debian-mirror-gitlab/spec/frontend/jobs/components/job/jobs_container_spec.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

148 lines
3.3 KiB
JavaScript
Raw Normal View History

2021-04-17 20:07:23 +05:30
import { GlLink } from '@gitlab/ui';
import { mount } from '@vue/test-utils';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
2022-10-11 01:57:18 +05:30
import JobsContainer from '~/jobs/components/job/sidebar/jobs_container.vue';
2018-11-20 20:47:30 +05:30
2018-12-05 23:21:45 +05:30
describe('Jobs List block', () => {
2021-04-17 20:07:23 +05:30
let wrapper;
2018-11-20 20:47:30 +05:30
const retried = {
status: {
2019-12-04 20:38:33 +05:30
details_path: '/gitlab-org/gitlab-foss/pipelines/28029444',
2018-11-20 20:47:30 +05:30
group: 'success',
has_details: true,
icon: 'status_success',
label: 'passed',
text: 'passed',
tooltip: 'passed',
},
2018-12-05 23:21:45 +05:30
id: 233432756,
2018-11-20 20:47:30 +05:30
tooltip: 'build - passed',
retried: true,
};
const active = {
name: 'test',
status: {
2019-12-04 20:38:33 +05:30
details_path: '/gitlab-org/gitlab-foss/pipelines/28029444',
2018-11-20 20:47:30 +05:30
group: 'success',
has_details: true,
icon: 'status_success',
label: 'passed',
text: 'passed',
tooltip: 'passed',
},
2018-12-05 23:21:45 +05:30
id: 2322756,
2018-11-20 20:47:30 +05:30
tooltip: 'build - passed',
active: true,
};
const job = {
name: 'build',
status: {
2019-12-04 20:38:33 +05:30
details_path: '/gitlab-org/gitlab-foss/pipelines/28029444',
2018-11-20 20:47:30 +05:30
group: 'success',
has_details: true,
icon: 'status_success',
label: 'passed',
text: 'passed',
tooltip: 'passed',
},
2018-12-05 23:21:45 +05:30
id: 232153,
2018-11-20 20:47:30 +05:30
tooltip: 'build - passed',
};
2021-04-17 20:07:23 +05:30
const findAllJobs = () => wrapper.findAllComponents(GlLink);
const findJob = () => findAllJobs().at(0);
const findArrowIcon = () => wrapper.findByTestId('arrow-right-icon');
const findRetryIcon = () => wrapper.findByTestId('retry-icon');
const createComponent = (props) => {
wrapper = extendedWrapper(
mount(JobsContainer, {
propsData: {
...props,
},
}),
);
};
2018-11-20 20:47:30 +05:30
afterEach(() => {
2021-04-17 20:07:23 +05:30
wrapper.destroy();
2018-11-20 20:47:30 +05:30
});
2021-04-17 20:07:23 +05:30
it('renders a list of jobs', () => {
createComponent({
2018-11-20 20:47:30 +05:30
jobs: [job, retried, active],
2018-12-05 23:21:45 +05:30
jobId: 12313,
2018-11-20 20:47:30 +05:30
});
2021-04-17 20:07:23 +05:30
expect(findAllJobs()).toHaveLength(3);
2018-11-20 20:47:30 +05:30
});
2021-04-17 20:07:23 +05:30
it('renders the arrow right icon when job id matches `jobId`', () => {
createComponent({
2018-11-20 20:47:30 +05:30
jobs: [active],
2018-12-05 23:21:45 +05:30
jobId: active.id,
2018-11-20 20:47:30 +05:30
});
2021-04-17 20:07:23 +05:30
expect(findArrowIcon().exists()).toBe(true);
2018-11-20 20:47:30 +05:30
});
2021-04-17 20:07:23 +05:30
it('does not render the arrow right icon when the job is not active', () => {
createComponent({
2018-11-20 20:47:30 +05:30
jobs: [job],
2018-12-05 23:21:45 +05:30
jobId: active.id,
2018-11-20 20:47:30 +05:30
});
2021-04-17 20:07:23 +05:30
expect(findArrowIcon().exists()).toBe(false);
2018-11-20 20:47:30 +05:30
});
2021-04-17 20:07:23 +05:30
it('renders the job name when present', () => {
createComponent({
2018-11-20 20:47:30 +05:30
jobs: [job],
2018-12-05 23:21:45 +05:30
jobId: active.id,
2018-11-20 20:47:30 +05:30
});
2021-04-17 20:07:23 +05:30
expect(findJob().text()).toBe(job.name);
2022-08-13 15:12:31 +05:30
expect(findJob().text()).not.toContain(job.id.toString());
2018-11-20 20:47:30 +05:30
});
it('renders job id when job name is not available', () => {
2021-04-17 20:07:23 +05:30
createComponent({
2018-11-20 20:47:30 +05:30
jobs: [retried],
2018-12-05 23:21:45 +05:30
jobId: active.id,
2018-11-20 20:47:30 +05:30
});
2021-04-17 20:07:23 +05:30
expect(findJob().text()).toBe(retried.id.toString());
2018-11-20 20:47:30 +05:30
});
it('links to the job page', () => {
2021-04-17 20:07:23 +05:30
createComponent({
2018-11-20 20:47:30 +05:30
jobs: [job],
2018-12-05 23:21:45 +05:30
jobId: active.id,
2018-11-20 20:47:30 +05:30
});
2021-04-17 20:07:23 +05:30
expect(findJob().attributes('href')).toBe(job.status.details_path);
2018-11-20 20:47:30 +05:30
});
it('renders retry icon when job was retried', () => {
2021-04-17 20:07:23 +05:30
createComponent({
2018-11-20 20:47:30 +05:30
jobs: [retried],
2018-12-05 23:21:45 +05:30
jobId: active.id,
2018-11-20 20:47:30 +05:30
});
2021-04-17 20:07:23 +05:30
expect(findRetryIcon().exists()).toBe(true);
2018-11-20 20:47:30 +05:30
});
it('does not render retry icon when job was not retried', () => {
2021-04-17 20:07:23 +05:30
createComponent({
2018-11-20 20:47:30 +05:30
jobs: [job],
2018-12-05 23:21:45 +05:30
jobId: active.id,
2018-11-20 20:47:30 +05:30
});
2021-04-17 20:07:23 +05:30
expect(findRetryIcon().exists()).toBe(false);
2018-11-20 20:47:30 +05:30
});
});