| 253 | // Helper to build a minimal NotificationEvent-like object for |
| 254 | // the notificationclick handler. |
| 255 | function makeNotificationClickEvent(url?: string) { |
| 256 | let waitUntilPromise: Promise<unknown> = Promise.resolve(); |
| 257 | return { |
| 258 | notification: { |
| 259 | close: vi.fn(), |
| 260 | data: url !== undefined ? { url } : undefined, |
| 261 | }, |
| 262 | waitUntil: (p: Promise<unknown>) => { |
| 263 | waitUntilPromise = p; |
| 264 | }, |
| 265 | // Expose the promise so tests can await it. |
| 266 | get _waitUntilPromise() { |
| 267 | return waitUntilPromise; |
| 268 | }, |
| 269 | }; |
| 270 | } |
| 271 | |
| 272 | describe("serviceWorker notificationclick handler", () => { |
| 273 | it("focuses existing client without navigating when already on the target URL", async () => { |