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>2023-05-03 03:09:11 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-05-03 03:09:11 +0300
commita0754ad291e60e9411897ae4e05e01a600037ee9 (patch)
treed23b71bd0d4db9245aaa12d2fc81da20bcf0f105 /spec/frontend/commons
parent90693cc231ba6e1645dc57f2a9111a7b5a5ceae0 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/commons')
-rw-r--r--spec/frontend/commons/nav/user_merge_requests_spec.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/frontend/commons/nav/user_merge_requests_spec.js b/spec/frontend/commons/nav/user_merge_requests_spec.js
index f660cc8e9de..114cbbf812c 100644
--- a/spec/frontend/commons/nav/user_merge_requests_spec.js
+++ b/spec/frontend/commons/nav/user_merge_requests_spec.js
@@ -16,7 +16,10 @@ describe('User Merge Requests', () => {
let newBroadcastChannelMock;
beforeEach(() => {
+ jest.spyOn(document, 'dispatchEvent').mockReturnValue(false);
+
global.gon.current_user_id = 123;
+ global.gon.use_new_navigation = false;
channelMock = {
postMessage: jest.fn(),
@@ -73,6 +76,10 @@ describe('User Merge Requests', () => {
expect(channelMock.postMessage).not.toHaveBeenCalled();
});
});
+
+ it('does not emit event to refetch counts', () => {
+ expect(document.dispatchEvent).not.toHaveBeenCalled();
+ });
});
describe('openUserCountsBroadcast', () => {
@@ -85,6 +92,7 @@ describe('User Merge Requests', () => {
channelMock.onmessage({ data: TEST_COUNT });
+ expect(newBroadcastChannelMock).toHaveBeenCalled();
expect(findMRCountText()).toEqual(TEST_COUNT.toLocaleString());
});
@@ -93,6 +101,7 @@ describe('User Merge Requests', () => {
openUserCountsBroadcast();
+ expect(newBroadcastChannelMock).toHaveBeenCalled();
expect(channelMock.close).toHaveBeenCalled();
});
});
@@ -118,4 +127,28 @@ describe('User Merge Requests', () => {
});
});
});
+
+ describe('if new navigation is enabled', () => {
+ beforeEach(() => {
+ global.gon.use_new_navigation = true;
+ jest.spyOn(UserApi, 'getUserCounts');
+ });
+
+ it('openUserCountsBroadcast is a noop', () => {
+ openUserCountsBroadcast();
+ expect(newBroadcastChannelMock).not.toHaveBeenCalled();
+ });
+
+ describe('refreshUserMergeRequestCounts', () => {
+ it('does not call api', async () => {
+ await refreshUserMergeRequestCounts();
+ expect(UserApi.getUserCounts).not.toHaveBeenCalled();
+ });
+
+ it('emits event to refetch counts', async () => {
+ await refreshUserMergeRequestCounts();
+ expect(document.dispatchEvent).toHaveBeenCalledWith(new CustomEvent('todo:toggle'));
+ });
+ });
+ });
});