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';
|
|
|
|
import JobsContainer from '~/jobs/components/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);
|
|
|
|
expect(findJob().text()).not.toContain(job.id);
|
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
|
|
|
});
|
|
|
|
});
|