Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/pipelines/test_reports/stores/actions_spec.js')
-rw-r--r--spec/frontend/pipelines/test_reports/stores/actions_spec.js124
1 files changed, 53 insertions, 71 deletions
diff --git a/spec/frontend/pipelines/test_reports/stores/actions_spec.js b/spec/frontend/pipelines/test_reports/stores/actions_spec.js
index d4647c55a53..1809f15a6e6 100644
--- a/spec/frontend/pipelines/test_reports/stores/actions_spec.js
+++ b/spec/frontend/pipelines/test_reports/stores/actions_spec.js
@@ -5,7 +5,7 @@ import * as actions from '~/pipelines/stores/test_reports/actions';
import * as types from '~/pipelines/stores/test_reports/mutation_types';
import { TEST_HOST } from '../../../helpers/test_constants';
import testAction from '../../../helpers/vuex_action_helper';
-import createFlash from '~/flash';
+import { deprecatedCreateFlash as createFlash } from '~/flash';
jest.mock('~/flash.js');
@@ -16,14 +16,13 @@ describe('Actions TestReports Store', () => {
const testReports = getJSONFixture('pipelines/test_report.json');
const summary = { total_count: 1 };
- const fullReportEndpoint = `${TEST_HOST}/test_reports.json`;
+ const suiteEndpoint = `${TEST_HOST}/tests/:suite_name.json`;
const summaryEndpoint = `${TEST_HOST}/test_reports/summary.json`;
const defaultState = {
- fullReportEndpoint,
+ suiteEndpoint,
summaryEndpoint,
testReports: {},
selectedSuite: null,
- useBuildSummaryReport: false,
};
beforeEach(() => {
@@ -40,89 +39,63 @@ describe('Actions TestReports Store', () => {
mock.onGet(summaryEndpoint).replyOnce(200, summary, {});
});
- describe('when useBuildSummaryReport in state is true', () => {
- it('sets testReports and shows tests', done => {
- testAction(
- actions.fetchSummary,
- null,
- { ...state, useBuildSummaryReport: true },
- [{ type: types.SET_SUMMARY, payload: summary }],
- [{ type: 'toggleLoading' }, { type: 'toggleLoading' }],
- done,
- );
- });
-
- it('should create flash on API error', done => {
- testAction(
- actions.fetchSummary,
- null,
- {
- summaryEndpoint: null,
- useBuildSummaryReport: true,
- },
- [],
- [{ type: 'toggleLoading' }, { type: 'toggleLoading' }],
- () => {
- expect(createFlash).toHaveBeenCalled();
- done();
- },
- );
- });
+ it('sets testReports and shows tests', done => {
+ testAction(
+ actions.fetchSummary,
+ null,
+ state,
+ [{ type: types.SET_SUMMARY, payload: summary }],
+ [{ type: 'toggleLoading' }, { type: 'toggleLoading' }],
+ done,
+ );
});
- describe('when useBuildSummaryReport in state is false', () => {
- it('sets testReports and shows tests', done => {
- testAction(
- actions.fetchSummary,
- null,
- state,
- [{ type: types.SET_SUMMARY, payload: summary }],
- [],
- done,
- );
- });
-
- it('should create flash on API error', done => {
- testAction(
- actions.fetchSummary,
- null,
- {
- summaryEndpoint: null,
- },
- [],
- [],
- () => {
- expect(createFlash).toHaveBeenCalled();
- done();
- },
- );
- });
+ it('should create flash on API error', done => {
+ testAction(
+ actions.fetchSummary,
+ null,
+ { summaryEndpoint: null },
+ [],
+ [{ type: 'toggleLoading' }, { type: 'toggleLoading' }],
+ () => {
+ expect(createFlash).toHaveBeenCalled();
+ done();
+ },
+ );
});
});
- describe('fetch full report', () => {
+ describe('fetch test suite', () => {
beforeEach(() => {
- mock.onGet(fullReportEndpoint).replyOnce(200, testReports, {});
+ const buildIds = [1];
+ testReports.test_suites[0].build_ids = buildIds;
+ const endpoint = suiteEndpoint.replace(':suite_name', testReports.test_suites[0].name);
+ mock
+ .onGet(endpoint, { params: { build_ids: buildIds } })
+ .replyOnce(200, testReports.test_suites[0], {});
});
- it('sets testReports and shows tests', done => {
+ it('sets test suite and shows tests', done => {
+ const suite = testReports.test_suites[0];
+ const index = 0;
+
testAction(
- actions.fetchFullReport,
- null,
- state,
- [{ type: types.SET_REPORTS, payload: testReports }],
+ actions.fetchTestSuite,
+ index,
+ { ...state, testReports },
+ [{ type: types.SET_SUITE, payload: { suite, index } }],
[{ type: 'toggleLoading' }, { type: 'toggleLoading' }],
done,
);
});
it('should create flash on API error', done => {
+ const index = 0;
+
testAction(
- actions.fetchFullReport,
- null,
- {
- fullReportEndpoint: null,
- },
+ actions.fetchTestSuite,
+ index,
+ { ...state, testReports, suiteEndpoint: null },
[],
[{ type: 'toggleLoading' }, { type: 'toggleLoading' }],
() => {
@@ -131,6 +104,15 @@ describe('Actions TestReports Store', () => {
},
);
});
+
+ describe('when we already have the suite data', () => {
+ it('should not fetch suite', done => {
+ const index = 0;
+ testReports.test_suites[0].hasFullSuite = true;
+
+ testAction(actions.fetchTestSuite, index, { ...state, testReports }, [], [], done);
+ });
+ });
});
describe('set selected suite index', () => {