test(web): stub the Notification permission without a static-only class
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MRtGG9ARfqqhma3t85Ro2u
This commit is contained in:
parent
2d95db70f2
commit
59d02c46fb
@ -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 = () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user