Skip to content

Commit 76995b4

Browse files
committed
test: race, multiple rerenders should only show the same notification once
1 parent aeeac53 commit 76995b4

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

test/spec/Extn-InAppNotifications-integ-test.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,5 +373,44 @@ define(function (require, exports, module) {
373373
banner.registerCustomFilter(null);
374374
banner.cleanNotificationBanner();
375375
});
376+
377+
it("Should show notification only once even with multiple concurrent reRenderNotifications calls", async function () {
378+
banner.cleanNotificationBanner();
379+
380+
const {notification} = getRandomNotification("all", false); // NOT DANGER_SHOW_ON_EVERY_BOOT
381+
let renderCount = 0;
382+
383+
// Set cache
384+
banner._setBannerCache(notification);
385+
386+
// Register filter to track render calls
387+
banner.registerCustomFilter(async () => {
388+
renderCount++;
389+
return true;
390+
});
391+
392+
// Make 3 concurrent calls
393+
const promise1 = banner.reRenderNotifications();
394+
const promise2 = banner.reRenderNotifications();
395+
const promise3 = banner.reRenderNotifications();
396+
397+
// Only first render should show banner
398+
await _waitForBannerShown();
399+
expect(renderCount).toEqual(1);
400+
testWindow.$('.close-icon').click();
401+
await promise1;
402+
403+
// Second and third should resolve without showing banner
404+
await awaits(50);
405+
await promise2;
406+
await promise3;
407+
408+
// Filter should only have been called once
409+
expect(renderCount).toEqual(1);
410+
expect(testWindow.$('#notification-bar').is(":visible")).toBe(false);
411+
412+
// Cleanup
413+
banner.registerCustomFilter(null);
414+
});
376415
});
377416
});

0 commit comments

Comments
 (0)