2018-11-20 20:47:30 +05:30
|
|
|
import Vue from 'vue';
|
|
|
|
import component from '~/jobs/components/environments_block.vue';
|
|
|
|
import mountComponent from '../../helpers/vue_mount_component_helper';
|
|
|
|
|
|
|
|
describe('Environments block', () => {
|
|
|
|
const Component = Vue.extend(component);
|
|
|
|
let vm;
|
2018-12-05 23:21:45 +05:30
|
|
|
const status = {
|
2018-11-20 20:47:30 +05:30
|
|
|
group: 'success',
|
|
|
|
icon: 'status_success',
|
|
|
|
label: 'passed',
|
|
|
|
text: 'passed',
|
|
|
|
tooltip: 'passed',
|
|
|
|
};
|
2018-12-05 23:21:45 +05:30
|
|
|
|
2018-11-20 20:47:30 +05:30
|
|
|
const environment = {
|
2018-12-05 23:21:45 +05:30
|
|
|
environment_path: '/environment',
|
2018-11-20 20:47:30 +05:30
|
|
|
name: 'environment',
|
|
|
|
};
|
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
const lastDeployment = { iid: 'deployment', deployable: { build_path: 'bar' } };
|
|
|
|
|
2018-11-20 20:47:30 +05:30
|
|
|
afterEach(() => {
|
|
|
|
vm.$destroy();
|
|
|
|
});
|
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
describe('with last deployment', () => {
|
2018-11-20 20:47:30 +05:30
|
|
|
it('renders info for most recent deployment', () => {
|
|
|
|
vm = mountComponent(Component, {
|
|
|
|
deploymentStatus: {
|
2018-12-05 23:21:45 +05:30
|
|
|
status: 'last',
|
2018-11-20 20:47:30 +05:30
|
|
|
environment,
|
|
|
|
},
|
2018-12-05 23:21:45 +05:30
|
|
|
iconStatus: status,
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
expect(vm.$el.textContent.trim()).toEqual(
|
|
|
|
'This job is the most recent deployment to environment.',
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('with out of date deployment', () => {
|
|
|
|
describe('with last deployment', () => {
|
|
|
|
it('renders info for out date and most recent', () => {
|
|
|
|
vm = mountComponent(Component, {
|
|
|
|
deploymentStatus: {
|
|
|
|
status: 'out_of_date',
|
|
|
|
environment: Object.assign({}, environment, {
|
2019-12-04 20:38:33 +05:30
|
|
|
last_deployment: lastDeployment,
|
2018-11-20 20:47:30 +05:30
|
|
|
}),
|
|
|
|
},
|
2018-12-05 23:21:45 +05:30
|
|
|
iconStatus: status,
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
expect(vm.$el.textContent.trim()).toEqual(
|
2018-12-05 23:21:45 +05:30
|
|
|
'This job is an out-of-date deployment to environment. View the most recent deployment #deployment.',
|
2018-11-20 20:47:30 +05:30
|
|
|
);
|
2018-12-13 13:39:08 +05:30
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
expect(vm.$el.querySelector('.js-job-deployment-link').getAttribute('href')).toEqual('bar');
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('without last deployment', () => {
|
|
|
|
it('renders info about out of date deployment', () => {
|
|
|
|
vm = mountComponent(Component, {
|
|
|
|
deploymentStatus: {
|
|
|
|
status: 'out_of_date',
|
|
|
|
environment,
|
|
|
|
},
|
2018-12-05 23:21:45 +05:30
|
|
|
iconStatus: status,
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
expect(vm.$el.textContent.trim()).toEqual(
|
|
|
|
'This job is an out-of-date deployment to environment.',
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('with failed deployment', () => {
|
|
|
|
it('renders info about failed deployment', () => {
|
|
|
|
vm = mountComponent(Component, {
|
|
|
|
deploymentStatus: {
|
|
|
|
status: 'failed',
|
|
|
|
environment,
|
|
|
|
},
|
2018-12-05 23:21:45 +05:30
|
|
|
iconStatus: status,
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
expect(vm.$el.textContent.trim()).toEqual(
|
|
|
|
'The deployment of this job to environment did not succeed.',
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('creating deployment', () => {
|
|
|
|
describe('with last deployment', () => {
|
2018-12-05 23:21:45 +05:30
|
|
|
it('renders info about creating deployment and overriding latest deployment', () => {
|
2018-11-20 20:47:30 +05:30
|
|
|
vm = mountComponent(Component, {
|
|
|
|
deploymentStatus: {
|
|
|
|
status: 'creating',
|
|
|
|
environment: Object.assign({}, environment, {
|
2019-12-04 20:38:33 +05:30
|
|
|
last_deployment: lastDeployment,
|
2018-11-20 20:47:30 +05:30
|
|
|
}),
|
|
|
|
},
|
2018-12-05 23:21:45 +05:30
|
|
|
iconStatus: status,
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
expect(vm.$el.textContent.trim()).toEqual(
|
2018-12-05 23:21:45 +05:30
|
|
|
'This job is creating a deployment to environment and will overwrite the latest deployment.',
|
2018-11-20 20:47:30 +05:30
|
|
|
);
|
2018-12-13 13:39:08 +05:30
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
expect(vm.$el.querySelector('.js-job-deployment-link').getAttribute('href')).toEqual('bar');
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('without last deployment', () => {
|
|
|
|
it('renders info about failed deployment', () => {
|
|
|
|
vm = mountComponent(Component, {
|
|
|
|
deploymentStatus: {
|
|
|
|
status: 'creating',
|
|
|
|
environment,
|
|
|
|
},
|
2018-12-05 23:21:45 +05:30
|
|
|
iconStatus: status,
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
expect(vm.$el.textContent.trim()).toEqual(
|
|
|
|
'This job is creating a deployment to environment.',
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2018-12-05 23:21:45 +05:30
|
|
|
|
|
|
|
describe('without environment', () => {
|
|
|
|
it('does not render environment link', () => {
|
|
|
|
vm = mountComponent(Component, {
|
|
|
|
deploymentStatus: {
|
|
|
|
status: 'creating',
|
|
|
|
environment: null,
|
|
|
|
},
|
|
|
|
iconStatus: status,
|
|
|
|
});
|
2018-12-13 13:39:08 +05:30
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
expect(vm.$el.querySelector('.js-environment-link')).toBeNull();
|
|
|
|
});
|
|
|
|
});
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
2019-12-04 20:38:33 +05:30
|
|
|
|
|
|
|
describe('with a cluster', () => {
|
|
|
|
it('renders the cluster link', () => {
|
|
|
|
const cluster = {
|
|
|
|
name: 'the-cluster',
|
|
|
|
path: '/the-cluster-path',
|
|
|
|
};
|
|
|
|
vm = mountComponent(Component, {
|
|
|
|
deploymentStatus: {
|
|
|
|
status: 'last',
|
|
|
|
environment: Object.assign({}, environment, {
|
|
|
|
last_deployment: {
|
|
|
|
...lastDeployment,
|
|
|
|
cluster,
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
iconStatus: status,
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(vm.$el.textContent.trim()).toContain('Cluster the-cluster was used.');
|
|
|
|
|
|
|
|
expect(vm.$el.querySelector('.js-job-cluster-link').getAttribute('href')).toEqual(
|
|
|
|
'/the-cluster-path',
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when the cluster is missing the path', () => {
|
|
|
|
it('renders the name without a link', () => {
|
|
|
|
const cluster = {
|
|
|
|
name: 'the-cluster',
|
|
|
|
};
|
|
|
|
vm = mountComponent(Component, {
|
|
|
|
deploymentStatus: {
|
|
|
|
status: 'last',
|
|
|
|
environment: Object.assign({}, environment, {
|
|
|
|
last_deployment: {
|
|
|
|
...lastDeployment,
|
|
|
|
cluster,
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
iconStatus: status,
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(vm.$el.textContent.trim()).toContain('Cluster the-cluster was used.');
|
|
|
|
|
|
|
|
expect(vm.$el.querySelector('.js-job-cluster-link')).toBeNull();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('without a cluster', () => {
|
|
|
|
it('does not render a cluster link', () => {
|
|
|
|
vm = mountComponent(Component, {
|
|
|
|
deploymentStatus: {
|
|
|
|
status: 'last',
|
|
|
|
environment: Object.assign({}, environment, {
|
|
|
|
last_deployment: lastDeployment,
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
iconStatus: status,
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(vm.$el.querySelector('.js-job-cluster-link')).toBeNull();
|
|
|
|
});
|
|
|
|
});
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|