test(i18n): the key guard's canary sees two modules, and lists leaves only (#453)

Review 25409, points 1 and 2: the canary now fails if both imports name
one file (T4), and a fixture pins that a missing branch is reported by
its leaves, never by its container (T1).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
le king fu 2026-10-19 21:10:03 -04:00
parent f27bdc4afa
commit 4f060ba7d7

View file

@ -68,7 +68,9 @@ const EN = nodesOf(en);
describe("locale keys: fr.json and en.json (#453)", () => { describe("locale keys: fr.json and en.json (#453)", () => {
it("reads both files whole, array items included", () => { it("reads both files whole, array items included", () => {
// The canary: an empty or unread file would make the comparison pass on nothing. // The canary: an empty or unread file would make the comparison pass on
// nothing, and so would one file imported twice.
expect(en, "en.json and fr.json are two modules").not.toBe(fr);
for (const [name, nodes] of [["fr.json", FR], ["en.json", EN]] as const) { for (const [name, nodes] of [["fr.json", FR], ["en.json", EN]] as const) {
expect(nodes.get("common.cancel"), name).toBe("leaf"); expect(nodes.get("common.cancel"), name).toBe("leaf");
expect(nodes.get("dashboard.help.tips"), name).toBe("array"); expect(nodes.get("dashboard.help.tips"), name).toBe("array");
@ -95,6 +97,8 @@ describe("locale keys: the comparison (#453)", () => {
const b = nodesOf({ list: ["one"], only: { b: "y" } }); const b = nodesOf({ list: ["one"], only: { b: "y" } });
expect(missingKeys(a, b)).toEqual(["list.1", "only.a"]); expect(missingKeys(a, b)).toEqual(["list.1", "only.a"]);
expect(missingKeys(b, a)).toEqual(["only.b"]); expect(missingKeys(b, a)).toEqual(["only.b"]);
// Leaves only: the container `zz` of a missing branch is not listed.
expect(missingKeys(nodesOf({ zz: { only: "x" } }), nodesOf({}))).toEqual(["zz.only"]);
}); });
it("holds an array against an object with the same indices as a gap", () => { it("holds an array against an object with the same indices as a gap", () => {