2021-04-07 12:08:53 +00:00
|
|
|
import { shallowMount } from '@vue/test-utils';
|
|
|
|
import PipelinesCiTemplate from '~/pipelines/components/pipelines_list/pipelines_ci_templates.vue';
|
|
|
|
import { SUGGESTED_CI_TEMPLATES } from '~/pipelines/constants';
|
|
|
|
|
|
|
|
const addCiYmlPath = "/-/new/master?commit_message='Add%20.gitlab-ci.yml'";
|
|
|
|
|
|
|
|
describe('Pipelines CI Templates', () => {
|
|
|
|
let wrapper;
|
|
|
|
|
2021-04-09 18:09:24 +00:00
|
|
|
const GlEmoji = { template: '<img/>' };
|
|
|
|
|
2021-04-07 12:08:53 +00:00
|
|
|
const createWrapper = () => {
|
|
|
|
return shallowMount(PipelinesCiTemplate, {
|
|
|
|
provide: {
|
|
|
|
addCiYmlPath,
|
|
|
|
},
|
2021-04-09 18:09:24 +00:00
|
|
|
stubs: {
|
|
|
|
GlEmoji,
|
|
|
|
},
|
2021-04-07 12:08:53 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2021-04-09 18:09:24 +00:00
|
|
|
const findTestTemplateLinks = () => wrapper.findAll('[data-testid="test-template-link"]');
|
2021-04-07 12:08:53 +00:00
|
|
|
const findTemplateDescriptions = () => wrapper.findAll('[data-testid="template-description"]');
|
|
|
|
const findTemplateLinks = () => wrapper.findAll('[data-testid="template-link"]');
|
2021-04-09 18:09:24 +00:00
|
|
|
const findTemplateNames = () => wrapper.findAll('[data-testid="template-name"]');
|
2021-04-07 12:08:53 +00:00
|
|
|
const findTemplateLogos = () => wrapper.findAll('[data-testid="template-logo"]');
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
wrapper = null;
|
|
|
|
});
|
|
|
|
|
2021-04-09 18:09:24 +00:00
|
|
|
describe('renders test template', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
wrapper = createWrapper();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('links to the hello world template', () => {
|
|
|
|
expect(findTestTemplateLinks().at(0).attributes('href')).toBe(
|
|
|
|
addCiYmlPath.concat('&template=Hello-World'),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('renders template list', () => {
|
2021-04-07 12:08:53 +00:00
|
|
|
beforeEach(() => {
|
|
|
|
wrapper = createWrapper();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders all suggested templates', () => {
|
|
|
|
const content = wrapper.text();
|
|
|
|
|
|
|
|
const keys = Object.keys(SUGGESTED_CI_TEMPLATES);
|
|
|
|
|
|
|
|
expect(content).toContain(...keys);
|
|
|
|
});
|
|
|
|
|
2021-04-09 18:09:24 +00:00
|
|
|
it('has the correct template name', () => {
|
|
|
|
expect(findTemplateNames().at(0).text()).toBe('Android');
|
|
|
|
});
|
|
|
|
|
2021-04-07 12:08:53 +00:00
|
|
|
it('links to the correct template', () => {
|
2021-04-09 18:09:24 +00:00
|
|
|
expect(findTemplateLinks().at(0).attributes('href')).toBe(
|
2021-04-07 12:08:53 +00:00
|
|
|
addCiYmlPath.concat('&template=Android'),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('has the description of the template', () => {
|
2021-04-09 18:09:24 +00:00
|
|
|
expect(findTemplateDescriptions().at(0).text()).toBe(
|
|
|
|
'CI/CD template to test and deploy your Android project.',
|
2021-04-07 12:08:53 +00:00
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('has the right logo of the template', () => {
|
2021-04-09 18:09:24 +00:00
|
|
|
expect(findTemplateLogos().at(0).attributes('src')).toBe(
|
2021-04-07 12:08:53 +00:00
|
|
|
'/assets/illustrations/logos/android.svg',
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|