summaryrefslogtreecommitdiff
path: root/spec/frontend/vue_shared/components/deployment_instance
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-01-05 18:10:25 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-01-05 18:10:25 +0000
commitf368b4968e55b32dcedfaefe7c31f7a9463454cf (patch)
treeb3e4652bd0131adf46f4b7e07346a0dbfa32da05 /spec/frontend/vue_shared/components/deployment_instance
parent2c2b5aeac04350b0d3e13d4b52add0b520bf2ebb (diff)
downloadgitlab-ce-f368b4968e55b32dcedfaefe7c31f7a9463454cf.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/vue_shared/components/deployment_instance')
-rw-r--r--spec/frontend/vue_shared/components/deployment_instance/deployment_instance_spec.js103
-rw-r--r--spec/frontend/vue_shared/components/deployment_instance/mock_data.js144
2 files changed, 247 insertions, 0 deletions
diff --git a/spec/frontend/vue_shared/components/deployment_instance/deployment_instance_spec.js b/spec/frontend/vue_shared/components/deployment_instance/deployment_instance_spec.js
new file mode 100644
index 00000000000..b812ced72c9
--- /dev/null
+++ b/spec/frontend/vue_shared/components/deployment_instance/deployment_instance_spec.js
@@ -0,0 +1,103 @@
+import { shallowMount } from '@vue/test-utils';
+import DeployBoardInstance from '~/vue_shared/components/deployment_instance.vue';
+import { folder } from './mock_data';
+
+describe('Deploy Board Instance', () => {
+ let wrapper;
+
+ const createComponent = (props = {}) =>
+ shallowMount(DeployBoardInstance, {
+ propsData: {
+ status: 'succeeded',
+ ...props,
+ },
+ });
+
+ describe('as a non-canary deployment', () => {
+ afterEach(() => {
+ wrapper.destroy();
+ });
+
+ it('should render a div with the correct css status and tooltip data', () => {
+ wrapper = createComponent({
+ logsPath: folder.logs_path,
+ tooltipText: 'This is a pod',
+ });
+
+ expect(wrapper.classes('deployment-instance-succeeded')).toBe(true);
+ expect(wrapper.attributes('title')).toEqual('This is a pod');
+ });
+
+ it('should render a div without tooltip data', (done) => {
+ wrapper = createComponent({
+ status: 'deploying',
+ tooltipText: '',
+ });
+
+ wrapper.vm.$nextTick(() => {
+ expect(wrapper.classes('deployment-instance-deploying')).toBe(true);
+ expect(wrapper.attributes('title')).toEqual('');
+ done();
+ });
+ });
+
+ it('should have a log path computed with a pod name as a parameter', () => {
+ wrapper = createComponent({
+ logsPath: folder.logs_path,
+ podName: 'tanuki-1',
+ });
+
+ expect(wrapper.vm.computedLogPath).toEqual(
+ '/root/review-app/-/logs?environment_name=foo&pod_name=tanuki-1',
+ );
+ });
+ });
+
+ describe('as a canary deployment', () => {
+ afterEach(() => {
+ wrapper.destroy();
+ });
+
+ it('should render a div with canary class when stable prop is provided as false', (done) => {
+ wrapper = createComponent({
+ stable: false,
+ });
+
+ wrapper.vm.$nextTick(() => {
+ expect(wrapper.classes('deployment-instance-canary')).toBe(true);
+ done();
+ });
+ });
+ });
+
+ describe('as a legend item', () => {
+ afterEach(() => {
+ wrapper.destroy();
+ });
+
+ it('should not be a link without a logsPath prop', (done) => {
+ wrapper = createComponent({
+ stable: false,
+ logsPath: '',
+ });
+
+ wrapper.vm.$nextTick(() => {
+ expect(wrapper.vm.computedLogPath).toBeNull();
+ expect(wrapper.vm.isLink).toBeFalsy();
+ done();
+ });
+ });
+
+ it('should render a link without href if path is not passed', () => {
+ wrapper = createComponent();
+
+ expect(wrapper.attributes('href')).toBeUndefined();
+ });
+
+ it('should not have a tooltip', () => {
+ wrapper = createComponent();
+
+ expect(wrapper.attributes('title')).toEqual('');
+ });
+ });
+});
diff --git a/spec/frontend/vue_shared/components/deployment_instance/mock_data.js b/spec/frontend/vue_shared/components/deployment_instance/mock_data.js
new file mode 100644
index 00000000000..6618c57948c
--- /dev/null
+++ b/spec/frontend/vue_shared/components/deployment_instance/mock_data.js
@@ -0,0 +1,144 @@
+export const environmentsList = [
+ {
+ name: 'DEV',
+ size: 1,
+ id: 7,
+ state: 'available',
+ external_url: null,
+ environment_type: null,
+ last_deployment: null,
+ has_stop_action: false,
+ environment_path: '/root/review-app/environments/7',
+ stop_path: '/root/review-app/environments/7/stop',
+ created_at: '2017-01-31T10:53:46.894Z',
+ updated_at: '2017-01-31T10:53:46.894Z',
+ project_path: '/root/review-app',
+ rollout_status: {},
+ },
+ {
+ folderName: 'build',
+ size: 5,
+ id: 12,
+ name: 'build/update-README',
+ state: 'available',
+ external_url: null,
+ environment_type: 'build',
+ last_deployment: null,
+ has_stop_action: false,
+ environment_path: '/root/review-app/environments/12',
+ stop_path: '/root/review-app/environments/12/stop',
+ created_at: '2017-02-01T19:42:18.400Z',
+ updated_at: '2017-02-01T19:42:18.400Z',
+ project_path: '/root/review-app',
+ rollout_status: {},
+ },
+];
+
+export const serverData = [
+ {
+ name: 'DEV',
+ size: 1,
+ latest: {
+ id: 7,
+ name: 'DEV',
+ state: 'available',
+ external_url: null,
+ environment_type: null,
+ last_deployment: null,
+ has_stop_action: false,
+ environment_path: '/root/review-app/environments/7',
+ stop_path: '/root/review-app/environments/7/stop',
+ created_at: '2017-01-31T10:53:46.894Z',
+ updated_at: '2017-01-31T10:53:46.894Z',
+ rollout_status: {},
+ },
+ },
+ {
+ name: 'build',
+ size: 5,
+ latest: {
+ id: 12,
+ name: 'build/update-README',
+ state: 'available',
+ external_url: null,
+ environment_type: 'build',
+ last_deployment: null,
+ has_stop_action: false,
+ environment_path: '/root/review-app/environments/12',
+ stop_path: '/root/review-app/environments/12/stop',
+ created_at: '2017-02-01T19:42:18.400Z',
+ updated_at: '2017-02-01T19:42:18.400Z',
+ },
+ },
+ {
+ name: 'build',
+ size: 1,
+ latest: {
+ id: 12,
+ name: 'build/update-README',
+ state: 'available',
+ external_url: null,
+ environment_type: 'build',
+ last_deployment: null,
+ has_stop_action: false,
+ environment_path: '/root/review-app/environments/12',
+ stop_path: '/root/review-app/environments/12/stop',
+ created_at: '2017-02-01T19:42:18.400Z',
+ updated_at: '2017-02-01T19:42:18.400Z',
+ },
+ },
+];
+
+export const deployBoardMockData = {
+ instances: [
+ { status: 'finished', tooltip: 'tanuki-2334 Finished', pod_name: 'production-tanuki-1' },
+ { status: 'finished', tooltip: 'tanuki-2335 Finished', pod_name: 'production-tanuki-1' },
+ { status: 'finished', tooltip: 'tanuki-2336 Finished', pod_name: 'production-tanuki-1' },
+ { status: 'finished', tooltip: 'tanuki-2337 Finished', pod_name: 'production-tanuki-1' },
+ { status: 'finished', tooltip: 'tanuki-2338 Finished', pod_name: 'production-tanuki-1' },
+ { status: 'finished', tooltip: 'tanuki-2339 Finished', pod_name: 'production-tanuki-1' },
+ { status: 'finished', tooltip: 'tanuki-2340 Finished', pod_name: 'production-tanuki-1' },
+ { status: 'finished', tooltip: 'tanuki-2334 Finished', pod_name: 'production-tanuki-1' },
+ { status: 'finished', tooltip: 'tanuki-2335 Finished', pod_name: 'production-tanuki-1' },
+ { status: 'finished', tooltip: 'tanuki-2336 Finished', pod_name: 'production-tanuki-1' },
+ { status: 'finished', tooltip: 'tanuki-2337 Finished', pod_name: 'production-tanuki-1' },
+ { status: 'finished', tooltip: 'tanuki-2338 Finished', pod_name: 'production-tanuki-1' },
+ { status: 'finished', tooltip: 'tanuki-2339 Finished', pod_name: 'production-tanuki-1' },
+ { status: 'finished', tooltip: 'tanuki-2340 Finished', pod_name: 'production-tanuki-1' },
+ { status: 'deploying', tooltip: 'tanuki-2341 Deploying', pod_name: 'production-tanuki-1' },
+ { status: 'deploying', tooltip: 'tanuki-2342 Deploying', pod_name: 'production-tanuki-1' },
+ { status: 'deploying', tooltip: 'tanuki-2343 Deploying', pod_name: 'production-tanuki-1' },
+ { status: 'failed', tooltip: 'tanuki-2344 Failed', pod_name: 'production-tanuki-1' },
+ { status: 'ready', tooltip: 'tanuki-2345 Ready', pod_name: 'production-tanuki-1' },
+ { status: 'ready', tooltip: 'tanuki-2346 Ready', pod_name: 'production-tanuki-1' },
+ { status: 'preparing', tooltip: 'tanuki-2348 Preparing', pod_name: 'production-tanuki-1' },
+ { status: 'preparing', tooltip: 'tanuki-2349 Preparing', pod_name: 'production-tanuki-1' },
+ { status: 'preparing', tooltip: 'tanuki-2350 Preparing', pod_name: 'production-tanuki-1' },
+ { status: 'preparing', tooltip: 'tanuki-2353 Preparing', pod_name: 'production-tanuki-1' },
+ { status: 'waiting', tooltip: 'tanuki-2354 Waiting', pod_name: 'production-tanuki-1' },
+ { status: 'waiting', tooltip: 'tanuki-2355 Waiting', pod_name: 'production-tanuki-1' },
+ { status: 'waiting', tooltip: 'tanuki-2356 Waiting', pod_name: 'production-tanuki-1' },
+ ],
+ abort_url: 'url',
+ rollback_url: 'url',
+ completion: 100,
+ status: 'found',
+};
+
+export const folder = {
+ folderName: 'build',
+ size: 5,
+ id: 12,
+ name: 'build/update-README',
+ state: 'available',
+ external_url: null,
+ environment_type: 'build',
+ last_deployment: null,
+ has_stop_action: false,
+ environment_path: '/root/review-app/environments/12',
+ stop_path: '/root/review-app/environments/12/stop',
+ created_at: '2017-02-01T19:42:18.400Z',
+ updated_at: '2017-02-01T19:42:18.400Z',
+ rollout_status: {},
+ logs_path: '/root/review-app/-/logs?environment_name=foo',
+};