import { describe, expect, it } from "vitest"; import { readRepoFile } from "~/utils/testing/repoPaths"; function getValueAtPath(source: Record, path: string): unknown { return path.split(".").reduce((current, segment) => { if (!current || typeof current !== "object") { return undefined; } return (current as Record)[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; for (const key of errorKeys) { expect(getValueAtPath(translations, key), `${locale}:${key}`).toEqual(expect.any(String)); } } }); });