diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 01:45:44 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 01:45:44 +0000 |
commit | 85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch) | |
tree | 9160f299afd8c80c038f08e1545be119f5e3f1e1 /spec/frontend/pipelines/test_reports | |
parent | 15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff) | |
download | gitlab-ce-85dc423f7090da0a52c73eb66faf22ddb20efff9.tar.gz |
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
Diffstat (limited to 'spec/frontend/pipelines/test_reports')
5 files changed, 39 insertions, 19 deletions
diff --git a/spec/frontend/pipelines/test_reports/stores/getters_spec.js b/spec/frontend/pipelines/test_reports/stores/getters_spec.js index ca9ebb54138..58e8065033f 100644 --- a/spec/frontend/pipelines/test_reports/stores/getters_spec.js +++ b/spec/frontend/pipelines/test_reports/stores/getters_spec.js @@ -1,6 +1,6 @@ import { getJSONFixture } from 'helpers/fixtures'; import * as getters from '~/pipelines/stores/test_reports/getters'; -import { iconForTestStatus } from '~/pipelines/stores/test_reports/utils'; +import { iconForTestStatus, formattedTime } from '~/pipelines/stores/test_reports/utils'; describe('Getters TestReports Store', () => { let state; @@ -34,7 +34,7 @@ describe('Getters TestReports Store', () => { const suites = getters.getTestSuites(state); const expected = testReports.test_suites.map(x => ({ ...x, - formattedTime: '00:00:00', + formattedTime: formattedTime(x.total_time), })); expect(suites).toEqual(expected); @@ -65,7 +65,7 @@ describe('Getters TestReports Store', () => { const cases = getters.getSuiteTests(state); const expected = testReports.test_suites[0].test_cases.map(x => ({ ...x, - formattedTime: '00:00:00', + formattedTime: formattedTime(x.execution_time), icon: iconForTestStatus(x.status), })); diff --git a/spec/frontend/pipelines/test_reports/stores/utils_spec.js b/spec/frontend/pipelines/test_reports/stores/utils_spec.js new file mode 100644 index 00000000000..7e632d099fc --- /dev/null +++ b/spec/frontend/pipelines/test_reports/stores/utils_spec.js @@ -0,0 +1,26 @@ +import { formattedTime } from '~/pipelines/stores/test_reports/utils'; + +describe('Test reports utils', () => { + describe('formattedTime', () => { + describe('when time is smaller than a second', () => { + it('should return time in milliseconds fixed to 2 decimals', () => { + const result = formattedTime(0.4815162342); + expect(result).toBe('481.52ms'); + }); + }); + + describe('when time is equal to a second', () => { + it('should return time in seconds fixed to 2 decimals', () => { + const result = formattedTime(1); + expect(result).toBe('1.00s'); + }); + }); + + describe('when time is greater than a second', () => { + it('should return time in seconds fixed to 2 decimals', () => { + const result = formattedTime(4.815162342); + expect(result).toBe('4.82s'); + }); + }); + }); +}); diff --git a/spec/frontend/pipelines/test_reports/test_reports_spec.js b/spec/frontend/pipelines/test_reports/test_reports_spec.js index a709edf5184..c8ab18b9086 100644 --- a/spec/frontend/pipelines/test_reports/test_reports_spec.js +++ b/spec/frontend/pipelines/test_reports/test_reports_spec.js @@ -1,4 +1,5 @@ import Vuex from 'vuex'; +import { GlLoadingIcon } from '@gitlab/ui'; import { shallowMount, createLocalVue } from '@vue/test-utils'; import { getJSONFixture } from 'helpers/fixtures'; import TestReports from '~/pipelines/components/test_reports/test_reports.vue'; @@ -15,9 +16,9 @@ describe('Test reports app', () => { const testReports = getJSONFixture('pipelines/test_report.json'); - const loadingSpinner = () => wrapper.find('.js-loading-spinner'); - const testsDetail = () => wrapper.find('.js-tests-detail'); - const noTestsToShow = () => wrapper.find('.js-no-tests-to-show'); + const loadingSpinner = () => wrapper.find(GlLoadingIcon); + const testsDetail = () => wrapper.find('[data-testid="tests-detail"]'); + const noTestsToShow = () => wrapper.find('[data-testid="no-tests-to-show"]'); const testSummary = () => wrapper.find(TestSummary); const testSummaryTable = () => wrapper.find(TestSummaryTable); @@ -88,6 +89,10 @@ describe('Test reports app', () => { expect(wrapper.vm.testReports).toBeTruthy(); expect(wrapper.vm.showTests).toBeTruthy(); }); + + it('shows tests details', () => { + expect(testsDetail().exists()).toBe(true); + }); }); describe('when a suite is clicked', () => { 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 3a4aa94571e..2feb6aa5799 100644 --- a/spec/frontend/pipelines/test_reports/test_suite_table_spec.js +++ b/spec/frontend/pipelines/test_reports/test_suite_table_spec.js @@ -23,8 +23,6 @@ describe('Test reports suite table', () => { const noCasesMessage = () => wrapper.find('.js-no-test-cases'); const allCaseRows = () => wrapper.findAll('.js-case-row'); const findCaseRowAtIndex = index => wrapper.findAll('.js-case-row').at(index); - const allCaseNames = () => - wrapper.findAll('[data-testid="caseName"]').wrappers.map(el => el.attributes('text')); const findIconForRow = (row, status) => row.find(`.ci-status-icon-${status}`); const createComponent = (suite = testSuite) => { @@ -63,16 +61,6 @@ describe('Test reports suite table', () => { expect(allCaseRows().length).toBe(testCases.length); }); - it('renders the failed tests first, skipped tests next, then successful tests', () => { - const expectedCaseOrder = [ - ...testCases.filter(x => x.status === TestStatus.FAILED), - ...testCases.filter(x => x.status === TestStatus.SKIPPED), - ...testCases.filter(x => x.status === TestStatus.SUCCESS), - ].map(x => x.name); - - expect(allCaseNames()).toEqual(expectedCaseOrder); - }); - it('renders the correct icon for each status', () => { const failedTest = testCases.findIndex(x => x.status === TestStatus.FAILED); const skippedTest = testCases.findIndex(x => x.status === TestStatus.SKIPPED); diff --git a/spec/frontend/pipelines/test_reports/test_summary_spec.js b/spec/frontend/pipelines/test_reports/test_summary_spec.js index 79be6c168cf..dc5af7b160c 100644 --- a/spec/frontend/pipelines/test_reports/test_summary_spec.js +++ b/spec/frontend/pipelines/test_reports/test_summary_spec.js @@ -1,6 +1,7 @@ import { mount } from '@vue/test-utils'; import { getJSONFixture } from 'helpers/fixtures'; import Summary from '~/pipelines/components/test_reports/test_summary.vue'; +import { formattedTime } from '~/pipelines/stores/test_reports/utils'; describe('Test reports summary', () => { let wrapper; @@ -76,7 +77,7 @@ describe('Test reports summary', () => { }); it('displays the correctly formatted duration', () => { - expect(duration().text()).toBe('00:00:00'); + expect(duration().text()).toBe(formattedTime(testSuite.total_time)); }); }); |