diff options
Diffstat (limited to 'spec/frontend/performance_bar/components/performance_bar_app_spec.js')
-rw-r--r-- | spec/frontend/performance_bar/components/performance_bar_app_spec.js | 55 |
1 files changed, 45 insertions, 10 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', () => { |