diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /spec/frontend/pipelines/test_reports/test_suite_table_spec.js | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'spec/frontend/pipelines/test_reports/test_suite_table_spec.js')
-rw-r--r-- | spec/frontend/pipelines/test_reports/test_suite_table_spec.js | 44 |
1 files changed, 40 insertions, 4 deletions
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 b8fd056610b..a87145cc557 100644 --- a/spec/frontend/pipelines/test_reports/test_suite_table_spec.js +++ b/spec/frontend/pipelines/test_reports/test_suite_table_spec.js @@ -1,10 +1,11 @@ -import Vuex from 'vuex'; +import { GlButton, GlFriendlyWrap, GlLink, GlPagination } from '@gitlab/ui'; import { shallowMount, createLocalVue } from '@vue/test-utils'; +import Vuex from 'vuex'; import { getJSONFixture } from 'helpers/fixtures'; -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'; +import * as getters from '~/pipelines/stores/test_reports/getters'; +import { formatFilePath } from '~/pipelines/stores/test_reports/utils'; import skippedTestCases from './mock_data'; const localVue = createLocalVue(); @@ -20,15 +21,18 @@ describe('Test reports suite table', () => { testSuite.test_cases = [...testSuite.test_cases, ...skippedTestCases]; const testCases = testSuite.test_cases; + const blobPath = '/test/blob/path'; 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 findLinkForRow = (row) => row.find(GlLink); const findIconForRow = (row, status) => row.find(`.ci-status-icon-${status}`); const createComponent = (suite = testSuite, perPage = 20) => { store = new Vuex.Store({ state: { + blobPath, testReports: { test_suites: [suite], }, @@ -64,7 +68,7 @@ describe('Test reports suite table', () => { beforeEach(() => createComponent()); it('renders the correct number of rows', () => { - expect(allCaseRows().length).toBe(testCases.length); + expect(allCaseRows()).toHaveLength(testCases.length); }); it.each([ @@ -82,9 +86,13 @@ describe('Test reports suite table', () => { it('renders the file name for the test with a copy button', () => { const { file } = testCases[0]; + const relativeFile = formatFilePath(file); + const filePath = `${blobPath}/${relativeFile}`; const row = findCaseRowAtIndex(0); + const fileLink = findLinkForRow(row); const button = row.find(GlButton); + expect(fileLink.attributes('href')).toBe(filePath); expect(row.text()).toContain(file); expect(button.exists()).toBe(true); expect(button.attributes('data-clipboard-text')).toBe(file); @@ -106,4 +114,32 @@ describe('Test reports suite table', () => { expect(wrapper.find(GlPagination).exists()).toBe(true); }); }); + + describe('when a test case classname property is null', () => { + it('still renders all test cases', () => { + createComponent({ + ...testSuite, + test_cases: testSuite.test_cases.map((testCase) => ({ + ...testCase, + classname: null, + })), + }); + + expect(allCaseRows()).toHaveLength(testCases.length); + }); + }); + + describe('when a test case name property is null', () => { + it('still renders all test cases', () => { + createComponent({ + ...testSuite, + test_cases: testSuite.test_cases.map((testCase) => ({ + ...testCase, + name: null, + })), + }); + + expect(allCaseRows()).toHaveLength(testCases.length); + }); + }); }); |