diff options
Diffstat (limited to 'spec/frontend/ci/admin/jobs_table/components/cells')
-rw-r--r-- | spec/frontend/ci/admin/jobs_table/components/cells/project_cell_spec.js | 32 | ||||
-rw-r--r-- | spec/frontend/ci/admin/jobs_table/components/cells/runner_cell_spec.js | 64 |
2 files changed, 96 insertions, 0 deletions
diff --git a/spec/frontend/ci/admin/jobs_table/components/cells/project_cell_spec.js b/spec/frontend/ci/admin/jobs_table/components/cells/project_cell_spec.js new file mode 100644 index 00000000000..3e391e74394 --- /dev/null +++ b/spec/frontend/ci/admin/jobs_table/components/cells/project_cell_spec.js @@ -0,0 +1,32 @@ +import { GlLink } from '@gitlab/ui'; +import { shallowMount } from '@vue/test-utils'; +import ProjectCell from '~/ci/admin/jobs_table/components/cells/project_cell.vue'; +import { mockAllJobsNodes } from 'jest/ci/jobs_mock_data'; + +const mockJob = mockAllJobsNodes[0]; + +describe('Project cell', () => { + let wrapper; + + const findProjectLink = () => wrapper.findComponent(GlLink); + + const createComponent = (props = {}) => { + wrapper = shallowMount(ProjectCell, { + propsData: { + ...props, + }, + }); + }; + + describe('Project Link', () => { + beforeEach(() => { + createComponent({ job: mockJob }); + }); + + it('shows and links to the project', () => { + expect(findProjectLink().exists()).toBe(true); + expect(findProjectLink().text()).toBe(mockJob.pipeline.project.fullPath); + expect(findProjectLink().attributes('href')).toBe(mockJob.pipeline.project.webUrl); + }); + }); +}); diff --git a/spec/frontend/ci/admin/jobs_table/components/cells/runner_cell_spec.js b/spec/frontend/ci/admin/jobs_table/components/cells/runner_cell_spec.js new file mode 100644 index 00000000000..2f1dae71572 --- /dev/null +++ b/spec/frontend/ci/admin/jobs_table/components/cells/runner_cell_spec.js @@ -0,0 +1,64 @@ +import { GlLink } from '@gitlab/ui'; +import { shallowMount } from '@vue/test-utils'; +import RunnerCell from '~/ci/admin/jobs_table/components/cells/runner_cell.vue'; +import { RUNNER_EMPTY_TEXT } from '~/ci/admin/jobs_table/constants'; +import { allRunnersData } from 'jest/ci/runner/mock_data'; + +const mockRunner = allRunnersData.data.runners.nodes[0]; + +const mockJobWithRunner = { + id: 'gid://gitlab/Ci::Build/2264', + runner: mockRunner, +}; + +const mockJobWithoutRunner = { + id: 'gid://gitlab/Ci::Build/2265', +}; + +describe('Runner Cell', () => { + let wrapper; + + const findRunnerLink = () => wrapper.findComponent(GlLink); + const findEmptyRunner = () => wrapper.find('[data-testid="empty-runner-text"]'); + + const createComponent = (props = {}) => { + wrapper = shallowMount(RunnerCell, { + propsData: { + ...props, + }, + }); + }; + + describe('Runner Link', () => { + describe('Job with runner', () => { + beforeEach(() => { + createComponent({ job: mockJobWithRunner }); + }); + + it('shows and links to the runner', () => { + expect(findRunnerLink().exists()).toBe(true); + expect(findRunnerLink().text()).toBe(mockRunner.description); + expect(findRunnerLink().attributes('href')).toBe(mockRunner.adminUrl); + }); + + it('hides the empty runner text', () => { + expect(findEmptyRunner().exists()).toBe(false); + }); + }); + + describe('Job without runner', () => { + beforeEach(() => { + createComponent({ job: mockJobWithoutRunner }); + }); + + it('shows default `empty` text', () => { + expect(findEmptyRunner().exists()).toBe(true); + expect(findEmptyRunner().text()).toBe(RUNNER_EMPTY_TEXT); + }); + + it('hides the runner link', () => { + expect(findRunnerLink().exists()).toBe(false); + }); + }); + }); +}); |