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.
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
// @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]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user