Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
@@ -0,0 +1,29 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { readRepoFile } from "~/utils/testing/repoPaths";
|
||||
|
||||
function getValueAtPath(source: Record<string, unknown>, path: string): unknown {
|
||||
return path.split(".").reduce<unknown>((current, segment) => {
|
||||
if (!current || typeof current !== "object") {
|
||||
return undefined;
|
||||
}
|
||||
return (current as Record<string, unknown>)[segment];
|
||||
}, source);
|
||||
}
|
||||
|
||||
describe("embed form submit i18n", () => {
|
||||
it("keeps every public submit error key translated in supported locales", () => {
|
||||
const routeSource = readRepoFile("apps/web/app/routes/api.embed.forms.$formKey.submit.tsx");
|
||||
const errorKeys = Array.from(routeSource.matchAll(/"embed\.forms\.submit\.errors\.[^"]+"/gu)).map(([match]) =>
|
||||
match.replaceAll('"', "")
|
||||
);
|
||||
|
||||
expect(errorKeys).toHaveLength(14);
|
||||
|
||||
for (const locale of ["en", "de"]) {
|
||||
const translations = JSON.parse(readRepoFile(`apps/web/public/locales/${locale}/translations.json`)) as Record<string, unknown>;
|
||||
for (const key of errorKeys) {
|
||||
expect(getValueAtPath(translations, key), `${locale}:${key}`).toEqual(expect.any(String));
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user