diff --git a/apps/web/src/stores/notifications/SummarizedNotificationState.test.ts b/apps/web/src/stores/notifications/SummarizedNotificationState.test.ts new file mode 100644 index 0000000000..d9854af661 --- /dev/null +++ b/apps/web/src/stores/notifications/SummarizedNotificationState.test.ts @@ -0,0 +1,41 @@ +/* +Copyright 2026 hayaksi1 + +SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial +Please see LICENSE files in the repository root for full details. +*/ + +// @vitest-environment happy-dom + +import { describe, it, expect } from "vitest"; + +import { SummarizedNotificationState } from "./SummarizedNotificationState"; +import { StaticNotificationState } from "./StaticNotificationState"; +import { NotificationLevel } from "./NotificationLevel"; + +describe("SummarizedNotificationState", () => { + it("reports the unsent symbol when one of the summarized states failed to send", () => { + const state = new SummarizedNotificationState(); + state.add(StaticNotificationState.forCount(12, NotificationLevel.Notification)); + state.add(new StaticNotificationState("!", 1, NotificationLevel.Unsent)); + + expect(state.level).toBe(NotificationLevel.Unsent); + expect(state.symbol).toBe("!"); + }); + + it("keeps reporting the count when nothing failed to send", () => { + const state = new SummarizedNotificationState(); + state.add(StaticNotificationState.forCount(12, NotificationLevel.Notification)); + + expect(state.level).toBe(NotificationLevel.Notification); + expect(state.symbol).toBeNull(); + expect(state.count).toBe(12); + }); + + it("still adopts an explicit symbol below the unsent level", () => { + const state = new SummarizedNotificationState(); + state.add(StaticNotificationState.forSymbol("@", NotificationLevel.Highlight), true); + + expect(state.symbol).toBe("@"); + }); +}); diff --git a/apps/web/src/stores/notifications/SummarizedNotificationState.ts b/apps/web/src/stores/notifications/SummarizedNotificationState.ts index 0d223834e6..70a0b289cf 100644 --- a/apps/web/src/stores/notifications/SummarizedNotificationState.ts +++ b/apps/web/src/stores/notifications/SummarizedNotificationState.ts @@ -29,6 +29,14 @@ export class SummarizedNotificationState extends NotificationState { return this.totalStatesWithUnread; } + /** + * Matches {@link SpaceNotificationState.symbol}: a failure to send is reported as "!" rather + * than as a count, so the summarized badge does not present it as a notification count. + */ + public get symbol(): string | null { + return this._level === NotificationLevel.Unsent ? "!" : this._symbol; + } + /** * Append a notification state to this snapshot, taking the loudest NotificationColor * of the two. By default this will not adopt the symbol of the other notification