diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /spec/frontend/pipelines/test_reports/test_case_details_spec.js | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'spec/frontend/pipelines/test_reports/test_case_details_spec.js')
-rw-r--r-- | spec/frontend/pipelines/test_reports/test_case_details_spec.js | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/spec/frontend/pipelines/test_reports/test_case_details_spec.js b/spec/frontend/pipelines/test_reports/test_case_details_spec.js new file mode 100644 index 00000000000..9e66012818e --- /dev/null +++ b/spec/frontend/pipelines/test_reports/test_case_details_spec.js @@ -0,0 +1,74 @@ +import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { GlModal } from '@gitlab/ui'; +import TestCaseDetails from '~/pipelines/components/test_reports/test_case_details.vue'; +import CodeBlock from '~/vue_shared/components/code_block.vue'; + +const localVue = createLocalVue(); + +describe('Test case details', () => { + let wrapper; + const defaultTestCase = { + classname: 'spec.test_spec', + name: 'Test#something cool', + formattedTime: '10.04ms', + system_output: 'Line 42 is broken', + }; + + const findModal = () => wrapper.find(GlModal); + const findName = () => wrapper.find('[data-testid="test-case-name"]'); + const findDuration = () => wrapper.find('[data-testid="test-case-duration"]'); + const findSystemOutput = () => wrapper.find('[data-testid="test-case-trace"]'); + + const createComponent = (testCase = {}) => { + wrapper = shallowMount(TestCaseDetails, { + localVue, + propsData: { + modalId: 'my-modal', + testCase: { + ...defaultTestCase, + ...testCase, + }, + }, + stubs: { CodeBlock, GlModal }, + }); + }; + + afterEach(() => { + wrapper.destroy(); + wrapper = null; + }); + + describe('required details', () => { + beforeEach(() => { + createComponent(); + }); + + it('renders the test case classname as modal title', () => { + expect(findModal().attributes('title')).toBe(defaultTestCase.classname); + }); + + it('renders the test case name', () => { + expect(findName().text()).toBe(defaultTestCase.name); + }); + + it('renders the test case duration', () => { + expect(findDuration().text()).toBe(defaultTestCase.formattedTime); + }); + }); + + describe('when test case has system output', () => { + it('renders the test case system output', () => { + createComponent(); + + expect(findSystemOutput().text()).toContain(defaultTestCase.system_output); + }); + }); + + describe('when test case does not have system output', () => { + it('does not render the test case system output', () => { + createComponent({ system_output: null }); + + expect(findSystemOutput().exists()).toBe(false); + }); + }); +}); |