diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 11:59:07 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 11:59:07 +0000 |
commit | 8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch) | |
tree | 544930fb309b30317ae9797a9683768705d664c4 /spec/frontend/pipelines/test_reports | |
parent | 4b1de649d0168371549608993deac953eb692019 (diff) | |
download | gitlab-ce-8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca.tar.gz |
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'spec/frontend/pipelines/test_reports')
3 files changed, 62 insertions, 8 deletions
diff --git a/spec/frontend/pipelines/test_reports/stores/getters_spec.js b/spec/frontend/pipelines/test_reports/stores/getters_spec.js index 58e8065033f..8cef499fdb9 100644 --- a/spec/frontend/pipelines/test_reports/stores/getters_spec.js +++ b/spec/frontend/pipelines/test_reports/stores/getters_spec.js @@ -10,11 +10,19 @@ describe('Getters TestReports Store', () => { const defaultState = { testReports, selectedSuiteIndex: 0, + pageInfo: { + page: 1, + perPage: 2, + }, }; const emptyState = { testReports: {}, selectedSuite: null, + pageInfo: { + page: 1, + perPage: 2, + }, }; beforeEach(() => { @@ -59,15 +67,17 @@ describe('Getters TestReports Store', () => { }); describe('getSuiteTests', () => { - it('should return the test cases inside the suite', () => { + it('should return the current page of test cases inside the suite', () => { setupState(); const cases = getters.getSuiteTests(state); - const expected = testReports.test_suites[0].test_cases.map(x => ({ - ...x, - formattedTime: formattedTime(x.execution_time), - icon: iconForTestStatus(x.status), - })); + const expected = testReports.test_suites[0].test_cases + .map(x => ({ + ...x, + formattedTime: formattedTime(x.execution_time), + icon: iconForTestStatus(x.status), + })) + .slice(0, state.pageInfo.perPage); expect(cases).toEqual(expected); }); @@ -78,4 +88,15 @@ describe('Getters TestReports Store', () => { expect(getters.getSuiteTests(state)).toEqual([]); }); }); + + describe('getSuiteTestCount', () => { + it('should return the total number of test cases', () => { + setupState(); + + const testCount = getters.getSuiteTestCount(state); + const expected = testReports.test_suites[0].test_cases.length; + + expect(testCount).toEqual(expected); + }); + }); }); diff --git a/spec/frontend/pipelines/test_reports/stores/mutations_spec.js b/spec/frontend/pipelines/test_reports/stores/mutations_spec.js index b935029bc6a..191e9e7391c 100644 --- a/spec/frontend/pipelines/test_reports/stores/mutations_spec.js +++ b/spec/frontend/pipelines/test_reports/stores/mutations_spec.js @@ -12,12 +12,25 @@ describe('Mutations TestReports Store', () => { testReports: {}, selectedSuite: null, isLoading: false, + pageInfo: { + page: 1, + perPage: 2, + }, }; beforeEach(() => { mockState = { ...defaultState }; }); + describe('set page', () => { + it('should set the current page to display', () => { + const pageToDisplay = 3; + mutations[types.SET_PAGE](mockState, pageToDisplay); + + expect(mockState.pageInfo.page).toEqual(pageToDisplay); + }); + }); + describe('set suite', () => { it('should set the suite at the given index', () => { mockState.testReports = 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 284099b000b..0e00ca670a7 100644 --- a/spec/frontend/pipelines/test_reports/test_suite_table_spec.js +++ b/spec/frontend/pipelines/test_reports/test_suite_table_spec.js @@ -1,7 +1,7 @@ import Vuex from 'vuex'; import { shallowMount, createLocalVue } from '@vue/test-utils'; import { getJSONFixture } from 'helpers/fixtures'; -import { GlButton, GlFriendlyWrap } from '@gitlab/ui'; +import { GlButton, GlFriendlyWrap, GlPagination } from '@gitlab/ui'; import SuiteTable from '~/pipelines/components/test_reports/test_suite_table.vue'; import * as getters from '~/pipelines/stores/test_reports/getters'; import { TestStatus } from '~/pipelines/constants'; @@ -26,13 +26,17 @@ describe('Test reports suite table', () => { const findCaseRowAtIndex = index => wrapper.findAll('.js-case-row').at(index); const findIconForRow = (row, status) => row.find(`.ci-status-icon-${status}`); - const createComponent = (suite = testSuite) => { + const createComponent = (suite = testSuite, perPage = 20) => { store = new Vuex.Store({ state: { testReports: { test_suites: [suite], }, selectedSuiteIndex: 0, + pageInfo: { + page: 1, + perPage, + }, }, getters, }); @@ -86,4 +90,20 @@ describe('Test reports suite table', () => { expect(button.attributes('data-clipboard-text')).toBe(file); }); }); + + describe('when a test suite has more test cases than the pagination size', () => { + const perPage = 2; + + beforeEach(() => { + createComponent(testSuite, perPage); + }); + + it('renders one page of test cases', () => { + expect(allCaseRows().length).toBe(perPage); + }); + + it('renders a pagination component', () => { + expect(wrapper.find(GlPagination).exists()).toBe(true); + }); + }); }); |