Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
@@ -170,6 +170,34 @@ describe("i18n parity guard", () => {
|
||||
expect(report).toContain("keys:\n - common.save");
|
||||
});
|
||||
|
||||
test("fails when high-confidence German UI text leaks into the English catalog", async () => {
|
||||
const { root } = await makeFixture();
|
||||
await writeTranslations(root, "de", { leads: { status: { new: "Neu" } } });
|
||||
await writeTranslations(root, "en", { leads: { status: { new: "Neu" } } });
|
||||
|
||||
const result = checkFixtureParity(root);
|
||||
const report = formatI18nParityReport(result);
|
||||
|
||||
expect(result.ok).toBe(false);
|
||||
expect(result.issues).toContainEqual({
|
||||
type: "language-leak",
|
||||
locale: "en",
|
||||
namespace: "translations",
|
||||
filePath: path.join(root, "apps", "web", "public", "locales", "en", "translations.json"),
|
||||
findings: [{ key: "leads.status.new", words: ["Neu"] }],
|
||||
});
|
||||
expect(report).toContain("German UI text in English catalog [en/translations]");
|
||||
expect(report).toContain("leads.status.new [Neu]");
|
||||
});
|
||||
|
||||
test("does not flag lower-case technical identifiers in English examples", async () => {
|
||||
const { root } = await makeFixture();
|
||||
await writeTranslations(root, "de", { audit: { example: "z. B. kontakt.created" } });
|
||||
await writeTranslations(root, "en", { audit: { example: "e.g. kontakt.created" } });
|
||||
|
||||
expect(checkFixtureParity(root).ok).toBe(true);
|
||||
});
|
||||
|
||||
test("fails when an unconfigured locale directory is present", async () => {
|
||||
const { root } = await makeFixture();
|
||||
await writeTranslations(root, "de", { common: { save: "Speichern" } });
|
||||
@@ -241,6 +269,153 @@ describe("i18n parity guard", () => {
|
||||
expect(result.ok).toBe(true);
|
||||
});
|
||||
|
||||
test("extracts semantic translation keys from view-model and registry fields", async () => {
|
||||
const { root } = await makeFixture();
|
||||
await writeTranslations(root, "de", {
|
||||
registry: {
|
||||
breadcrumb: "Archiv",
|
||||
empty: "Keine Einträge",
|
||||
health: "Verbunden",
|
||||
status: "Bereit",
|
||||
},
|
||||
});
|
||||
await writeTranslations(root, "en", {
|
||||
registry: {
|
||||
breadcrumb: "Archive",
|
||||
empty: "No entries",
|
||||
health: "Connected",
|
||||
status: "Ready",
|
||||
},
|
||||
});
|
||||
await writeSource(
|
||||
root,
|
||||
"packages/view-models/src/registry.ts",
|
||||
[
|
||||
"export const vm = {",
|
||||
' breadcrumbKey: "registry.breadcrumb",',
|
||||
' emptyHeadlineKey: "registry.empty",',
|
||||
' healthMessageKey: "registry.health",',
|
||||
' statusLabelKey: "registry.status",',
|
||||
"};",
|
||||
].join("\n"),
|
||||
);
|
||||
|
||||
expect(checkFixtureParity(root).ok).toBe(true);
|
||||
});
|
||||
|
||||
test("fails for missing semantic registry keys that would otherwise render raw", async () => {
|
||||
const { root } = await makeFixture();
|
||||
await writeTranslations(root, "de", { common: { save: "Speichern" } });
|
||||
await writeTranslations(root, "en", { common: { save: "Save" } });
|
||||
await writeSource(root, "apps/web/app/services/registry.ts", 'export const result = { errorKey: "registry.errors.typo" };\n');
|
||||
|
||||
const result = checkFixtureParity(root);
|
||||
|
||||
expect(result.ok).toBe(false);
|
||||
expect(result.issues).toContainEqual({
|
||||
type: "missing-source-key",
|
||||
key: "registry.errors.typo",
|
||||
namespace: null,
|
||||
fallback: "no-fallback",
|
||||
files: ["apps/web/app/services/registry.ts"],
|
||||
});
|
||||
});
|
||||
|
||||
test("scans feature-specific view-model key fields beyond generic labels", async () => {
|
||||
const { root } = await makeFixture();
|
||||
await writeTranslations(root, "de", { common: { save: "Speichern" } });
|
||||
await writeTranslations(root, "en", { common: { save: "Save" } });
|
||||
await writeSource(
|
||||
root,
|
||||
"packages/view-models/src/feature.vm.ts",
|
||||
[
|
||||
"export const vm = {",
|
||||
' anonymousHintKey: "feature.hints.anonymous",',
|
||||
' candidatesEmptyKey: "feature.candidates.empty",',
|
||||
' dropzoneHeadlineKey: "feature.dropzone.headline",',
|
||||
' noMailboxKey: "feature.mailbox.missing",',
|
||||
' usersLoadingKey: "feature.users.loading",',
|
||||
"};",
|
||||
].join("\n"),
|
||||
);
|
||||
|
||||
const missingKeys = checkFixtureParity(root).issues
|
||||
.filter((issue) => issue.type === "missing-source-key")
|
||||
.map((issue) => issue.key)
|
||||
.sort();
|
||||
expect(missingKeys).toEqual([
|
||||
"feature.candidates.empty",
|
||||
"feature.dropzone.headline",
|
||||
"feature.hints.anonymous",
|
||||
"feature.mailbox.missing",
|
||||
"feature.users.loading",
|
||||
]);
|
||||
});
|
||||
|
||||
test("does not treat stable protocol registry identifiers as translation keys", async () => {
|
||||
const { root } = await makeFixture();
|
||||
await writeTranslations(root, "de", { common: { save: "Speichern" } });
|
||||
await writeTranslations(root, "en", { common: { save: "Save" } });
|
||||
await writeSource(
|
||||
root,
|
||||
"apps/web/app/services/protocol-registry.ts",
|
||||
[
|
||||
'export const feature = { featureFlagKey: "tenant.subscription.active" };',
|
||||
'export const trigger = { triggerKey: "lead.qualified" };',
|
||||
'export const template = { templateKey: "shk.order.v1" };',
|
||||
].join("\n"),
|
||||
);
|
||||
|
||||
expect(checkFixtureParity(root).ok).toBe(true);
|
||||
});
|
||||
|
||||
test("does not treat local variables named like translation fields as translation keys", async () => {
|
||||
const { root } = await makeFixture();
|
||||
await writeTranslations(root, "de", { common: { save: "Speichern" } });
|
||||
await writeTranslations(root, "en", { common: { save: "Save" } });
|
||||
await writeSource(root, "apps/web/app/services/registry.ts", 'export const value = () => { const translationKey = "configTranslationKeys"; return translationKey; };\n');
|
||||
|
||||
expect(checkFixtureParity(root).ok).toBe(true);
|
||||
});
|
||||
|
||||
test("accepts dynamic translation key families backed by catalog entries", async () => {
|
||||
const { root } = await makeFixture();
|
||||
await writeTranslations(root, "de", { workflow: { status: { active: "Aktiv", paused: "Pausiert" } } });
|
||||
await writeTranslations(root, "en", { workflow: { status: { active: "Active", paused: "Paused" } } });
|
||||
await writeSource(root, "apps/web/app/components/Status.tsx", "export function Status({ t, status }) { return t(`workflow.status.${status}`); }\n");
|
||||
|
||||
expect(checkFixtureParity(root).ok).toBe(true);
|
||||
});
|
||||
|
||||
test("fails for dynamic translation key families with a misspelled catalog prefix", async () => {
|
||||
const { root } = await makeFixture();
|
||||
await writeTranslations(root, "de", { forms: { editor: { operators: { equals: "Ist gleich" } } } });
|
||||
await writeTranslations(root, "en", { forms: { editor: { operators: { equals: "Equals" } } } });
|
||||
await writeSource(root, "apps/web/app/components/Operator.tsx", "export function Operator({ t, op }) { return t(`forms.builder.operators.${op}`); }\n");
|
||||
|
||||
const result = checkFixtureParity(root);
|
||||
const report = formatI18nParityReport(result);
|
||||
|
||||
expect(result.ok).toBe(false);
|
||||
expect(result.issues).toContainEqual({
|
||||
type: "missing-source-key",
|
||||
key: "forms.builder.operators.*",
|
||||
namespace: null,
|
||||
fallback: "no-fallback",
|
||||
files: ["apps/web/app/components/Operator.tsx"],
|
||||
});
|
||||
expect(report).toContain("missing source translation key family (no-fallback): forms.builder.operators.*");
|
||||
});
|
||||
|
||||
test("handles expressions with quoted fallbacks inside dynamic key families", async () => {
|
||||
const { root } = await makeFixture();
|
||||
await writeTranslations(root, "de", { dialog: { confirm: { leave: { title: "Verlassen?" } } } });
|
||||
await writeTranslations(root, "en", { dialog: { confirm: { leave: { title: "Leave?" } } } });
|
||||
await writeSource(root, "apps/web/app/components/Dialog.tsx", 'export function Dialog({ t, action }) { return t(`dialog.confirm.${action ?? "leave"}.title`); }\n');
|
||||
|
||||
expect(checkFixtureParity(root).ok).toBe(true);
|
||||
});
|
||||
|
||||
test("fails when static package source keys are missing from the reference locale", async () => {
|
||||
const { root } = await makeFixture();
|
||||
await writeTranslations(root, "de", { common: { save: "Speichern" } });
|
||||
|
||||
Reference in new issue
Block a user