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')
-rw-r--r--spec/frontend/pipelines/test_reports/stores/actions_spec.js109
-rw-r--r--spec/frontend/pipelines/test_reports/stores/getters_spec.js15
-rw-r--r--spec/frontend/pipelines/test_reports/stores/mutations_spec.js34
3 files changed, 120 insertions, 38 deletions
diff --git a/spec/frontend/pipelines/test_reports/stores/actions_spec.js b/spec/frontend/pipelines/test_reports/stores/actions_spec.js
index 56148361e0a..d4647c55a53 100644
--- a/spec/frontend/pipelines/test_reports/stores/actions_spec.js
+++ b/spec/frontend/pipelines/test_reports/stores/actions_spec.js
@@ -14,31 +14,100 @@ describe('Actions TestReports Store', () => {
let state;
const testReports = getJSONFixture('pipelines/test_report.json');
+ const summary = { total_count: 1 };
- const endpoint = `${TEST_HOST}/test_reports.json`;
+ const fullReportEndpoint = `${TEST_HOST}/test_reports.json`;
+ const summaryEndpoint = `${TEST_HOST}/test_reports/summary.json`;
const defaultState = {
- endpoint,
+ fullReportEndpoint,
+ summaryEndpoint,
testReports: {},
- selectedSuite: {},
+ selectedSuite: null,
+ useBuildSummaryReport: false,
};
beforeEach(() => {
mock = new MockAdapter(axios);
- state = defaultState;
+ state = { ...defaultState };
});
afterEach(() => {
mock.restore();
});
- describe('fetch reports', () => {
+ describe('fetch report summary', () => {
beforeEach(() => {
- mock.onGet(`${TEST_HOST}/test_reports.json`).replyOnce(200, testReports, {});
+ 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();
+ },
+ );
+ });
+ });
+
+ 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();
+ },
+ );
+ });
+ });
+ });
+
+ describe('fetch full report', () => {
+ beforeEach(() => {
+ mock.onGet(fullReportEndpoint).replyOnce(200, testReports, {});
});
it('sets testReports and shows tests', done => {
testAction(
- actions.fetchReports,
+ actions.fetchFullReport,
null,
state,
[{ type: types.SET_REPORTS, payload: testReports }],
@@ -49,10 +118,10 @@ describe('Actions TestReports Store', () => {
it('should create flash on API error', done => {
testAction(
- actions.fetchReports,
+ actions.fetchFullReport,
null,
{
- endpoint: null,
+ fullReportEndpoint: null,
},
[],
[{ type: 'toggleLoading' }, { type: 'toggleLoading' }],
@@ -64,28 +133,28 @@ describe('Actions TestReports Store', () => {
});
});
- describe('set selected suite', () => {
- const selectedSuite = testReports.test_suites[0];
+ describe('set selected suite index', () => {
+ it('sets selectedSuiteIndex', done => {
+ const selectedSuiteIndex = 0;
- it('sets selectedSuite', done => {
testAction(
- actions.setSelectedSuite,
- selectedSuite,
- state,
- [{ type: types.SET_SELECTED_SUITE, payload: selectedSuite }],
+ actions.setSelectedSuiteIndex,
+ selectedSuiteIndex,
+ { ...state, hasFullReport: true },
+ [{ type: types.SET_SELECTED_SUITE_INDEX, payload: selectedSuiteIndex }],
[],
done,
);
});
});
- describe('remove selected suite', () => {
- it('sets selectedSuite to {}', done => {
+ describe('remove selected suite index', () => {
+ it('sets selectedSuiteIndex to null', done => {
testAction(
- actions.removeSelectedSuite,
+ actions.removeSelectedSuiteIndex,
{},
state,
- [{ type: types.SET_SELECTED_SUITE, payload: {} }],
+ [{ type: types.SET_SELECTED_SUITE_INDEX, payload: null }],
[],
done,
);
diff --git a/spec/frontend/pipelines/test_reports/stores/getters_spec.js b/spec/frontend/pipelines/test_reports/stores/getters_spec.js
index 011a7e68908..ca9ebb54138 100644
--- a/spec/frontend/pipelines/test_reports/stores/getters_spec.js
+++ b/spec/frontend/pipelines/test_reports/stores/getters_spec.js
@@ -9,12 +9,12 @@ describe('Getters TestReports Store', () => {
const defaultState = {
testReports,
- selectedSuite: testReports.test_suites[0],
+ selectedSuiteIndex: 0,
};
const emptyState = {
testReports: {},
- selectedSuite: {},
+ selectedSuite: null,
};
beforeEach(() => {
@@ -47,6 +47,17 @@ describe('Getters TestReports Store', () => {
});
});
+ describe('getSelectedSuite', () => {
+ it('should return the selected suite', () => {
+ setupState();
+
+ const selectedSuite = getters.getSelectedSuite(state);
+ const expected = testReports.test_suites[state.selectedSuiteIndex];
+
+ expect(selectedSuite).toEqual(expected);
+ });
+ });
+
describe('getSuiteTests', () => {
it('should return the test cases inside the suite', () => {
setupState();
diff --git a/spec/frontend/pipelines/test_reports/stores/mutations_spec.js b/spec/frontend/pipelines/test_reports/stores/mutations_spec.js
index a0eb93c4e6b..f4cc5c4bc5d 100644
--- a/spec/frontend/pipelines/test_reports/stores/mutations_spec.js
+++ b/spec/frontend/pipelines/test_reports/stores/mutations_spec.js
@@ -10,21 +10,13 @@ describe('Mutations TestReports Store', () => {
const defaultState = {
endpoint: '',
testReports: {},
- selectedSuite: {},
+ selectedSuite: null,
isLoading: false,
+ hasFullReport: false,
};
beforeEach(() => {
- mockState = defaultState;
- });
-
- describe('set endpoint', () => {
- it('should set endpoint', () => {
- const expectedState = { ...mockState, endpoint: 'foo' };
- mutations[types.SET_ENDPOINT](mockState, 'foo');
-
- expect(mockState.endpoint).toEqual(expectedState.endpoint);
- });
+ mockState = { ...defaultState };
});
describe('set reports', () => {
@@ -33,15 +25,25 @@ describe('Mutations TestReports Store', () => {
mutations[types.SET_REPORTS](mockState, testReports);
expect(mockState.testReports).toEqual(expectedState.testReports);
+ expect(mockState.hasFullReport).toBe(true);
+ });
+ });
+
+ describe('set selected suite index', () => {
+ it('should set selectedSuiteIndex', () => {
+ const selectedSuiteIndex = 0;
+ mutations[types.SET_SELECTED_SUITE_INDEX](mockState, selectedSuiteIndex);
+
+ expect(mockState.selectedSuiteIndex).toEqual(selectedSuiteIndex);
});
});
- describe('set selected suite', () => {
- it('should set selectedSuite', () => {
- const selectedSuite = testReports.test_suites[0];
- mutations[types.SET_SELECTED_SUITE](mockState, selectedSuite);
+ describe('set summary', () => {
+ it('should set summary', () => {
+ const summary = { total_count: 1 };
+ mutations[types.SET_SUMMARY](mockState, summary);
- expect(mockState.selectedSuite).toEqual(selectedSuite);
+ expect(mockState.testReports).toEqual(summary);
});
});