diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-26 15:06:18 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-26 15:06:18 +0300 |
commit | 6a4ffad42050949fcf08e78147575734ae99627e (patch) | |
tree | 723bb2480948ba4ec29ca9ac10f8728dc2a831b6 /spec/frontend/performance_bar | |
parent | 23d237110e6a646dec08e1f5b4696d2d9c51cfef (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/performance_bar')
-rw-r--r-- | spec/frontend/performance_bar/components/request_selector_spec.js | 41 | ||||
-rw-r--r-- | spec/frontend/performance_bar/stores/performance_bar_store_spec.js | 45 |
2 files changed, 49 insertions, 37 deletions
diff --git a/spec/frontend/performance_bar/components/request_selector_spec.js b/spec/frontend/performance_bar/components/request_selector_spec.js index a4ed55fbf15..42ccb1f1b5c 100644 --- a/spec/frontend/performance_bar/components/request_selector_spec.js +++ b/spec/frontend/performance_bar/components/request_selector_spec.js @@ -4,23 +4,9 @@ import { shallowMount } from '@vue/test-utils'; describe('request selector', () => { const requests = [ { - id: '123', - url: 'https://gitlab.com/', - hasWarnings: false, - }, - { - id: '456', - url: 'https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/1', - hasWarnings: false, - }, - { - id: '789', - url: 'https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/1.json?serializer=widget', - hasWarnings: false, - }, - { - id: 'abc', + id: 'warningReq', url: 'https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/1/discussions.json', + truncatedUrl: 'discussions.json', hasWarnings: true, }, ]; @@ -28,35 +14,16 @@ describe('request selector', () => { const wrapper = shallowMount(RequestSelector, { propsData: { requests, - currentRequest: requests[1], + currentRequest: requests[0], }, }); - function optionText(requestId) { - return wrapper - .find(`[value='${requestId}']`) - .text() - .trim(); - } - - it('displays the last component of the path', () => { - expect(optionText(requests[2].id)).toEqual('1.json?serializer=widget'); - }); - - it('keeps the last two components of the path when the last component is numeric', () => { - expect(optionText(requests[1].id)).toEqual('merge_requests/1'); - }); - - it('ignores trailing slashes', () => { - expect(optionText(requests[0].id)).toEqual('gitlab.com'); - }); - it('has a warning icon if any requests have warnings', () => { expect(wrapper.find('span > gl-emoji').element.dataset.name).toEqual('warning'); }); it('adds a warning glyph to requests with warnings', () => { - const requestValue = wrapper.find('[value="abc"]').text(); + const requestValue = wrapper.find('[value="warningReq"]').text(); expect(requestValue).toContain('discussions.json'); expect(requestValue).toContain('(!)'); diff --git a/spec/frontend/performance_bar/stores/performance_bar_store_spec.js b/spec/frontend/performance_bar/stores/performance_bar_store_spec.js new file mode 100644 index 00000000000..686029a28a9 --- /dev/null +++ b/spec/frontend/performance_bar/stores/performance_bar_store_spec.js @@ -0,0 +1,45 @@ +import PerformanceBarStore from '~/performance_bar/stores/performance_bar_store'; + +describe('PerformanceBarStore', () => { + describe('truncateUrl', () => { + let store; + const findUrl = id => store.findRequest(id).truncatedUrl; + + beforeEach(() => { + store = new PerformanceBarStore(); + }); + + it('ignores trailing slashes', () => { + store.addRequest('id', 'https://gitlab.com/'); + expect(findUrl('id')).toEqual('gitlab.com'); + }); + + it('keeps the last two components of the path when the last component is numeric', () => { + store.addRequest('id', 'https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/1'); + expect(findUrl('id')).toEqual('merge_requests/1'); + }); + + it('uses the last component of the path', () => { + store.addRequest( + 'id', + 'https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/1.json?serializer=widget', + ); + expect(findUrl('id')).toEqual('1.json?serializer=widget'); + }); + + it('keeps query components', () => { + store.addRequest('id', 'http://localhost:3001/h5bp/html5-boilerplate/?param'); + expect(findUrl('id')).toEqual('html5-boilerplate?param'); + }); + + it('keeps components when query contains a slash', () => { + store.addRequest('id', 'http://localhost:3001/h5bp/html5-boilerplate?trunc/ated'); + expect(findUrl('id')).toEqual('html5-boilerplate?trunc/ated'); + }); + + it('ignores fragments', () => { + store.addRequest('id', 'http://localhost:3001/h5bp/html5-boilerplate/#frag/ment'); + expect(findUrl('id')).toEqual('html5-boilerplate'); + }); + }); +}); |