From 59d02c46fb691e41f449e8b96924dcf64250462e Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 3 Oct 2026 14:11:10 +0000 Subject: [PATCH] test(web): stub the Notification permission without a static-only class Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01MRtGG9ARfqqhma3t85Ro2u --- apps/web/e2e/notification-settings.spec.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) 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 = () => {