diff options
Diffstat (limited to 'spec/frontend/performance_bar')
4 files changed, 62 insertions, 13 deletions
diff --git a/spec/frontend/performance_bar/components/performance_bar_app_spec.js b/spec/frontend/performance_bar/components/performance_bar_app_spec.js index 2c9ab4bf78d..7a018236314 100644 --- a/spec/frontend/performance_bar/components/performance_bar_app_spec.js +++ b/spec/frontend/performance_bar/components/performance_bar_app_spec.js @@ -1,18 +1,53 @@ -import { shallowMount } from '@vue/test-utils'; +import { mount } from '@vue/test-utils'; +import { GlLink } from '@gitlab/ui'; import PerformanceBarApp from '~/performance_bar/components/performance_bar_app.vue'; import PerformanceBarStore from '~/performance_bar/stores/performance_bar_store'; describe('performance bar app', () => { + let wrapper; const store = new PerformanceBarStore(); - const wrapper = shallowMount(PerformanceBarApp, { - propsData: { - store, - env: 'development', - requestId: '123', - statsUrl: 'https://log.gprd.gitlab.net/app/dashboards#/view/', - peekUrl: '/-/peek/results', - profileUrl: '?lineprofiler=true', - }, + store.addRequest('123', 'https://gitlab.com', '', {}, 'GET'); + const createComponent = () => { + wrapper = mount(PerformanceBarApp, { + propsData: { + store, + env: 'development', + requestId: '123', + requestMethod: 'GET', + statsUrl: 'https://log.gprd.gitlab.net/app/dashboards#/view/', + peekUrl: '/-/peek/results', + }, + }); + }; + + beforeEach(() => { + createComponent(); + }); + + describe('flamegraph buttons', () => { + const flamegraphDiv = () => wrapper.find('#peek-flamegraph'); + const flamegraphLinks = () => flamegraphDiv().findAllComponents(GlLink); + + it('creates three flamegraph buttons based on the path', () => { + expect(flamegraphLinks()).toHaveLength(3); + + ['wall', 'cpu', 'object'].forEach((path, index) => { + expect(flamegraphLinks().at(index).attributes('href')).toBe( + `https://gitlab.com?performance_bar=flamegraph&stackprof_mode=${path}`, + ); + }); + }); + }); + + describe('memory report button', () => { + const memoryReportDiv = () => wrapper.find('#peek-memory-report'); + const memoryReportLink = () => memoryReportDiv().findComponent(GlLink); + + it('creates memory report button', () => { + expect(memoryReportLink().attributes('href')).toEqual( + 'https://gitlab.com?performance_bar=memory', + ); + }); }); it('sets the class to match the environment', () => { diff --git a/spec/frontend/performance_bar/index_spec.js b/spec/frontend/performance_bar/index_spec.js index f09b0cc3df8..1849c373326 100644 --- a/spec/frontend/performance_bar/index_spec.js +++ b/spec/frontend/performance_bar/index_spec.js @@ -20,9 +20,9 @@ describe('performance bar wrapper', () => { peekWrapper.setAttribute('id', 'js-peek'); peekWrapper.dataset.env = 'development'; peekWrapper.dataset.requestId = '123'; + peekWrapper.dataset.requestMethod = 'GET'; peekWrapper.dataset.peekUrl = '/-/peek/results'; peekWrapper.dataset.statsUrl = 'https://log.gprd.gitlab.net/app/dashboards#/view/'; - peekWrapper.dataset.profileUrl = '?lineprofiler=true'; mock = new MockAdapter(axios); @@ -70,7 +70,13 @@ describe('performance bar wrapper', () => { it('adds the request immediately', () => { vm.addRequest('123', 'https://gitlab.com/'); - expect(vm.store.addRequest).toHaveBeenCalledWith('123', 'https://gitlab.com/', undefined); + expect(vm.store.addRequest).toHaveBeenCalledWith( + '123', + 'https://gitlab.com/', + undefined, + undefined, + undefined, + ); }); }); diff --git a/spec/frontend/performance_bar/services/performance_bar_service_spec.js b/spec/frontend/performance_bar/services/performance_bar_service_spec.js index 1bb70a43a1b..b1f5f4d6982 100644 --- a/spec/frontend/performance_bar/services/performance_bar_service_spec.js +++ b/spec/frontend/performance_bar/services/performance_bar_service_spec.js @@ -66,7 +66,7 @@ describe('PerformanceBarService', () => { describe('operationName', () => { function requestUrl(response, peekUrl) { - return PerformanceBarService.callbackParams(response, peekUrl)[3]; + return PerformanceBarService.callbackParams(response, peekUrl)[4]; } it('gets the operation name from response.config', () => { diff --git a/spec/frontend/performance_bar/stores/performance_bar_store_spec.js b/spec/frontend/performance_bar/stores/performance_bar_store_spec.js index 7d5c5031792..170469db6ad 100644 --- a/spec/frontend/performance_bar/stores/performance_bar_store_spec.js +++ b/spec/frontend/performance_bar/stores/performance_bar_store_spec.js @@ -46,6 +46,14 @@ describe('PerformanceBarStore', () => { store.addRequest('id', 'http://localhost:3001/api/graphql', 'someOperation'); expect(findUrl('id')).toBe('graphql (someOperation)'); }); + + it('appends the number of batches queries when it is a GraphQL call', () => { + store.addRequest('id', 'http://localhost:3001/api/graphql', 'someOperation'); + store.addRequest('id', 'http://localhost:3001/api/graphql', 'anotherOperation'); + store.addRequest('id', 'http://localhost:3001/api/graphql', 'anotherOne'); + store.addRequest('anotherId', 'http://localhost:3001/api/graphql', 'operationName'); + expect(findUrl('id')).toBe('graphql (someOperation) [3 queries batched]'); + }); }); describe('setRequestDetailsData', () => { |