diff options
Diffstat (limited to 'spec/frontend/reports')
7 files changed, 105 insertions, 83 deletions
diff --git a/spec/frontend/reports/accessibility_report/store/actions_spec.js b/spec/frontend/reports/accessibility_report/store/actions_spec.js index 46dbe1ff7a1..bab6c4905a7 100644 --- a/spec/frontend/reports/accessibility_report/store/actions_spec.js +++ b/spec/frontend/reports/accessibility_report/store/actions_spec.js @@ -17,16 +17,15 @@ describe('Accessibility Reports actions', () => { }); describe('setEndpoints', () => { - it('should commit SET_ENDPOINTS mutation', (done) => { + it('should commit SET_ENDPOINTS mutation', () => { const endpoint = 'endpoint.json'; - testAction( + return testAction( actions.setEndpoint, endpoint, localState, [{ type: types.SET_ENDPOINT, payload: endpoint }], [], - done, ); }); }); @@ -46,11 +45,11 @@ describe('Accessibility Reports actions', () => { }); describe('success', () => { - it('should commit REQUEST_REPORT mutation and dispatch receiveReportSuccess', (done) => { + it('should commit REQUEST_REPORT mutation and dispatch receiveReportSuccess', () => { const data = { report: { summary: {} } }; mock.onGet(`${TEST_HOST}/endpoint.json`).reply(200, data); - testAction( + return testAction( actions.fetchReport, null, localState, @@ -61,60 +60,55 @@ describe('Accessibility Reports actions', () => { type: 'receiveReportSuccess', }, ], - done, ); }); }); describe('error', () => { - it('should commit REQUEST_REPORT and RECEIVE_REPORT_ERROR mutations', (done) => { + it('should commit REQUEST_REPORT and RECEIVE_REPORT_ERROR mutations', () => { mock.onGet(`${TEST_HOST}/endpoint.json`).reply(500); - testAction( + return testAction( actions.fetchReport, null, localState, [{ type: types.REQUEST_REPORT }], [{ type: 'receiveReportError' }], - done, ); }); }); }); describe('receiveReportSuccess', () => { - it('should commit RECEIVE_REPORT_SUCCESS mutation with 200', (done) => { - testAction( + it('should commit RECEIVE_REPORT_SUCCESS mutation with 200', () => { + return testAction( actions.receiveReportSuccess, { status: 200, data: mockReport }, localState, [{ type: types.RECEIVE_REPORT_SUCCESS, payload: mockReport }], [{ type: 'stopPolling' }], - done, ); }); - it('should not commit RECEIVE_REPORTS_SUCCESS mutation with 204', (done) => { - testAction( + it('should not commit RECEIVE_REPORTS_SUCCESS mutation with 204', () => { + return testAction( actions.receiveReportSuccess, { status: 204, data: mockReport }, localState, [], [], - done, ); }); }); describe('receiveReportError', () => { - it('should commit RECEIVE_REPORT_ERROR mutation', (done) => { - testAction( + it('should commit RECEIVE_REPORT_ERROR mutation', () => { + return testAction( actions.receiveReportError, null, localState, [{ type: types.RECEIVE_REPORT_ERROR }], [{ type: 'stopPolling' }], - done, ); }); }); diff --git a/spec/frontend/reports/codequality_report/components/codequality_issue_body_spec.js b/spec/frontend/reports/codequality_report/components/codequality_issue_body_spec.js index c548007a8a6..17f07ac2b8f 100644 --- a/spec/frontend/reports/codequality_report/components/codequality_issue_body_spec.js +++ b/spec/frontend/reports/codequality_report/components/codequality_issue_body_spec.js @@ -51,6 +51,7 @@ describe('code quality issue body issue body', () => { ${'blocker'} | ${'text-danger-800'} | ${'severity-critical'} ${'unknown'} | ${'text-secondary-400'} | ${'severity-unknown'} ${'invalid'} | ${'text-secondary-400'} | ${'severity-unknown'} + ${undefined} | ${'text-secondary-400'} | ${'severity-unknown'} `( 'renders correct icon for "$severity" severity rating', ({ severity, iconClass, iconName }) => { diff --git a/spec/frontend/reports/codequality_report/grouped_codequality_reports_app_spec.js b/spec/frontend/reports/codequality_report/grouped_codequality_reports_app_spec.js index 1f923f41274..b61b65c2713 100644 --- a/spec/frontend/reports/codequality_report/grouped_codequality_reports_app_spec.js +++ b/spec/frontend/reports/codequality_report/grouped_codequality_reports_app_spec.js @@ -135,7 +135,7 @@ describe('Grouped code quality reports app', () => { }); it('does not render a help icon', () => { - expect(findWidget().find('[data-testid="question-icon"]').exists()).toBe(false); + expect(findWidget().find('[data-testid="question-o-icon"]').exists()).toBe(false); }); describe('when base report was not found', () => { @@ -144,7 +144,7 @@ describe('Grouped code quality reports app', () => { }); it('renders a help icon with more information', () => { - expect(findWidget().find('[data-testid="question-icon"]').exists()).toBe(true); + expect(findWidget().find('[data-testid="question-o-icon"]').exists()).toBe(true); }); }); }); diff --git a/spec/frontend/reports/codequality_report/store/actions_spec.js b/spec/frontend/reports/codequality_report/store/actions_spec.js index 1821390786b..71f1a0f4de0 100644 --- a/spec/frontend/reports/codequality_report/store/actions_spec.js +++ b/spec/frontend/reports/codequality_report/store/actions_spec.js @@ -23,7 +23,7 @@ describe('Codequality Reports actions', () => { }); describe('setPaths', () => { - it('should commit SET_PATHS mutation', (done) => { + it('should commit SET_PATHS mutation', () => { const paths = { baseBlobPath: 'baseBlobPath', headBlobPath: 'headBlobPath', @@ -31,13 +31,12 @@ describe('Codequality Reports actions', () => { helpPath: 'codequalityHelpPath', }; - testAction( + return testAction( actions.setPaths, paths, localState, [{ type: types.SET_PATHS, payload: paths }], [], - done, ); }); }); @@ -56,10 +55,10 @@ describe('Codequality Reports actions', () => { }); describe('on success', () => { - it('commits REQUEST_REPORTS and dispatches receiveReportsSuccess', (done) => { + it('commits REQUEST_REPORTS and dispatches receiveReportsSuccess', () => { mock.onGet(endpoint).reply(200, reportIssues); - testAction( + return testAction( actions.fetchReports, null, localState, @@ -70,51 +69,48 @@ describe('Codequality Reports actions', () => { type: 'receiveReportsSuccess', }, ], - done, ); }); }); describe('on error', () => { - it('commits REQUEST_REPORTS and dispatches receiveReportsError', (done) => { + it('commits REQUEST_REPORTS and dispatches receiveReportsError', () => { mock.onGet(endpoint).reply(500); - testAction( + return testAction( actions.fetchReports, null, localState, [{ type: types.REQUEST_REPORTS }], [{ type: 'receiveReportsError', payload: expect.any(Error) }], - done, ); }); }); describe('when base report is not found', () => { - it('commits REQUEST_REPORTS and dispatches receiveReportsError', (done) => { + it('commits REQUEST_REPORTS and dispatches receiveReportsError', () => { const data = { status: STATUS_NOT_FOUND }; mock.onGet(`${TEST_HOST}/codequality_reports.json`).reply(200, data); - testAction( + return testAction( actions.fetchReports, null, localState, [{ type: types.REQUEST_REPORTS }], [{ type: 'receiveReportsError', payload: data }], - done, ); }); }); describe('while waiting for report results', () => { - it('continues polling until it receives data', (done) => { + it('continues polling until it receives data', () => { mock .onGet(endpoint) .replyOnce(204, undefined, pollIntervalHeader) .onGet(endpoint) .reply(200, reportIssues); - Promise.all([ + return Promise.all([ testAction( actions.fetchReports, null, @@ -126,7 +122,6 @@ describe('Codequality Reports actions', () => { type: 'receiveReportsSuccess', }, ], - done, ), axios // wait for initial NO_CONTENT response to be fulfilled @@ -134,24 +129,23 @@ describe('Codequality Reports actions', () => { .then(() => { jest.advanceTimersByTime(pollInterval); }), - ]).catch(done.fail); + ]); }); - it('continues polling until it receives an error', (done) => { + it('continues polling until it receives an error', () => { mock .onGet(endpoint) .replyOnce(204, undefined, pollIntervalHeader) .onGet(endpoint) .reply(500); - Promise.all([ + return Promise.all([ testAction( actions.fetchReports, null, localState, [{ type: types.REQUEST_REPORTS }], [{ type: 'receiveReportsError', payload: expect.any(Error) }], - done, ), axios // wait for initial NO_CONTENT response to be fulfilled @@ -159,35 +153,33 @@ describe('Codequality Reports actions', () => { .then(() => { jest.advanceTimersByTime(pollInterval); }), - ]).catch(done.fail); + ]); }); }); }); describe('receiveReportsSuccess', () => { - it('commits RECEIVE_REPORTS_SUCCESS', (done) => { + it('commits RECEIVE_REPORTS_SUCCESS', () => { const data = { issues: [] }; - testAction( + return testAction( actions.receiveReportsSuccess, data, localState, [{ type: types.RECEIVE_REPORTS_SUCCESS, payload: data }], [], - done, ); }); }); describe('receiveReportsError', () => { - it('commits RECEIVE_REPORTS_ERROR', (done) => { - testAction( + it('commits RECEIVE_REPORTS_ERROR', () => { + return testAction( actions.receiveReportsError, null, localState, [{ type: types.RECEIVE_REPORTS_ERROR, payload: null }], [], - done, ); }); }); diff --git a/spec/frontend/reports/components/report_section_spec.js b/spec/frontend/reports/components/report_section_spec.js index f9eb6dd05f3..888b49f3e0c 100644 --- a/spec/frontend/reports/components/report_section_spec.js +++ b/spec/frontend/reports/components/report_section_spec.js @@ -2,6 +2,7 @@ import { mount } from '@vue/test-utils'; import Vue, { nextTick } from 'vue'; import mountComponent, { mountComponentWithSlots } from 'helpers/vue_mount_component_helper'; import { extendedWrapper } from 'helpers/vue_test_utils_helper'; +import HelpPopover from '~/vue_shared/components/help_popover.vue'; import reportSection from '~/reports/components/report_section.vue'; describe('Report section', () => { @@ -9,6 +10,7 @@ describe('Report section', () => { let wrapper; const ReportSection = Vue.extend(reportSection); const findCollapseButton = () => wrapper.findByTestId('report-section-expand-button'); + const findPopover = () => wrapper.findComponent(HelpPopover); const resolvedIssues = [ { @@ -269,4 +271,33 @@ describe('Report section', () => { expect(vm.$el.textContent.trim()).not.toContain('This is a success'); }); }); + + describe('help popover', () => { + describe('when popover options are defined', () => { + const options = { + title: 'foo', + content: 'bar', + }; + + beforeEach(() => { + createComponent({ + popoverOptions: options, + }); + }); + + it('popover is shown with options', () => { + expect(findPopover().props('options')).toEqual(options); + }); + }); + + describe('when popover options are not defined', () => { + beforeEach(() => { + createComponent({ popoverOptions: {} }); + }); + + it('popover is not shown', () => { + expect(findPopover().exists()).toBe(false); + }); + }); + }); }); diff --git a/spec/frontend/reports/components/summary_row_spec.js b/spec/frontend/reports/components/summary_row_spec.js index 04d9d10dcd2..778660d9e44 100644 --- a/spec/frontend/reports/components/summary_row_spec.js +++ b/spec/frontend/reports/components/summary_row_spec.js @@ -1,25 +1,26 @@ import { mount } from '@vue/test-utils'; import { extendedWrapper } from 'helpers/vue_test_utils_helper'; +import HelpPopover from '~/vue_shared/components/help_popover.vue'; import SummaryRow from '~/reports/components/summary_row.vue'; describe('Summary row', () => { let wrapper; - const props = { - summary: 'SAST detected 1 new vulnerability and 1 fixed vulnerability', - popoverOptions: { - title: 'Static Application Security Testing (SAST)', - content: '<a>Learn more about SAST</a>', - }, - statusIcon: 'warning', + const summary = 'SAST detected 1 new vulnerability and 1 fixed vulnerability'; + const popoverOptions = { + title: 'Static Application Security Testing (SAST)', + content: '<a>Learn more about SAST</a>', }; + const statusIcon = 'warning'; - const createComponent = ({ propsData = {}, slots = {} } = {}) => { + const createComponent = ({ props = {}, slots = {} } = {}) => { wrapper = extendedWrapper( mount(SummaryRow, { propsData: { + summary, + popoverOptions, + statusIcon, ...props, - ...propsData, }, slots, }), @@ -28,6 +29,7 @@ describe('Summary row', () => { const findSummary = () => wrapper.findByTestId('summary-row-description'); const findStatusIcon = () => wrapper.findByTestId('summary-row-icon'); + const findHelpPopover = () => wrapper.findComponent(HelpPopover); afterEach(() => { wrapper.destroy(); @@ -36,7 +38,7 @@ describe('Summary row', () => { it('renders provided summary', () => { createComponent(); - expect(findSummary().text()).toContain(props.summary); + expect(findSummary().text()).toContain(summary); }); it('renders provided icon', () => { @@ -44,12 +46,22 @@ describe('Summary row', () => { expect(findStatusIcon().classes()).toContain('js-ci-status-icon-warning'); }); + it('renders help popover if popoverOptions are provided', () => { + createComponent(); + expect(findHelpPopover().props('options')).toEqual(popoverOptions); + }); + + it('does not render help popover if popoverOptions are not provided', () => { + createComponent({ props: { popoverOptions: null } }); + expect(findHelpPopover().exists()).toBe(false); + }); + describe('summary slot', () => { it('replaces the summary prop', () => { const summarySlotContent = 'Summary slot content'; createComponent({ slots: { summary: summarySlotContent } }); - expect(wrapper.text()).not.toContain(props.summary); + expect(wrapper.text()).not.toContain(summary); expect(findSummary().text()).toContain(summarySlotContent); }); }); diff --git a/spec/frontend/reports/grouped_test_report/store/actions_spec.js b/spec/frontend/reports/grouped_test_report/store/actions_spec.js index bbc3a5dbba5..5876827c548 100644 --- a/spec/frontend/reports/grouped_test_report/store/actions_spec.js +++ b/spec/frontend/reports/grouped_test_report/store/actions_spec.js @@ -24,8 +24,8 @@ describe('Reports Store Actions', () => { }); describe('setPaths', () => { - it('should commit SET_PATHS mutation', (done) => { - testAction( + it('should commit SET_PATHS mutation', () => { + return testAction( setPaths, { endpoint: 'endpoint.json', headBlobPath: '/blob/path' }, mockedState, @@ -36,14 +36,13 @@ describe('Reports Store Actions', () => { }, ], [], - done, ); }); }); describe('requestReports', () => { - it('should commit REQUEST_REPORTS mutation', (done) => { - testAction(requestReports, null, mockedState, [{ type: types.REQUEST_REPORTS }], [], done); + it('should commit REQUEST_REPORTS mutation', () => { + return testAction(requestReports, null, mockedState, [{ type: types.REQUEST_REPORTS }], []); }); }); @@ -62,12 +61,12 @@ describe('Reports Store Actions', () => { }); describe('success', () => { - it('dispatches requestReports and receiveReportsSuccess ', (done) => { + it('dispatches requestReports and receiveReportsSuccess ', () => { mock .onGet(`${TEST_HOST}/endpoint.json`) .replyOnce(200, { summary: {}, suites: [{ name: 'rspec' }] }); - testAction( + return testAction( fetchReports, null, mockedState, @@ -81,7 +80,6 @@ describe('Reports Store Actions', () => { type: 'receiveReportsSuccess', }, ], - done, ); }); }); @@ -91,8 +89,8 @@ describe('Reports Store Actions', () => { mock.onGet(`${TEST_HOST}/endpoint.json`).reply(500); }); - it('dispatches requestReports and receiveReportsError ', (done) => { - testAction( + it('dispatches requestReports and receiveReportsError ', () => { + return testAction( fetchReports, null, mockedState, @@ -105,71 +103,65 @@ describe('Reports Store Actions', () => { type: 'receiveReportsError', }, ], - done, ); }); }); }); describe('receiveReportsSuccess', () => { - it('should commit RECEIVE_REPORTS_SUCCESS mutation with 200', (done) => { - testAction( + it('should commit RECEIVE_REPORTS_SUCCESS mutation with 200', () => { + return testAction( receiveReportsSuccess, { data: { summary: {} }, status: 200 }, mockedState, [{ type: types.RECEIVE_REPORTS_SUCCESS, payload: { summary: {} } }], [], - done, ); }); - it('should not commit RECEIVE_REPORTS_SUCCESS mutation with 204', (done) => { - testAction( + it('should not commit RECEIVE_REPORTS_SUCCESS mutation with 204', () => { + return testAction( receiveReportsSuccess, { data: { summary: {} }, status: 204 }, mockedState, [], [], - done, ); }); }); describe('receiveReportsError', () => { - it('should commit RECEIVE_REPORTS_ERROR mutation', (done) => { - testAction( + it('should commit RECEIVE_REPORTS_ERROR mutation', () => { + return testAction( receiveReportsError, null, mockedState, [{ type: types.RECEIVE_REPORTS_ERROR }], [], - done, ); }); }); describe('openModal', () => { - it('should commit SET_ISSUE_MODAL_DATA', (done) => { - testAction( + it('should commit SET_ISSUE_MODAL_DATA', () => { + return testAction( openModal, { name: 'foo' }, mockedState, [{ type: types.SET_ISSUE_MODAL_DATA, payload: { name: 'foo' } }], [], - done, ); }); }); describe('closeModal', () => { - it('should commit RESET_ISSUE_MODAL_DATA', (done) => { - testAction( + it('should commit RESET_ISSUE_MODAL_DATA', () => { + return testAction( closeModal, {}, mockedState, [{ type: types.RESET_ISSUE_MODAL_DATA, payload: {} }], [], - done, ); }); }); |