diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-08 09:09:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-08 09:09:13 +0300 |
commit | 0a319374e7784aa5c2d1c30dd832d2a0509edbab (patch) | |
tree | 123c5bac601b85d60cbaba541b25aed8c981c529 /spec/frontend/pipelines/test_reports | |
parent | 5683a027b79d2236bf9b3d1eb5303075584894d7 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/pipelines/test_reports')
5 files changed, 36 insertions, 20 deletions
diff --git a/spec/frontend/pipelines/test_reports/stores/actions_spec.js b/spec/frontend/pipelines/test_reports/stores/actions_spec.js index bd42db36645..c47c6e99103 100644 --- a/spec/frontend/pipelines/test_reports/stores/actions_spec.js +++ b/spec/frontend/pipelines/test_reports/stores/actions_spec.js @@ -22,7 +22,7 @@ describe('Actions TestReports Store', () => { fullReportEndpoint, summaryEndpoint, testReports: {}, - selectedSuite: {}, + selectedSuite: null, summary: {}, }; @@ -101,28 +101,28 @@ describe('Actions TestReports Store', () => { }); }); - describe('set selected suite', () => { - const selectedSuite = testReports.test_suites[0]; + describe('set selected suite index', () => { + const selectedSuiteIndex = 0; - it('sets selectedSuite', done => { + it('sets selectedSuiteIndex', done => { testAction( - actions.setSelectedSuite, - selectedSuite, + actions.setSelectedSuiteIndex, + selectedSuiteIndex, state, - [{ type: types.SET_SELECTED_SUITE, payload: selectedSuite }], + [{ 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 cf54cacab60..2320f84b3bb 100644 --- a/spec/frontend/pipelines/test_reports/stores/mutations_spec.js +++ b/spec/frontend/pipelines/test_reports/stores/mutations_spec.js @@ -10,7 +10,7 @@ describe('Mutations TestReports Store', () => { const defaultState = { endpoint: '', testReports: {}, - selectedSuite: {}, + selectedSuite: null, isLoading: false, }; @@ -27,12 +27,12 @@ describe('Mutations TestReports Store', () => { }); }); - describe('set selected suite', () => { - it('should set selectedSuite', () => { - const selectedSuite = testReports.test_suites[0]; - mutations[types.SET_SELECTED_SUITE](mockState, selectedSuite); + describe('set selected suite index', () => { + it('should set selectedSuiteIndex', () => { + const selectedSuiteIndex = 0; + mutations[types.SET_SELECTED_SUITE_INDEX](mockState, selectedSuiteIndex); - expect(mockState.selectedSuite).toEqual(selectedSuite); + expect(mockState.selectedSuiteIndex).toEqual(selectedSuiteIndex); }); }); diff --git a/spec/frontend/pipelines/test_reports/test_reports_spec.js b/spec/frontend/pipelines/test_reports/test_reports_spec.js index dd2b7220d7c..7bd71716cb0 100644 --- a/spec/frontend/pipelines/test_reports/test_reports_spec.js +++ b/spec/frontend/pipelines/test_reports/test_reports_spec.js @@ -3,6 +3,7 @@ import { shallowMount, createLocalVue } from '@vue/test-utils'; import { getJSONFixture } from 'helpers/fixtures'; import TestReports from '~/pipelines/components/test_reports/test_reports.vue'; import * as actions from '~/pipelines/stores/test_reports/actions'; +import * as getters from '~/pipelines/stores/test_reports/getters'; const localVue = createLocalVue(); localVue.use(Vuex); @@ -29,6 +30,7 @@ describe('Test reports app', () => { ...actions, fetchSummary: () => {}, }, + getters, }); wrapper = shallowMount(TestReports, { diff --git a/spec/frontend/pipelines/test_reports/test_suite_table_spec.js b/spec/frontend/pipelines/test_reports/test_suite_table_spec.js index 5d448bcb439..65bffe7039a 100644 --- a/spec/frontend/pipelines/test_reports/test_suite_table_spec.js +++ b/spec/frontend/pipelines/test_reports/test_suite_table_spec.js @@ -28,7 +28,10 @@ describe('Test reports suite table', () => { const createComponent = (suite = testSuite) => { store = new Vuex.Store({ state: { - selectedSuite: suite, + testReports: { + test_suites: [suite], + }, + selectedSuiteIndex: 0, }, getters, }); |