2020-06-23 00:09:42 +05:30
|
|
|
import { GlBreadcrumb } from '@gitlab/ui';
|
2021-03-11 19:13:27 +05:30
|
|
|
import { shallowMount } from '@vue/test-utils';
|
2020-06-23 00:09:42 +05:30
|
|
|
import App from '~/projects/experiment_new_project_creation/components/app.vue';
|
|
|
|
import LegacyContainer from '~/projects/experiment_new_project_creation/components/legacy_container.vue';
|
2021-03-11 19:13:27 +05:30
|
|
|
import WelcomePage from '~/projects/experiment_new_project_creation/components/welcome.vue';
|
2020-06-23 00:09:42 +05:30
|
|
|
|
|
|
|
describe('Experimental new project creation app', () => {
|
|
|
|
let wrapper;
|
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
const createComponent = (propsData) => {
|
2020-06-23 00:09:42 +05:30
|
|
|
wrapper = shallowMount(App, { propsData });
|
|
|
|
};
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
window.location.hash = '';
|
|
|
|
wrapper = null;
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('with empty hash', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
createComponent();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders welcome page', () => {
|
|
|
|
expect(wrapper.find(WelcomePage).exists()).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('does not render breadcrumbs', () => {
|
|
|
|
expect(wrapper.find(GlBreadcrumb).exists()).toBe(false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders blank project container if there are errors', () => {
|
|
|
|
createComponent({ hasErrors: true });
|
|
|
|
expect(wrapper.find(WelcomePage).exists()).toBe(false);
|
|
|
|
expect(wrapper.find(LegacyContainer).exists()).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when hash is not empty on load', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
window.location.hash = '#blank_project';
|
|
|
|
createComponent();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders relevant container', () => {
|
|
|
|
expect(wrapper.find(WelcomePage).exists()).toBe(false);
|
|
|
|
expect(wrapper.find(LegacyContainer).exists()).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders breadcrumbs', () => {
|
|
|
|
expect(wrapper.find(GlBreadcrumb).exists()).toBe(true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
describe('display custom new project guideline text', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
window.location.hash = '#blank_project';
|
|
|
|
});
|
|
|
|
|
|
|
|
it('does not render new project guideline if undefined', () => {
|
|
|
|
createComponent();
|
|
|
|
expect(wrapper.find('div#new-project-guideline').exists()).toBe(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('render new project guideline if defined', () => {
|
|
|
|
const guidelineSelector = 'div#new-project-guideline';
|
|
|
|
|
|
|
|
createComponent({
|
|
|
|
newProjectGuidelines: '<h4>Internal Guidelines</h4><p>lorem ipsum</p>',
|
|
|
|
});
|
|
|
|
expect(wrapper.find(guidelineSelector).exists()).toBe(true);
|
|
|
|
expect(wrapper.find(guidelineSelector).html()).toContain('<h4>Internal Guidelines</h4>');
|
|
|
|
expect(wrapper.find(guidelineSelector).html()).toContain('<p>lorem ipsum</p>');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
it('renders relevant container when hash changes', () => {
|
|
|
|
createComponent();
|
|
|
|
expect(wrapper.find(WelcomePage).exists()).toBe(true);
|
|
|
|
|
|
|
|
window.location.hash = '#blank_project';
|
|
|
|
const ev = document.createEvent('HTMLEvents');
|
|
|
|
ev.initEvent('hashchange', false, false);
|
|
|
|
window.dispatchEvent(ev);
|
|
|
|
|
|
|
|
return wrapper.vm.$nextTick().then(() => {
|
|
|
|
expect(wrapper.find(WelcomePage).exists()).toBe(false);
|
|
|
|
expect(wrapper.find(LegacyContainer).exists()).toBe(true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|