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:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-04-21 02:50:22 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-04-21 02:50:22 +0300
commit9dc93a4519d9d5d7be48ff274127136236a3adb3 (patch)
tree70467ae3692a0e35e5ea56bcb803eb512a10bedb /spec/frontend/whats_new
parent4b0f34b6d759d6299322b3a54453e930c6121ff0 (diff)
Add latest changes from gitlab-org/gitlab@13-11-stable-eev13.11.0-rc43
Diffstat (limited to 'spec/frontend/whats_new')
-rw-r--r--spec/frontend/whats_new/components/app_spec.js59
-rw-r--r--spec/frontend/whats_new/store/actions_spec.js11
-rw-r--r--spec/frontend/whats_new/utils/notification_spec.js23
3 files changed, 28 insertions, 65 deletions
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');
});
});
});