From 9dc93a4519d9d5d7be48ff274127136236a3adb3 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Tue, 20 Apr 2021 23:50:22 +0000 Subject: Add latest changes from gitlab-org/gitlab@13-11-stable-ee --- spec/frontend/whats_new/components/app_spec.js | 59 ++-------------------- spec/frontend/whats_new/store/actions_spec.js | 11 ++-- spec/frontend/whats_new/utils/notification_spec.js | 23 +++++++-- 3 files changed, 28 insertions(+), 65 deletions(-) (limited to 'spec/frontend/whats_new') diff --git a/spec/frontend/whats_new/components/app_spec.js b/spec/frontend/whats_new/components/app_spec.js index ad062d04140..45c4682208b 100644 --- a/spec/frontend/whats_new/components/app_spec.js +++ b/spec/frontend/whats_new/components/app_spec.js @@ -1,4 +1,4 @@ -import { GlDrawer, GlInfiniteScroll, GlTabs } from '@gitlab/ui'; +import { GlDrawer, GlInfiniteScroll } from '@gitlab/ui'; import { createLocalVue, mount } from '@vue/test-utils'; import Vuex from 'vuex'; import { mockTracking, unmockTracking, triggerEvent } from 'helpers/tracking_helper'; @@ -21,12 +21,9 @@ describe('App', () => { let actions; let state; let trackingSpy; - let gitlabDotCom = true; const buildProps = () => ({ - storageKey: 'storage-key', - versions: ['3.11', '3.10'], - gitlabDotCom, + versionDigest: 'version-digest', }); const buildWrapper = () => { @@ -91,7 +88,7 @@ describe('App', () => { }); it('dispatches openDrawer and tracking calls when mounted', () => { - expect(actions.openDrawer).toHaveBeenCalledWith(expect.any(Object), 'storage-key'); + expect(actions.openDrawer).toHaveBeenCalledWith(expect.any(Object), 'version-digest'); expect(trackingSpy).toHaveBeenCalledWith(undefined, 'click_whats_new_drawer', { label: 'namespace_id', value: 'namespace-840', @@ -176,54 +173,4 @@ describe('App', () => { ); }); }); - - describe('self managed', () => { - const findTabs = () => wrapper.find(GlTabs); - - const clickSecondTab = async () => { - const secondTab = wrapper.findAll('.nav-link').at(1); - await secondTab.trigger('click'); - await new Promise((resolve) => requestAnimationFrame(resolve)); - }; - - beforeEach(() => { - gitlabDotCom = false; - setup(); - }); - - it('renders tabs with drawer body height and content', () => { - const scroll = findInfiniteScroll(); - const tabs = findTabs(); - - expect(scroll.exists()).toBe(false); - expect(tabs.attributes().style).toBe(`height: ${MOCK_DRAWER_BODY_HEIGHT}px;`); - expect(wrapper.find('h5').text()).toBe('Whats New Drawer'); - }); - - describe('fetchVersion', () => { - beforeEach(() => { - actions.fetchItems.mockClear(); - }); - - it('when version isnt fetched, clicking a tab calls fetchItems', async () => { - const fetchVersionSpy = jest.spyOn(wrapper.vm, 'fetchVersion'); - await clickSecondTab(); - - expect(fetchVersionSpy).toHaveBeenCalledWith('3.10'); - expect(actions.fetchItems).toHaveBeenCalledWith(expect.anything(), { version: '3.10' }); - }); - - it('when version has been fetched, clicking a tab calls fetchItems', async () => { - wrapper.vm.$store.state.features.push({ title: 'GitLab Stories', release: 3.1 }); - await wrapper.vm.$nextTick(); - - const fetchVersionSpy = jest.spyOn(wrapper.vm, 'fetchVersion'); - await clickSecondTab(); - - expect(fetchVersionSpy).toHaveBeenCalledWith('3.10'); - expect(actions.fetchItems).not.toHaveBeenCalled(); - expect(wrapper.find('.tab-pane.active h5').text()).toBe('GitLab Stories'); - }); - }); - }); }); diff --git a/spec/frontend/whats_new/store/actions_spec.js b/spec/frontend/whats_new/store/actions_spec.js index c4125d28aba..39ad526cf14 100644 --- a/spec/frontend/whats_new/store/actions_spec.js +++ b/spec/frontend/whats_new/store/actions_spec.js @@ -11,9 +11,12 @@ describe('whats new actions', () => { useLocalStorageSpy(); it('should commit openDrawer', () => { - testAction(actions.openDrawer, 'storage-key', {}, [{ type: types.OPEN_DRAWER }]); + testAction(actions.openDrawer, 'digest-hash', {}, [{ type: types.OPEN_DRAWER }]); - expect(window.localStorage.setItem).toHaveBeenCalledWith('storage-key', 'false'); + expect(window.localStorage.setItem).toHaveBeenCalledWith( + 'display-whats-new-notification', + 'digest-hash', + ); }); }); @@ -45,12 +48,12 @@ describe('whats new actions', () => { axiosMock.reset(); axiosMock - .onGet('/-/whats_new', { params: { page: 8, version: 40 } }) + .onGet('/-/whats_new', { params: { page: 8 } }) .replyOnce(200, [{ title: 'GitLab Stories' }]); testAction( actions.fetchItems, - { page: 8, version: 40 }, + { page: 8 }, {}, expect.arrayContaining([ { type: types.ADD_FEATURES, payload: [{ title: 'GitLab Stories' }] }, diff --git a/spec/frontend/whats_new/utils/notification_spec.js b/spec/frontend/whats_new/utils/notification_spec.js index e3e390f4394..e1de65df30f 100644 --- a/spec/frontend/whats_new/utils/notification_spec.js +++ b/spec/frontend/whats_new/utils/notification_spec.js @@ -1,5 +1,5 @@ import { useLocalStorageSpy } from 'helpers/local_storage_helper'; -import { setNotification, getStorageKey } from '~/whats_new/utils/notification'; +import { setNotification, getVersionDigest } from '~/whats_new/utils/notification'; describe('~/whats_new/utils/notification', () => { useLocalStorageSpy(); @@ -33,10 +33,23 @@ describe('~/whats_new/utils/notification', () => { expect(notificationEl.classList).toContain('with-notifications'); }); - it('removes class and count element when storage key is true', () => { + it('removes class and count element when legacy storage key is false', () => { const notificationEl = findNotificationEl(); notificationEl.classList.add('with-notifications'); - localStorage.setItem('storage-key', 'false'); + localStorage.setItem('display-whats-new-notification-13.10', 'false'); + + expect(findNotificationCountEl()).toExist(); + + subject(); + + expect(findNotificationCountEl()).not.toExist(); + expect(notificationEl.classList).not.toContain('with-notifications'); + }); + + it('removes class and count element when storage key has current digest', () => { + const notificationEl = findNotificationEl(); + notificationEl.classList.add('with-notifications'); + localStorage.setItem('display-whats-new-notification', 'version-digest'); expect(findNotificationCountEl()).toExist(); @@ -47,9 +60,9 @@ describe('~/whats_new/utils/notification', () => { }); }); - describe('getStorageKey', () => { + describe('getVersionDigest', () => { it('retrieves the storage key data attribute from the el', () => { - expect(getStorageKey(getAppEl())).toBe('storage-key'); + expect(getVersionDigest(getAppEl())).toBe('version-digest'); }); }); }); -- cgit v1.2.3