Files
siftlode/frontend/src/lib/notifications.coalesce.dom.test.ts
T
peter 046dde44a4 test(notifications): the center re-says its rows after a switch, a repeat coalesces by content; e2e helper fails with a cause
The center's rows (title, message, refusal, live button) were never rendered across a language
switch, and nothing held the structural compare that coalescing now needs. The channel-link helper
swallowed whatever ended its poll into a bare false: a link that goes away mid-look now counts as
not hit, and no hittable link fails with the poll's own message.
2026-10-30 00:17:46 +01:00

38 lines
1.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// @vitest-environment jsdom
//
// A burst of the same notice is one entry with a count (×N), not a pile of copies. The texts are
// objects now (what to say, built afresh by every msg() call), so "the same" is the same key and
// values, never the same object: a compare by reference would let every repeat stack.
import { afterEach, describe, expect, it } from "vitest";
import { clearAll, getNotifications, msg, notify, raw } from "./notifications";
afterEach(() => clearAll());
describe("coalescing a repeated notice", () => {
it("folds the same key and values into one entry, counted", () => {
notify({
level: "error",
title: msg("errors.title"),
message: msg("errors.reason.unreachable"),
});
notify({
level: "error",
title: msg("errors.title"),
message: msg("errors.reason.unreachable"),
});
expect(getNotifications().map((n) => n.repeat)).toEqual([2]);
});
it("folds the same server refusal too", () => {
notify({ level: "error", message: { detail: { code: "not_found", reason: "view" } } });
notify({ level: "error", message: { detail: { code: "not_found", reason: "view" } } });
expect(getNotifications().map((n) => n.repeat)).toEqual([2]);
});
it("keeps two notices apart when only a value differs", () => {
notify({ message: msg("channels.notify.hidden", { name: raw("One") }) });
notify({ message: msg("channels.notify.hidden", { name: raw("Two") }) });
expect(getNotifications().map((n) => n.repeat)).toEqual([1, 1]);
});
});