test: harden housekeeping registry contracts

This commit is contained in:
Simo committed 2026-08-25 19:49:31 +02:00
1 parent 2d5f03048a
commit 14cfad4029
4 files changed
+239 -11

No files matched your search

@@ -21,6 +21,39 @@ const requiredKeys = [
"pages.housekeeping.states.error.description",
];
const expectedDomainMessages = [
{
id: "operations",
labelKey: "pages.housekeeping.domains.operations.title",
descriptionKey: "pages.housekeeping.domains.operations.description",
},
{
id: "people",
labelKey: "pages.housekeeping.domains.people.title",
descriptionKey: "pages.housekeeping.domains.people.description",
},
{
id: "content",
labelKey: "pages.housekeeping.domains.content.title",
descriptionKey: "pages.housekeeping.domains.content.description",
},
{
id: "economy",
labelKey: "pages.housekeeping.domains.economy.title",
descriptionKey: "pages.housekeeping.domains.economy.description",
},
{
id: "hotel",
labelKey: "pages.housekeeping.domains.hotel.title",
descriptionKey: "pages.housekeeping.domains.hotel.description",
},
{
id: "system",
labelKey: "pages.housekeeping.domains.system.title",
descriptionKey: "pages.housekeeping.domains.system.description",
},
] as const;
function resolveMessage(messages: unknown, key: string): unknown {
return key.split(".").reduce<unknown>((value, segment) => {
if (value === null || typeof value !== "object") return undefined;
@@ -44,14 +77,34 @@ describe("housekeeping localization contract", () => {
"states",
]);
for (const key of [
...HOUSEKEEPING_MANIFESTS.flatMap((manifest) => [
manifest.labelKey,
manifest.descriptionKey,
]),
...requiredKeys,
]) {
for (const key of requiredKeys) {
expect(resolveMessage(messages, key), key).toEqual(expect.any(String));
}
for (const [index, expected] of expectedDomainMessages.entries()) {
const manifest = HOUSEKEEPING_MANIFESTS[index];
expect(manifest).toMatchObject(expected);
expect(
resolveMessage(messages, expected.labelKey),
expected.labelKey,
).toEqual(expect.any(String));
expect(
resolveMessage(messages, expected.descriptionKey),
expected.descriptionKey,
).toEqual(expect.any(String));
}
});
it("uses idiomatic Italian copy for the housekeeping shell", () => {
expect(resolveMessage(itMessages, "pages.housekeeping.preview.badge")).toBe(
"Anteprima della struttura",
);
expect(
resolveMessage(itMessages, "pages.housekeeping.navigation.primary"),
).toBe("Aree housekeeping");
expect(
resolveMessage(itMessages, "pages.housekeeping.states.loading.title"),
).toBe("Caricamento in corso");
});
});