fix(webui): refine browser notifications (NAN-227)
Reconcile the original notification fix with the integrated main snapshot. Group notification settings and simplify localized copy and documentation. Preserve permission opt-out and notification click routing across app transitions. Suppress late completion notifications for discarded temporary chats and align notification settings skeletons with the loaded layout.
This commit is contained in:
1 parent
7b2af031c0
commit
11152626f8
34 files changed
+728
-289
No files matched your search
@@ -152,6 +152,23 @@ describe("browser notification worker", () => {
|
||||
return reply;
|
||||
}
|
||||
|
||||
it("confirms notification support without displaying a test notification", async () => {
|
||||
const sw = loadSw();
|
||||
const reply = await send(sw, { type: "nanobot:notification-probe" });
|
||||
expect(reply).toHaveBeenCalledWith("ready");
|
||||
expect(sw.showNotification).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("returns test clicks to notification settings, including a still-open older page", async () => {
|
||||
const sw = loadSw();
|
||||
for (const section of ["notifications", "appearance"]) {
|
||||
const target = `${ORIGIN}/#/settings?section=${section}`;
|
||||
expect(await send(sw, { test: true, key: section, url: target })).toHaveBeenCalledWith("submitted");
|
||||
await sw.fire("notificationclick", { notification: { close: vi.fn(), data: { url: target } } });
|
||||
expect(sw.openWindow).toHaveBeenLastCalledWith(target);
|
||||
}
|
||||
});
|
||||
|
||||
it("deduplicates concurrent tabs, dismissed notifications, and worker restarts", async () => {
|
||||
const sw = loadSw();
|
||||
const replies = await Promise.all([send(sw), send(sw)]);
|
||||
@@ -201,6 +218,16 @@ describe("browser notification worker", () => {
|
||||
expect(sw.openWindow).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("opens the destination when the source closed, even if an older page is still open", async () => {
|
||||
const sw = loadSw();
|
||||
const oldTab = { id: "old-page", frameType: "top-level", postMessage: vi.fn(), focus: vi.fn() };
|
||||
sw.matchClients.mockResolvedValue([oldTab]);
|
||||
await sw.fire("notificationclick", { notification: { close: vi.fn(), data: { url, clientId: "closed" } } });
|
||||
expect(sw.openWindow).toHaveBeenCalledWith(url);
|
||||
expect(oldTab.postMessage).not.toHaveBeenCalled();
|
||||
expect(oldTab.focus).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("opens the same host with ordinary auth, but cannot restore a closed temporary chat", async () => {
|
||||
const sw = loadSw();
|
||||
await sw.fire("notificationclick", { notification: { close: vi.fn(), data: { url, clientId: "closed" } } });
|
||||
|
||||
Reference in new issue
Block a user