diff --git a/apps/web/e2e/notification-settings.spec.ts b/apps/web/e2e/notification-settings.spec.ts index 4d7893f..27e1571 100644 --- a/apps/web/e2e/notification-settings.spec.ts +++ b/apps/web/e2e/notification-settings.spec.ts @@ -15,18 +15,19 @@ const ENDPOINT = "https://push.example.test/e2e-device"; async function stubPushApi(page: Page, endpoint: string) { await page.addInitScript((pushEndpoint) => { const permissionKey = "e2e:notification-permission"; + const notification = Object.defineProperties(function Notification() {}, { + permission: { get: () => sessionStorage.getItem(permissionKey) ?? "default" }, + requestPermission: { + value: async () => { + sessionStorage.setItem(permissionKey, "granted"); + return "granted"; + }, + }, + }); Object.defineProperty(window, "Notification", { configurable: true, writable: true, - value: class { - static get permission() { - return sessionStorage.getItem(permissionKey) ?? "default"; - } - static async requestPermission() { - sessionStorage.setItem(permissionKey, "granted"); - return "granted"; - } - }, + value: notification, }); const storageKey = "e2e:push-subscription"; const current = () => {