fix(notifications): a notice keeps what to say and says it in the reader's language when shown
This commit is contained in:
@@ -5,11 +5,12 @@
|
||||
// notification store used to keep its empty, nobody's history, and the tab's first notice replaced the
|
||||
// account's stored history with it.
|
||||
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { raw, sayNotif, type NotifText } from "./notifications";
|
||||
|
||||
const entry = (id: number, message: string) => ({
|
||||
id,
|
||||
level: "info",
|
||||
message,
|
||||
message: raw(message),
|
||||
ts: 1,
|
||||
read: true,
|
||||
dismissed: true,
|
||||
@@ -20,9 +21,9 @@ const entry = (id: number, message: string) => ({
|
||||
const storedMessages = () =>
|
||||
(
|
||||
JSON.parse(localStorage.getItem("siftlode.notifications") ?? "[]") as {
|
||||
message: string;
|
||||
message: NotifText;
|
||||
}[]
|
||||
).map((n) => n.message);
|
||||
).map((n) => sayNotif(n.message));
|
||||
|
||||
// Warm the transform cache once (see verifyEntry.dom.test.tsx): the first cold import costs ~0.8 s
|
||||
// alone and outran the 5 s case timeout under a full coverage run. Transformed code outlives
|
||||
@@ -52,9 +53,9 @@ describe("stores read at import, before the account is known", { timeout: CASE_B
|
||||
const notifications = await import("./notifications");
|
||||
const { claimLocalData } = await import("./storage");
|
||||
|
||||
notifications.notify({ message: "before the claim" }); // e.g. a failed boot probe
|
||||
notifications.notify({ message: raw("before the claim") }); // e.g. a failed boot probe
|
||||
claimLocalData(5);
|
||||
notifications.notify({ message: "after the claim" });
|
||||
notifications.notify({ message: raw("after the claim") });
|
||||
|
||||
expect(storedMessages()).toEqual(["older", "before the claim", "after the claim"]);
|
||||
expect(notifications.getNotifSettings().durationMs).toBe(0);
|
||||
@@ -80,7 +81,7 @@ describe("a browser that held another account's state", { timeout: CASE_BUDGET }
|
||||
const { claimLocalData } = await import("./storage");
|
||||
|
||||
claimLocalData(5);
|
||||
notifications.notify({ message: "as five" });
|
||||
notifications.notify({ message: raw("as five") });
|
||||
|
||||
expect(storedMessages()).toEqual(["as five"]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user