Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/environments/environments_app_spec.js')
-rw-r--r--spec/frontend/environments/environments_app_spec.js50
1 files changed, 49 insertions, 1 deletions
diff --git a/spec/frontend/environments/environments_app_spec.js b/spec/frontend/environments/environments_app_spec.js
index 1abdeff614c..dc176001943 100644
--- a/spec/frontend/environments/environments_app_spec.js
+++ b/spec/frontend/environments/environments_app_spec.js
@@ -1,4 +1,4 @@
-import { GlTabs } from '@gitlab/ui';
+import { GlTabs, GlAlert } from '@gitlab/ui';
import { mount, shallowMount } from '@vue/test-utils';
import MockAdapter from 'axios-mock-adapter';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
@@ -7,7 +7,9 @@ import DeployBoard from '~/environments/components/deploy_board.vue';
import EmptyState from '~/environments/components/empty_state.vue';
import EnableReviewAppModal from '~/environments/components/enable_review_app_modal.vue';
import EnvironmentsApp from '~/environments/components/environments_app.vue';
+import { ENVIRONMENTS_SURVEY_DISMISSED_COOKIE_NAME } from '~/environments/constants';
import axios from '~/lib/utils/axios_utils';
+import { setCookie, getCookie, removeCookie } from '~/lib/utils/common_utils';
import * as urlUtils from '~/lib/utils/url_utility';
import { environment, folder } from './mock_data';
@@ -48,6 +50,7 @@ describe('Environment', () => {
const findNewEnvironmentButton = () => wrapper.findByTestId('new-environment');
const findEnvironmentsTabAvailable = () => wrapper.find('.js-environments-tab-available > a');
const findEnvironmentsTabStopped = () => wrapper.find('.js-environments-tab-stopped > a');
+ const findSurveyAlert = () => wrapper.find(GlAlert);
beforeEach(() => {
mock = new MockAdapter(axios);
@@ -280,4 +283,49 @@ describe('Environment', () => {
expect(wrapper.findComponent(GlTabs).attributes('value')).toBe('1');
});
});
+
+ describe('survey alert', () => {
+ beforeEach(async () => {
+ mockRequest(200, { environments: [] });
+ await createWrapper(true);
+ });
+
+ afterEach(() => {
+ removeCookie(ENVIRONMENTS_SURVEY_DISMISSED_COOKIE_NAME);
+ });
+
+ describe('when the user has not dismissed the alert', () => {
+ it('shows the alert', () => {
+ expect(findSurveyAlert().exists()).toBe(true);
+ });
+
+ describe('when the user dismisses the alert', () => {
+ beforeEach(() => {
+ findSurveyAlert().vm.$emit('dismiss');
+ });
+
+ it('hides the alert', () => {
+ expect(findSurveyAlert().exists()).toBe(false);
+ });
+
+ it('persists the dismisal using a cookie', () => {
+ const cookieValue = getCookie(ENVIRONMENTS_SURVEY_DISMISSED_COOKIE_NAME);
+
+ expect(cookieValue).toBe('true');
+ });
+ });
+ });
+
+ describe('when the user has previously dismissed the alert', () => {
+ beforeEach(async () => {
+ setCookie(ENVIRONMENTS_SURVEY_DISMISSED_COOKIE_NAME, 'true');
+
+ await createWrapper(true);
+ });
+
+ it('does not show the alert', () => {
+ expect(findSurveyAlert().exists()).toBe(false);
+ });
+ });
+ });
});