完善桌面体验与系统通知收口
This commit is contained in:
@@ -39,7 +39,7 @@ describe("desktop notification manager", () => {
|
||||
},
|
||||
});
|
||||
acknowledgeNotificationsMock.mockResolvedValue({ data: {} });
|
||||
showNotificationMock.mockResolvedValue(undefined);
|
||||
showNotificationMock.mockResolvedValue(true);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
@@ -53,7 +53,7 @@ describe("desktop notification manager", () => {
|
||||
|
||||
it("acknowledges displayed notifications and leaves failed deliveries for retry", async () => {
|
||||
showNotificationMock
|
||||
.mockResolvedValueOnce(undefined)
|
||||
.mockResolvedValueOnce(true)
|
||||
.mockRejectedValueOnce(new Error("notification failed"));
|
||||
const { initDesktopNotificationManager, triggerDesktopNotificationPoll } = await import("./desktopNotificationManager");
|
||||
|
||||
@@ -66,6 +66,21 @@ describe("desktop notification manager", () => {
|
||||
expect(acknowledgeNotificationsMock).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("does not acknowledge notifications when the system dispatch does not happen", async () => {
|
||||
showNotificationMock
|
||||
.mockResolvedValueOnce(false)
|
||||
.mockResolvedValueOnce(true);
|
||||
const { initDesktopNotificationManager, triggerDesktopNotificationPoll } = await import("./desktopNotificationManager");
|
||||
|
||||
initDesktopNotificationManager();
|
||||
triggerDesktopNotificationPoll();
|
||||
await vi.runOnlyPendingTimersAsync();
|
||||
|
||||
expect(showNotificationMock).toHaveBeenCalledTimes(2);
|
||||
expect(acknowledgeNotificationsMock).toHaveBeenCalledWith("claim-token", ["notification-2"]);
|
||||
expect(acknowledgeNotificationsMock).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("does not claim notifications before operating system permission is granted", async () => {
|
||||
getPermissionMock.mockResolvedValue("prompt");
|
||||
const { initDesktopNotificationManager, triggerDesktopNotificationPoll } = await import("./desktopNotificationManager");
|
||||
|
||||
Reference in New Issue
Block a user