debian-mirror-gitlab/spec/frontend/pipelines/graph/job_group_dropdown_spec.js

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

89 lines
2.2 KiB
JavaScript
Raw Normal View History

2021-04-29 21:17:54 +05:30
import { shallowMount, mount } from '@vue/test-utils';
2020-01-01 13:55:28 +05:30
import JobGroupDropdown from '~/pipelines/components/graph/job_group_dropdown.vue';
2018-10-15 14:42:47 +05:30
2018-12-13 13:39:08 +05:30
describe('job group dropdown component', () => {
const group = {
2018-10-15 14:42:47 +05:30
jobs: [
{
id: 4256,
name: '<img src=x onerror=alert(document.domain)>',
status: {
2018-11-18 11:00:15 +05:30
icon: 'status_success',
2018-10-15 14:42:47 +05:30
text: 'passed',
label: 'passed',
tooltip: 'passed',
group: 'success',
details_path: '/root/ci-mock/builds/4256',
has_details: true,
action: {
icon: 'retry',
title: 'Retry',
path: '/root/ci-mock/builds/4256/retry',
method: 'post',
},
},
},
{
id: 4299,
name: 'test',
status: {
2018-11-18 11:00:15 +05:30
icon: 'status_success',
2018-10-15 14:42:47 +05:30
text: 'passed',
label: 'passed',
tooltip: 'passed',
group: 'success',
details_path: '/root/ci-mock/builds/4299',
has_details: true,
action: {
icon: 'retry',
title: 'Retry',
path: '/root/ci-mock/builds/4299/retry',
method: 'post',
},
},
},
],
name: 'rspec:linux',
size: 2,
status: {
2018-11-18 11:00:15 +05:30
icon: 'status_success',
2018-10-15 14:42:47 +05:30
text: 'passed',
label: 'passed',
tooltip: 'passed',
group: 'success',
details_path: '/root/ci-mock/builds/4256',
has_details: true,
action: {
icon: 'retry',
title: 'Retry',
path: '/root/ci-mock/builds/4256/retry',
method: 'post',
},
},
};
2020-04-22 19:07:51 +05:30
let wrapper;
const findButton = () => wrapper.find('button');
2021-04-29 21:17:54 +05:30
const createComponent = ({ mountFn = shallowMount }) => {
wrapper = mountFn(JobGroupDropdown, { propsData: { group } });
};
2018-10-15 14:42:47 +05:30
afterEach(() => {
2020-04-22 19:07:51 +05:30
wrapper.destroy();
2018-10-15 14:42:47 +05:30
});
beforeEach(() => {
2021-04-29 21:17:54 +05:30
createComponent({ mountFn: mount });
2018-10-15 14:42:47 +05:30
});
2018-12-13 13:39:08 +05:30
it('renders button with group name and size', () => {
2020-04-22 19:07:51 +05:30
expect(findButton().text()).toContain(group.name);
2022-08-13 15:12:31 +05:30
expect(findButton().text()).toContain(group.size.toString());
2018-10-15 14:42:47 +05:30
});
it('renders dropdown with jobs', () => {
2020-04-22 19:07:51 +05:30
expect(wrapper.findAll('.scrollable-menu>ul>li').length).toBe(group.jobs.length);
2018-10-15 14:42:47 +05:30
});
});