diff --git a/app/assets/javascripts/ci/job_details/store/actions.js b/app/assets/javascripts/ci/job_details/store/actions.js index a54dbf2e7b1828cd4b66d707ba31e99a5eee3fd8..1a018c577acba1929024e0d22f56ecb606691be8 100644 --- a/app/assets/javascripts/ci/job_details/store/actions.js +++ b/app/assets/javascripts/ci/job_details/store/actions.js @@ -282,7 +282,7 @@ export const triggerManualJob = ({ state }, variables) => { }; export const requestTestSummary = ({ state, commit, dispatch }) => { - if (!state.testSummaryComplete) { + if (!state.testSummaryComplete && state.testReportSummaryUrl?.length) { axios .get(state.testReportSummaryUrl) .then(({ data }) => { diff --git a/spec/frontend/ci/job_details/store/actions_spec.js b/spec/frontend/ci/job_details/store/actions_spec.js index 3e3e872f69816e263e2806e66bf2b7b72f7b73ac..43db1885b1f36d34e481a105078bfbebfac449c9 100644 --- a/spec/frontend/ci/job_details/store/actions_spec.js +++ b/spec/frontend/ci/job_details/store/actions_spec.js @@ -25,6 +25,7 @@ import { showSidebar, toggleSidebar, receiveTestSummarySuccess, + requestTestSummary, } from '~/ci/job_details/store/actions'; import { isScrolledToBottom } from '~/lib/utils/scroll_utils'; @@ -32,6 +33,7 @@ import * as types from '~/ci/job_details/store/mutation_types'; import state from '~/ci/job_details/store/state'; import axios from '~/lib/utils/axios_utils'; import { HTTP_STATUS_INTERNAL_SERVER_ERROR, HTTP_STATUS_OK } from '~/lib/utils/http_status'; +import { testSummaryData } from 'jest/ci/jobs_mock_data'; jest.mock('~/lib/utils/scroll_utils'); @@ -555,4 +557,47 @@ describe('Job State actions', () => { ); }); }); + + describe('requestTestSummary', () => { + let mock; + + beforeEach(() => { + mock = new MockAdapter(axios); + }); + + afterEach(() => { + mock.restore(); + stopPolling(); + clearEtagPoll(); + }); + + describe('success', () => { + it('dispatches receiveTestSummarySuccess', () => { + mockedState.testReportSummaryUrl = `${TEST_HOST}/test_report_summary.json`; + + mock + .onGet(`${TEST_HOST}/test_report_summary.json`) + .replyOnce(HTTP_STATUS_OK, testSummaryData); + + return testAction( + requestTestSummary, + null, + mockedState, + [{ type: types.RECEIVE_TEST_SUMMARY_COMPLETE }], + [ + { + payload: testSummaryData, + type: 'receiveTestSummarySuccess', + }, + ], + ); + }); + }); + + describe('without testReportSummaryUrl', () => { + it('does not dispatch any actions or mutations', () => { + return testAction(requestTestSummary, null, mockedState, [], []); + }); + }); + }); });