Commit 702f9fb0 authored by Nathan Friend's avatar Nathan Friend

Use setCookie/getCookie helpers

parent e0484503
<script> <script>
import { GlBadge, GlButton, GlModalDirective, GlTab, GlTabs, GlAlert } from '@gitlab/ui'; import { GlBadge, GlButton, GlModalDirective, GlTab, GlTabs, GlAlert } from '@gitlab/ui';
import Cookies from 'js-cookie';
import createFlash from '~/flash'; import createFlash from '~/flash';
import { setCookie, getCookie } from '~/lib/utils/common_utils';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import { ENVIRONMENTS_SURVEY_DISMISSED_COOKIE_NAME } from '../constants'; import { ENVIRONMENTS_SURVEY_DISMISSED_COOKIE_NAME } from '../constants';
import eventHub from '../event_hub'; import eventHub from '../event_hub';
...@@ -68,7 +68,7 @@ export default { ...@@ -68,7 +68,7 @@ export default {
data() { data() {
return { return {
environmentsSurveyAlertDismissed: environmentsSurveyAlertDismissed:
Cookies.get(ENVIRONMENTS_SURVEY_DISMISSED_COOKIE_NAME) === 'true', getCookie(ENVIRONMENTS_SURVEY_DISMISSED_COOKIE_NAME) === 'true',
}; };
}, },
...@@ -122,7 +122,7 @@ export default { ...@@ -122,7 +122,7 @@ export default {
}, },
onSurveyAlertDismiss() { onSurveyAlertDismiss() {
Cookies.set(ENVIRONMENTS_SURVEY_DISMISSED_COOKIE_NAME, 'true', { expires: 365 * 10 }); setCookie(ENVIRONMENTS_SURVEY_DISMISSED_COOKIE_NAME, 'true');
this.environmentsSurveyAlertDismissed = true; this.environmentsSurveyAlertDismissed = true;
}, },
}, },
......
import { GlTabs, GlAlert } from '@gitlab/ui'; import { GlTabs, GlAlert } from '@gitlab/ui';
import { mount, shallowMount } from '@vue/test-utils'; import { mount, shallowMount } from '@vue/test-utils';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import Cookies from 'js-cookie';
import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import Container from '~/environments/components/container.vue'; import Container from '~/environments/components/container.vue';
import DeployBoard from '~/environments/components/deploy_board.vue'; import DeployBoard from '~/environments/components/deploy_board.vue';
...@@ -10,6 +9,7 @@ import EnableReviewAppModal from '~/environments/components/enable_review_app_mo ...@@ -10,6 +9,7 @@ import EnableReviewAppModal from '~/environments/components/enable_review_app_mo
import EnvironmentsApp from '~/environments/components/environments_app.vue'; import EnvironmentsApp from '~/environments/components/environments_app.vue';
import { ENVIRONMENTS_SURVEY_DISMISSED_COOKIE_NAME } from '~/environments/constants'; import { ENVIRONMENTS_SURVEY_DISMISSED_COOKIE_NAME } from '~/environments/constants';
import axios from '~/lib/utils/axios_utils'; 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 * as urlUtils from '~/lib/utils/url_utility';
import { environment, folder } from './mock_data'; import { environment, folder } from './mock_data';
...@@ -291,7 +291,7 @@ describe('Environment', () => { ...@@ -291,7 +291,7 @@ describe('Environment', () => {
}); });
afterEach(() => { afterEach(() => {
Cookies.remove(ENVIRONMENTS_SURVEY_DISMISSED_COOKIE_NAME); removeCookie(ENVIRONMENTS_SURVEY_DISMISSED_COOKIE_NAME);
}); });
describe('when the user has not dismissed the alert', () => { describe('when the user has not dismissed the alert', () => {
...@@ -309,7 +309,7 @@ describe('Environment', () => { ...@@ -309,7 +309,7 @@ describe('Environment', () => {
}); });
it('persists the dismisal using a cookie', () => { it('persists the dismisal using a cookie', () => {
const cookieValue = Cookies.get(ENVIRONMENTS_SURVEY_DISMISSED_COOKIE_NAME); const cookieValue = getCookie(ENVIRONMENTS_SURVEY_DISMISSED_COOKIE_NAME);
expect(cookieValue).toBe('true'); expect(cookieValue).toBe('true');
}); });
...@@ -318,7 +318,7 @@ describe('Environment', () => { ...@@ -318,7 +318,7 @@ describe('Environment', () => {
describe('when the user has previously dismissed the alert', () => { describe('when the user has previously dismissed the alert', () => {
beforeEach(async () => { beforeEach(async () => {
Cookies.set(ENVIRONMENTS_SURVEY_DISMISSED_COOKIE_NAME, 'true', { expires: 365 * 10 }); setCookie(ENVIRONMENTS_SURVEY_DISMISSED_COOKIE_NAME, 'true');
await createWrapper(true); await createWrapper(true);
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment