From c1818b32e7b972df49c5318eac01cb3516ef9025 Mon Sep 17 00:00:00 2001 From: Daniel Riera Date: Fri, 11 Jul 2025 17:04:50 -0400 Subject: [PATCH] PM-23674 The v3 notification is using erroneous notification sizing in some cases (#15562) * PM-23674 * remove duplicate mock --- ...verlay-notifications-content.service.spec.ts | 17 +++++++++-------- .../overlay-notifications-content.service.ts | 10 +++++----- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/apps/browser/src/autofill/overlay/notifications/content/overlay-notifications-content.service.spec.ts b/apps/browser/src/autofill/overlay/notifications/content/overlay-notifications-content.service.spec.ts index 9202a5a3839..7339325bd93 100644 --- a/apps/browser/src/autofill/overlay/notifications/content/overlay-notifications-content.service.spec.ts +++ b/apps/browser/src/autofill/overlay/notifications/content/overlay-notifications-content.service.spec.ts @@ -4,6 +4,8 @@ import AutofillInit from "../../../content/autofill-init"; import { DomQueryService } from "../../../services/abstractions/dom-query.service"; import DomElementVisibilityService from "../../../services/dom-element-visibility.service"; import { flushPromises, sendMockExtensionMessage } from "../../../spec/testing-utils"; +import * as utils from "../../../utils"; +import { sendExtensionMessage } from "../../../utils"; import { NotificationTypeData } from "../abstractions/overlay-notifications-content.service"; import { OverlayNotificationsContentService } from "./overlay-notifications-content.service"; @@ -17,6 +19,11 @@ describe("OverlayNotificationsContentService", () => { beforeEach(() => { jest.useFakeTimers(); + jest + .spyOn(utils, "sendExtensionMessage") + .mockImplementation((command: string) => + Promise.resolve(command === "notificationRefreshFlagValue" ? false : true), + ); domQueryService = mock(); domElementVisibilityService = new DomElementVisibilityService(); overlayNotificationsContentService = new OverlayNotificationsContentService(); @@ -45,8 +52,7 @@ describe("OverlayNotificationsContentService", () => { }); it("applies correct styles when notificationRefreshFlag is true", async () => { - overlayNotificationsContentService["notificationRefreshFlag"] = true; - + (sendExtensionMessage as jest.Mock).mockResolvedValue(true); sendMockExtensionMessage({ command: "openNotificationBar", data: { @@ -62,8 +68,6 @@ describe("OverlayNotificationsContentService", () => { }); it("applies correct styles when notificationRefreshFlag is false", async () => { - overlayNotificationsContentService["notificationRefreshFlag"] = false; - sendMockExtensionMessage({ command: "openNotificationBar", data: { @@ -208,10 +212,7 @@ describe("OverlayNotificationsContentService", () => { jest.advanceTimersByTime(150); - expect(chrome.runtime.sendMessage).toHaveBeenCalledWith( - { command: "bgRemoveTabFromNotificationQueue" }, - expect.any(Function), - ); + expect(sendExtensionMessage).toHaveBeenCalledWith("bgRemoveTabFromNotificationQueue"); }); it("closes the notification bar without a fadeout", () => { diff --git a/apps/browser/src/autofill/overlay/notifications/content/overlay-notifications-content.service.ts b/apps/browser/src/autofill/overlay/notifications/content/overlay-notifications-content.service.ts index bc32bf23928..53cbde9cdfb 100644 --- a/apps/browser/src/autofill/overlay/notifications/content/overlay-notifications-content.service.ts +++ b/apps/browser/src/autofill/overlay/notifications/content/overlay-notifications-content.service.ts @@ -67,9 +67,6 @@ export class OverlayNotificationsContentService constructor() { void sendExtensionMessage("checkNotificationQueue"); - void sendExtensionMessage("notificationRefreshFlagValue").then((notificationRefreshFlag) => { - this.notificationRefreshFlag = !!notificationRefreshFlag; - }); } /** @@ -85,11 +82,10 @@ export class OverlayNotificationsContentService * * @param message - The message containing the initialization data for the notification bar. */ - private handleOpenNotificationBarMessage(message: NotificationsExtensionMessage) { + private async handleOpenNotificationBarMessage(message: NotificationsExtensionMessage) { if (!message.data) { return; } - const { type, typeData, params } = message.data; if (this.currentNotificationBarType && type !== this.currentNotificationBarType) { @@ -105,6 +101,10 @@ export class OverlayNotificationsContentService params, }; + await sendExtensionMessage("notificationRefreshFlagValue").then((notificationRefreshFlag) => { + this.notificationRefreshFlag = !!notificationRefreshFlag; + }); + if (globalThis.document.readyState === "loading") { document.addEventListener("DOMContentLoaded", () => this.openNotificationBar(initData)); return;