summaryrefslogtreecommitdiff
path: root/spec/javascripts/vue_mr_widget
diff options
context:
space:
mode:
authorFilipa Lacerda <filipa@gitlab.com>2018-10-30 10:45:54 +0000
committerFilipa Lacerda <filipa@gitlab.com>2018-10-30 10:45:54 +0000
commit0ccacd7bbdbb63e451ec17e6a650d329f5d4ac9c (patch)
tree8bbc1da190d72eb1a56e6063155ac53933161ab1 /spec/javascripts/vue_mr_widget
parent05af98bfefba87f60eda58642a6422af10c129ae (diff)
downloadgitlab-ce-0ccacd7bbdbb63e451ec17e6a650d329f5d4ac9c.tar.gz
Prevents review app to render an empty dropdown.
When a deployment has no files to show in the dropdown we fallback to the regular single button for the review app link. This commit moves the review app link into a component since it's used twice.
Diffstat (limited to 'spec/javascripts/vue_mr_widget')
-rw-r--r--spec/javascripts/vue_mr_widget/components/deployment_spec.js20
-rw-r--r--spec/javascripts/vue_mr_widget/components/review_app_link_spec.js38
2 files changed, 58 insertions, 0 deletions
diff --git a/spec/javascripts/vue_mr_widget/components/deployment_spec.js b/spec/javascripts/vue_mr_widget/components/deployment_spec.js
index d26ffa4b4a6..059abc8b7fb 100644
--- a/spec/javascripts/vue_mr_widget/components/deployment_spec.js
+++ b/spec/javascripts/vue_mr_widget/components/deployment_spec.js
@@ -211,6 +211,26 @@ describe('Deployment component', () => {
});
});
+ describe('without changes', () => {
+ beforeEach(() => {
+ window.gon = window.gon || {};
+ window.gon.features = window.gon.features || {};
+ window.gon.features.ciEnvironmentsStatusChanges = true;
+ delete deploymentMockData.changes;
+
+ vm = mountComponent(Component, { deployment: { ...deploymentMockData } });
+ });
+
+ afterEach(() => {
+ delete window.gon.features.ciEnvironmentsStatusChanges;
+ });
+
+ it('renders the link to the review app without dropdown', () => {
+ expect(vm.$el.querySelector('.js-mr-wigdet-deployment-dropdown')).toBeNull();
+ expect(vm.$el.querySelector('.js-deploy-url-feature-flag')).not.toBeNull();
+ });
+ })
+
describe('deployment status', () => {
describe('running', () => {
beforeEach(() => {
diff --git a/spec/javascripts/vue_mr_widget/components/review_app_link_spec.js b/spec/javascripts/vue_mr_widget/components/review_app_link_spec.js
new file mode 100644
index 00000000000..68a65bd21c6
--- /dev/null
+++ b/spec/javascripts/vue_mr_widget/components/review_app_link_spec.js
@@ -0,0 +1,38 @@
+import Vue from 'vue';
+import component from '~/vue_merge_request_widget/components/review_app_link.vue';
+import mountComponent from '../../helpers/vue_mount_component_helper';
+
+describe('review app link', () => {
+ const Component = Vue.extend(component);
+ const props = {
+ link: '/review',
+ cssClass: 'js-link',
+ };
+ let vm;
+ let el;
+
+ beforeEach(() => {
+ vm = mountComponent(Component, props);
+ el = vm.$el;
+ });
+
+ afterEach(() => {
+ vm.$destroy();
+ });
+
+ it('renders provided link as href attribute', () => {
+ expect(el.getAttribute('href')).toEqual(props.link);
+ });
+
+ it('renders provided cssClass as class attribute', () => {
+ expect(el.getAttribute('class')).toEqual(props.cssClass);
+ });
+
+ it('renders View app text', () => {
+ expect(el.textContent.trim()).toEqual('View app');
+ });
+
+ it('renders svg icon', () => {
+ expect(el.querySelector('svg')).not.toBeNull();
+ });
+});