2023-04-23 21:23:45 +05:30
|
|
|
import MockAdapter from 'axios-mock-adapter';
|
2023-05-27 22:25:52 +05:30
|
|
|
import { shallowMount, mount } from '@vue/test-utils';
|
|
|
|
import Vue, { nextTick } from 'vue';
|
|
|
|
import { GlBadge, GlModal, GlToast } from '@gitlab/ui';
|
2018-12-13 13:39:08 +05:30
|
|
|
import JobItem from '~/pipelines/components/graph/job_item.vue';
|
2023-04-23 21:23:45 +05:30
|
|
|
import axios from '~/lib/utils/axios_utils';
|
|
|
|
import { useLocalStorageSpy } from 'helpers/local_storage_helper';
|
2023-05-27 22:25:52 +05:30
|
|
|
import ActionComponent from '~/pipelines/components/jobs_shared/action_component.vue';
|
2023-04-23 21:23:45 +05:30
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
|
|
|
|
import {
|
|
|
|
delayedJob,
|
|
|
|
mockJob,
|
|
|
|
mockJobWithoutDetails,
|
|
|
|
mockJobWithUnauthorizedAction,
|
2023-04-23 21:23:45 +05:30
|
|
|
mockFailedJob,
|
2022-07-16 23:28:13 +05:30
|
|
|
triggerJob,
|
2023-04-23 21:23:45 +05:30
|
|
|
triggerJobWithRetryAction,
|
2022-07-16 23:28:13 +05:30
|
|
|
} from './mock_data';
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
describe('pipeline graph job item', () => {
|
2023-04-23 21:23:45 +05:30
|
|
|
useLocalStorageSpy();
|
2023-05-27 22:25:52 +05:30
|
|
|
Vue.use(GlToast);
|
2023-04-23 21:23:45 +05:30
|
|
|
|
2020-01-01 13:55:28 +05:30
|
|
|
let wrapper;
|
2023-04-23 21:23:45 +05:30
|
|
|
let mockAxios;
|
2020-01-01 13:55:28 +05:30
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
const findJobWithoutLink = () => wrapper.findByTestId('job-without-link');
|
|
|
|
const findJobWithLink = () => wrapper.findByTestId('job-with-link');
|
2023-05-27 22:25:52 +05:30
|
|
|
const findActionVueComponent = () => wrapper.findComponent(ActionComponent);
|
2022-07-16 23:28:13 +05:30
|
|
|
const findActionComponent = () => wrapper.findByTestId('ci-action-component');
|
|
|
|
const findBadge = () => wrapper.findComponent(GlBadge);
|
2023-04-23 21:23:45 +05:30
|
|
|
const findJobLink = () => wrapper.findByTestId('job-with-link');
|
|
|
|
const findModal = () => wrapper.findComponent(GlModal);
|
|
|
|
|
|
|
|
const clickOnModalPrimaryBtn = () => findModal().vm.$emit('primary');
|
|
|
|
const clickOnModalCancelBtn = () => findModal().vm.$emit('hide');
|
|
|
|
const clickOnModalCloseBtn = () => findModal().vm.$emit('close');
|
|
|
|
|
|
|
|
const myCustomClass1 = 'my-class-1';
|
|
|
|
const myCustomClass2 = 'my-class-2';
|
2020-07-28 23:09:34 +05:30
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
const defaultProps = {
|
|
|
|
job: mockJob,
|
|
|
|
};
|
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
const createWrapper = ({ props, data, mountFn = mount, mocks = {} } = {}) => {
|
2022-07-16 23:28:13 +05:30
|
|
|
wrapper = extendedWrapper(
|
2023-05-27 22:25:52 +05:30
|
|
|
mountFn(JobItem, {
|
2023-04-23 21:23:45 +05:30
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
...data,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
propsData: {
|
|
|
|
...defaultProps,
|
|
|
|
...props,
|
|
|
|
},
|
2023-05-27 22:25:52 +05:30
|
|
|
mocks: {
|
|
|
|
...mocks,
|
|
|
|
},
|
2022-07-16 23:28:13 +05:30
|
|
|
}),
|
|
|
|
);
|
2020-01-01 13:55:28 +05:30
|
|
|
};
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
const triggerActiveClass = 'gl-shadow-x0-y0-b3-s1-blue-500';
|
2021-11-11 11:23:49 +05:30
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
beforeEach(() => {
|
|
|
|
mockAxios = new MockAdapter(axios);
|
|
|
|
});
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
afterEach(() => {
|
2023-04-23 21:23:45 +05:30
|
|
|
mockAxios.restore();
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
describe('name with link', () => {
|
2022-04-04 11:22:00 +05:30
|
|
|
it('should render the job name and status with a link', async () => {
|
2023-04-23 21:23:45 +05:30
|
|
|
createWrapper();
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2022-04-04 11:22:00 +05:30
|
|
|
await nextTick();
|
2023-04-23 21:23:45 +05:30
|
|
|
const link = findJobLink();
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2022-04-04 11:22:00 +05:30
|
|
|
expect(link.attributes('href')).toBe(mockJob.status.detailsPath);
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2022-04-04 11:22:00 +05:30
|
|
|
expect(link.attributes('title')).toBe(`${mockJob.name} - ${mockJob.status.label}`);
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2022-04-04 11:22:00 +05:30
|
|
|
expect(wrapper.find('.ci-status-icon-success').exists()).toBe(true);
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2022-04-04 11:22:00 +05:30
|
|
|
expect(wrapper.text()).toBe(mockJob.name);
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('name without link', () => {
|
2020-07-28 23:09:34 +05:30
|
|
|
beforeEach(() => {
|
2020-01-01 13:55:28 +05:30
|
|
|
createWrapper({
|
2023-04-23 21:23:45 +05:30
|
|
|
props: {
|
|
|
|
job: mockJobWithoutDetails,
|
|
|
|
cssClassJobName: 'css-class-job-name',
|
|
|
|
jobHovered: 'test',
|
|
|
|
},
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
2020-07-28 23:09:34 +05:30
|
|
|
});
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2022-10-11 01:57:18 +05:30
|
|
|
it('should render status and name', () => {
|
2020-04-22 19:07:51 +05:30
|
|
|
expect(wrapper.find('.ci-status-icon-success').exists()).toBe(true);
|
2023-04-23 21:23:45 +05:30
|
|
|
expect(findJobLink().exists()).toBe(false);
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
expect(wrapper.text()).toBe(mockJobWithoutDetails.name);
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
2020-07-28 23:09:34 +05:30
|
|
|
|
|
|
|
it('should apply hover class and provided class name', () => {
|
|
|
|
expect(findJobWithoutLink().classes()).toContain('css-class-job-name');
|
|
|
|
});
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
describe('action icon', () => {
|
2022-10-11 01:57:18 +05:30
|
|
|
it('should render the action icon', () => {
|
2023-04-23 21:23:45 +05:30
|
|
|
createWrapper();
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2022-04-04 11:22:00 +05:30
|
|
|
const actionComponent = findActionComponent();
|
|
|
|
|
|
|
|
expect(actionComponent.exists()).toBe(true);
|
|
|
|
expect(actionComponent.props('actionIcon')).toBe('retry');
|
2023-07-09 08:55:56 +05:30
|
|
|
expect(actionComponent.attributes('disabled')).toBeUndefined();
|
2022-04-04 11:22:00 +05:30
|
|
|
});
|
|
|
|
|
2022-10-11 01:57:18 +05:30
|
|
|
it('should render disabled action icon when user cannot run the action', () => {
|
2023-04-23 21:23:45 +05:30
|
|
|
createWrapper({
|
|
|
|
props: {
|
|
|
|
job: mockJobWithUnauthorizedAction,
|
|
|
|
},
|
|
|
|
});
|
2022-04-04 11:22:00 +05:30
|
|
|
|
|
|
|
const actionComponent = findActionComponent();
|
|
|
|
|
|
|
|
expect(actionComponent.exists()).toBe(true);
|
|
|
|
expect(actionComponent.props('actionIcon')).toBe('stop');
|
2023-07-09 08:55:56 +05:30
|
|
|
expect(actionComponent.attributes('disabled')).toBeDefined();
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
2023-04-23 21:23:45 +05:30
|
|
|
|
|
|
|
it('action icon tooltip text when job has passed but can be ran again', () => {
|
|
|
|
createWrapper({ props: { job: mockJob } });
|
|
|
|
|
|
|
|
expect(findActionComponent().props('tooltipText')).toBe('Run again');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('action icon tooltip text when job has failed and can be retried', () => {
|
|
|
|
createWrapper({ props: { job: mockFailedJob } });
|
|
|
|
|
|
|
|
expect(findActionComponent().props('tooltipText')).toBe('Retry');
|
|
|
|
});
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
describe('job style', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
createWrapper({
|
2023-04-23 21:23:45 +05:30
|
|
|
props: {
|
|
|
|
job: mockJob,
|
|
|
|
cssClassJobName: 'css-class-job-name',
|
|
|
|
},
|
2022-07-16 23:28:13 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render provided class name', () => {
|
2023-04-23 21:23:45 +05:30
|
|
|
expect(findJobLink().classes()).toContain('css-class-job-name');
|
2022-07-16 23:28:13 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('does not show a badge on the job item', () => {
|
|
|
|
expect(findBadge().exists()).toBe(false);
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
it('does not apply the trigger job class', () => {
|
|
|
|
expect(findJobWithLink().classes()).not.toContain('gl-rounded-lg');
|
|
|
|
});
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
describe('status label', () => {
|
|
|
|
it('should not render status label when it is not provided', () => {
|
2020-01-01 13:55:28 +05:30
|
|
|
createWrapper({
|
2023-04-23 21:23:45 +05:30
|
|
|
props: {
|
|
|
|
job: {
|
|
|
|
id: 4258,
|
|
|
|
name: 'test',
|
|
|
|
status: {
|
|
|
|
icon: 'status_success',
|
|
|
|
},
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
expect(findJobWithoutLink().attributes('title')).toBe('test');
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('should not render status label when it is provided', () => {
|
2020-01-01 13:55:28 +05:30
|
|
|
createWrapper({
|
2023-04-23 21:23:45 +05:30
|
|
|
props: {
|
|
|
|
job: {
|
|
|
|
id: 4259,
|
|
|
|
name: 'test',
|
|
|
|
status: {
|
|
|
|
icon: 'status_success',
|
|
|
|
label: 'success',
|
|
|
|
tooltip: 'success',
|
|
|
|
},
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
expect(findJobWithoutLink().attributes('title')).toBe('test - success');
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
});
|
2018-10-15 14:42:47 +05:30
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
describe('for delayed job', () => {
|
2019-02-15 15:39:39 +05:30
|
|
|
it('displays remaining time in tooltip', () => {
|
2020-01-01 13:55:28 +05:30
|
|
|
createWrapper({
|
2023-04-23 21:23:45 +05:30
|
|
|
props: {
|
|
|
|
job: delayedJob,
|
|
|
|
},
|
2018-12-13 13:39:08 +05:30
|
|
|
});
|
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
expect(findJobWithLink().attributes('title')).toBe(
|
2020-01-01 13:55:28 +05:30
|
|
|
`delayed job - delayed manual action (${wrapper.vm.remainingTime})`,
|
|
|
|
);
|
2018-12-13 13:39:08 +05:30
|
|
|
});
|
|
|
|
});
|
2020-11-24 15:15:51 +05:30
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
describe('trigger job', () => {
|
|
|
|
describe('card', () => {
|
|
|
|
beforeEach(() => {
|
2023-04-23 21:23:45 +05:30
|
|
|
createWrapper({
|
|
|
|
props: {
|
|
|
|
job: triggerJob,
|
|
|
|
},
|
|
|
|
});
|
2022-07-16 23:28:13 +05:30
|
|
|
});
|
2020-11-24 15:15:51 +05:30
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
it('shows a badge on the job item', () => {
|
|
|
|
expect(findBadge().exists()).toBe(true);
|
|
|
|
expect(findBadge().text()).toBe('Trigger job');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('applies a rounded corner style instead of the usual pill shape', () => {
|
|
|
|
expect(findJobWithoutLink().classes()).toContain('gl-rounded-lg');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
describe('when retrying', () => {
|
|
|
|
const mockToastShow = jest.fn();
|
|
|
|
|
|
|
|
beforeEach(async () => {
|
|
|
|
createWrapper({
|
|
|
|
mountFn: shallowMount,
|
|
|
|
data: {
|
|
|
|
currentSkipModalValue: true,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
skipRetryModal: true,
|
|
|
|
job: triggerJobWithRetryAction,
|
|
|
|
},
|
|
|
|
mocks: {
|
|
|
|
$toast: {
|
|
|
|
show: mockToastShow,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
jest.spyOn(wrapper.vm.$toast, 'show');
|
|
|
|
|
|
|
|
await findActionVueComponent().vm.$emit('pipelineActionRequestComplete');
|
|
|
|
await nextTick();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('shows a toast message that the downstream is being created', () => {
|
|
|
|
expect(mockToastShow).toHaveBeenCalledTimes(1);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
describe('highlighting', () => {
|
|
|
|
it.each`
|
|
|
|
job | jobName | expanded | link
|
|
|
|
${mockJob} | ${mockJob.name} | ${true} | ${true}
|
|
|
|
${mockJobWithoutDetails} | ${mockJobWithoutDetails.name} | ${true} | ${false}
|
|
|
|
`(
|
|
|
|
`trigger job should stay highlighted when downstream is expanded`,
|
|
|
|
({ job, jobName, expanded, link }) => {
|
2023-04-23 21:23:45 +05:30
|
|
|
createWrapper({
|
|
|
|
props: {
|
|
|
|
job,
|
|
|
|
pipelineExpanded: { jobName, expanded },
|
|
|
|
},
|
|
|
|
});
|
2022-07-16 23:28:13 +05:30
|
|
|
const findJobEl = link ? findJobWithLink : findJobWithoutLink;
|
|
|
|
|
|
|
|
expect(findJobEl().classes()).toContain(triggerActiveClass);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
|
|
|
it.each`
|
|
|
|
job | jobName | expanded | link
|
|
|
|
${mockJob} | ${mockJob.name} | ${false} | ${true}
|
|
|
|
${mockJobWithoutDetails} | ${mockJobWithoutDetails.name} | ${false} | ${false}
|
|
|
|
`(
|
|
|
|
`trigger job should not be highlighted when downstream is not expanded`,
|
|
|
|
({ job, jobName, expanded, link }) => {
|
2023-04-23 21:23:45 +05:30
|
|
|
createWrapper({
|
|
|
|
props: {
|
|
|
|
job,
|
|
|
|
pipelineExpanded: { jobName, expanded },
|
|
|
|
},
|
|
|
|
});
|
2022-07-16 23:28:13 +05:30
|
|
|
const findJobEl = link ? findJobWithLink : findJobWithoutLink;
|
|
|
|
|
|
|
|
expect(findJobEl().classes()).not.toContain(triggerActiveClass);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
});
|
2020-11-24 15:15:51 +05:30
|
|
|
});
|
2021-11-18 22:05:49 +05:30
|
|
|
|
|
|
|
describe('job classes', () => {
|
|
|
|
it('job class is shown', () => {
|
|
|
|
createWrapper({
|
2023-04-23 21:23:45 +05:30
|
|
|
props: {
|
|
|
|
job: mockJob,
|
|
|
|
cssClassJobName: 'my-class',
|
|
|
|
},
|
2021-11-18 22:05:49 +05:30
|
|
|
});
|
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
const jobLinkEl = findJobLink();
|
2021-11-18 22:05:49 +05:30
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
expect(jobLinkEl.classes()).toContain('my-class');
|
|
|
|
|
|
|
|
expect(jobLinkEl.classes()).not.toContain(triggerActiveClass);
|
2021-11-18 22:05:49 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('job class is shown, along with hover', () => {
|
|
|
|
createWrapper({
|
2023-04-23 21:23:45 +05:30
|
|
|
props: {
|
|
|
|
job: mockJob,
|
|
|
|
cssClassJobName: 'my-class',
|
|
|
|
sourceJobHovered: mockJob.name,
|
|
|
|
},
|
2021-11-18 22:05:49 +05:30
|
|
|
});
|
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
const jobLinkEl = findJobLink();
|
|
|
|
|
|
|
|
expect(jobLinkEl.classes()).toContain('my-class');
|
|
|
|
expect(jobLinkEl.classes()).toContain(triggerActiveClass);
|
2021-11-18 22:05:49 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('multiple job classes are shown', () => {
|
|
|
|
createWrapper({
|
2023-04-23 21:23:45 +05:30
|
|
|
props: {
|
|
|
|
job: mockJob,
|
|
|
|
cssClassJobName: [myCustomClass1, myCustomClass2],
|
|
|
|
},
|
2021-11-18 22:05:49 +05:30
|
|
|
});
|
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
const jobLinkEl = findJobLink();
|
|
|
|
|
|
|
|
expect(jobLinkEl.classes()).toContain(myCustomClass1);
|
|
|
|
expect(jobLinkEl.classes()).toContain(myCustomClass2);
|
2021-11-18 22:05:49 +05:30
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
expect(jobLinkEl.classes()).not.toContain(triggerActiveClass);
|
2021-11-18 22:05:49 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('multiple job classes are shown conditionally', () => {
|
|
|
|
createWrapper({
|
2023-04-23 21:23:45 +05:30
|
|
|
props: {
|
|
|
|
job: mockJob,
|
|
|
|
cssClassJobName: { [myCustomClass1]: true, [myCustomClass2]: true },
|
|
|
|
},
|
2021-11-18 22:05:49 +05:30
|
|
|
});
|
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
const jobLinkEl = findJobLink();
|
|
|
|
|
|
|
|
expect(jobLinkEl.classes()).toContain(myCustomClass1);
|
|
|
|
expect(jobLinkEl.classes()).toContain(myCustomClass2);
|
2021-11-18 22:05:49 +05:30
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
expect(jobLinkEl.classes()).not.toContain(triggerActiveClass);
|
2021-11-18 22:05:49 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('multiple job classes are shown, along with a hover', () => {
|
|
|
|
createWrapper({
|
2023-04-23 21:23:45 +05:30
|
|
|
props: {
|
|
|
|
job: mockJob,
|
|
|
|
cssClassJobName: [myCustomClass1, myCustomClass2],
|
|
|
|
sourceJobHovered: mockJob.name,
|
|
|
|
},
|
2021-11-18 22:05:49 +05:30
|
|
|
});
|
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
const jobLinkEl = findJobLink();
|
|
|
|
|
|
|
|
expect(jobLinkEl.classes()).toContain(myCustomClass1);
|
|
|
|
expect(jobLinkEl.classes()).toContain(myCustomClass2);
|
|
|
|
expect(jobLinkEl.classes()).toContain(triggerActiveClass);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('confirmation modal', () => {
|
|
|
|
describe('when clicking on the action component', () => {
|
|
|
|
it.each`
|
|
|
|
skipRetryModal | exists | visibilityText
|
|
|
|
${false} | ${true} | ${'shows'}
|
|
|
|
${true} | ${false} | ${'hides'}
|
|
|
|
`(
|
|
|
|
'$visibilityText the modal when `skipRetryModal` is $skipRetryModal',
|
|
|
|
async ({ exists, skipRetryModal }) => {
|
|
|
|
createWrapper({
|
|
|
|
props: {
|
|
|
|
skipRetryModal,
|
|
|
|
job: triggerJobWithRetryAction,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
await findActionComponent().trigger('click');
|
|
|
|
|
|
|
|
expect(findModal().exists()).toBe(exists);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when showing the modal', () => {
|
|
|
|
it.each`
|
|
|
|
buttonName | shouldTriggerActionClick | actionBtn
|
|
|
|
${'primary'} | ${true} | ${clickOnModalPrimaryBtn}
|
|
|
|
${'cancel'} | ${false} | ${clickOnModalCancelBtn}
|
|
|
|
${'close'} | ${false} | ${clickOnModalCloseBtn}
|
|
|
|
`(
|
|
|
|
'clicking on $buttonName will pass down shouldTriggerActionClick as $shouldTriggerActionClick to the action component',
|
|
|
|
async ({ shouldTriggerActionClick, actionBtn }) => {
|
|
|
|
createWrapper({
|
|
|
|
props: {
|
|
|
|
skipRetryModal: false,
|
|
|
|
job: triggerJobWithRetryAction,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
await findActionComponent().trigger('click');
|
|
|
|
|
|
|
|
await actionBtn();
|
|
|
|
|
|
|
|
expect(findActionComponent().props().shouldTriggerClick).toBe(shouldTriggerActionClick);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when not checking the "do not show this again" checkbox', () => {
|
|
|
|
it.each`
|
|
|
|
actionName | actionBtn
|
|
|
|
${'closing'} | ${clickOnModalCloseBtn}
|
|
|
|
${'cancelling'} | ${clickOnModalCancelBtn}
|
|
|
|
${'confirming'} | ${clickOnModalPrimaryBtn}
|
|
|
|
`(
|
|
|
|
'does not emit any event and will not modify localstorage on $actionName',
|
|
|
|
async ({ actionBtn }) => {
|
|
|
|
createWrapper({
|
|
|
|
props: {
|
|
|
|
skipRetryModal: false,
|
|
|
|
job: triggerJobWithRetryAction,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
await findActionComponent().trigger('click');
|
|
|
|
await actionBtn();
|
|
|
|
|
|
|
|
expect(wrapper.emitted().setSkipRetryModal).toBeUndefined();
|
|
|
|
expect(localStorage.setItem).not.toHaveBeenCalled();
|
|
|
|
},
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when checking the "do not show this again" checkbox', () => {
|
|
|
|
it.each`
|
|
|
|
actionName | actionBtn
|
|
|
|
${'closing'} | ${clickOnModalCloseBtn}
|
|
|
|
${'cancelling'} | ${clickOnModalCancelBtn}
|
|
|
|
${'confirming'} | ${clickOnModalPrimaryBtn}
|
|
|
|
`(
|
|
|
|
'emits "setSkipRetryModal" and set local storage key on $actionName the modal',
|
|
|
|
async ({ actionBtn }) => {
|
|
|
|
// We are passing the checkbox as a slot to the GlModal.
|
|
|
|
// The way GlModal is mounted, we can neither click on the box
|
|
|
|
// or emit an event directly. We therefore set the data property
|
|
|
|
// as it would be if the box was checked.
|
|
|
|
createWrapper({
|
|
|
|
data: {
|
|
|
|
currentSkipModalValue: true,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
skipRetryModal: false,
|
|
|
|
job: triggerJobWithRetryAction,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
await findActionComponent().trigger('click');
|
|
|
|
await actionBtn();
|
|
|
|
|
|
|
|
expect(wrapper.emitted().setSkipRetryModal).toHaveLength(1);
|
|
|
|
expect(localStorage.setItem).toHaveBeenCalledWith('skip_retry_modal', 'true');
|
|
|
|
},
|
|
|
|
);
|
2021-11-18 22:05:49 +05:30
|
|
|
});
|
|
|
|
});
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|