2020-02-24 16:09:08 -05:00
|
|
|
import pipelineTourSuccess from '~/blob/pipeline_tour_success_modal.vue';
|
|
|
|
import { shallowMount } from '@vue/test-utils';
|
|
|
|
import Cookies from 'js-cookie';
|
|
|
|
import { GlSprintf, GlModal } from '@gitlab/ui';
|
2020-04-01 11:07:45 -04:00
|
|
|
import { mockTracking, triggerEvent, unmockTracking } from 'helpers/tracking_helper';
|
2020-03-31 14:07:42 -04:00
|
|
|
import modalProps from './pipeline_tour_success_mock_data';
|
2020-02-24 16:09:08 -05:00
|
|
|
|
|
|
|
describe('PipelineTourSuccessModal', () => {
|
|
|
|
let wrapper;
|
|
|
|
let cookieSpy;
|
2020-03-31 14:07:42 -04:00
|
|
|
let trackingSpy;
|
2020-02-24 16:09:08 -05:00
|
|
|
|
|
|
|
beforeEach(() => {
|
2020-03-31 14:07:42 -04:00
|
|
|
document.body.dataset.page = 'projects:blob:show';
|
|
|
|
trackingSpy = mockTracking('_category_', undefined, jest.spyOn);
|
2020-05-07 02:09:38 -04:00
|
|
|
|
2020-02-24 16:09:08 -05:00
|
|
|
wrapper = shallowMount(pipelineTourSuccess, {
|
2020-03-31 14:07:42 -04:00
|
|
|
propsData: modalProps,
|
2020-04-01 11:07:45 -04:00
|
|
|
stubs: {
|
|
|
|
GlModal,
|
|
|
|
},
|
2020-02-24 16:09:08 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
cookieSpy = jest.spyOn(Cookies, 'remove');
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
2020-03-31 14:07:42 -04:00
|
|
|
unmockTracking();
|
2020-02-24 16:09:08 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
it('has expected structure', () => {
|
|
|
|
const modal = wrapper.find(GlModal);
|
|
|
|
const sprintf = modal.find(GlSprintf);
|
|
|
|
|
|
|
|
expect(modal.attributes('title')).toContain("That's it, well done!");
|
|
|
|
expect(sprintf.exists()).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('calls to remove cookie', () => {
|
|
|
|
wrapper.vm.disableModalFromRenderingAgain();
|
|
|
|
|
2020-03-31 14:07:42 -04:00
|
|
|
expect(cookieSpy).toHaveBeenCalledWith(modalProps.commitCookie);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('tracking', () => {
|
2020-04-01 11:07:45 -04:00
|
|
|
it('send event for basic view of modal', () => {
|
2020-03-31 14:07:42 -04:00
|
|
|
expect(trackingSpy).toHaveBeenCalledWith(undefined, undefined, {
|
|
|
|
label: 'congratulate_first_pipeline',
|
|
|
|
property: modalProps.humanAccess,
|
|
|
|
});
|
|
|
|
});
|
2020-04-01 11:07:45 -04:00
|
|
|
|
|
|
|
it('send an event when go to pipelines is clicked', () => {
|
|
|
|
trackingSpy = mockTracking('_category_', wrapper.element, jest.spyOn);
|
|
|
|
const goToBtn = wrapper.find({ ref: 'goto' });
|
|
|
|
triggerEvent(goToBtn.element);
|
|
|
|
|
|
|
|
expect(trackingSpy).toHaveBeenCalledWith('_category_', 'click_button', {
|
|
|
|
label: 'congratulate_first_pipeline',
|
|
|
|
property: modalProps.humanAccess,
|
|
|
|
value: '10',
|
|
|
|
});
|
|
|
|
});
|
2020-02-24 16:09:08 -05:00
|
|
|
});
|
|
|
|
});
|