diff --git a/packages/ui/src/host-callbacks/PromptPermission.ts b/packages/ui/src/host-callbacks/PromptPermission.ts index 3c25d0f..9b7012c 100644 --- a/packages/ui/src/host-callbacks/PromptPermission.ts +++ b/packages/ui/src/host-callbacks/PromptPermission.ts @@ -9,6 +9,7 @@ import { getPermissionStatus, isDevicePermission, isEnforceableDevicePermission, + isDevicePermission, setPermissionStatus, type EnforceablePermissionName, } from "../permissions"; diff --git a/packages/ui/tests/notification.test.ts b/packages/ui/tests/notification.test.ts index 2093fa3..e7c3002 100644 --- a/packages/ui/tests/notification.test.ts +++ b/packages/ui/tests/notification.test.ts @@ -83,6 +83,22 @@ describe("notification host callbacks", () => { ).toEqual(["hello"]); }); + it("does not reload the product after granting notification permission", async () => { + await registerNotificationAuthorization(); + const reload = vi.fn(); + window.addEventListener("dotli:device-permission-changed", reload); + const { createPromptPermission } = + await import("@dotli/ui/host-callbacks/PromptPermission"); + + await expect( + createPromptPermission("myapp").devicePermission("Notifications"), + ).resolves.toEqual({ granted: true }); + await new Promise((resolve) => setTimeout(resolve, 0)); + + expect(reload).not.toHaveBeenCalled(); + window.removeEventListener("dotli:device-permission-changed", reload); + }); + it("reuses granted permission and cancels through the shared scheduler", async () => { await registerNotificationAuthorization("Authorized"); const { createNotificationAdapters } =