Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/ui/src/host-callbacks/PromptPermission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
getPermissionStatus,
isDevicePermission,
isEnforceableDevicePermission,
isDevicePermission,
setPermissionStatus,
type EnforceablePermissionName,
} from "../permissions";
Expand Down
16 changes: 16 additions & 0 deletions packages/ui/tests/notification.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 } =
Expand Down
Loading