Files
SnapOtter/tests/unit/web/i18n-locale.test.ts
SnapOtterandGitHub 5d36ac06d8 feat(analytics): build-time bake + telemetry depth (#336)
Bake PostHog + Sentry into the published Docker image (SNAPOTTER_ANALYTICS
build arg, codegen script). Delete entire consent system. Move event emission
to BullMQ worker. Add cross-tier identity stitching, Sentry performance
tracing on both tiers, frontend funnel events. Fix stateful regex bug.

86 files changed, 1593 insertions(+), 3747 deletions(-)
2026-06-24 11:05:39 +08:00

86 lines
2.2 KiB
TypeScript

import { en, loadTranslations, SUPPORTED_LOCALES } from "@snapotter/shared";
import { describe, expect, it } from "vitest";
describe("SUPPORTED_LOCALES", () => {
it("has 21 locales including English", () => {
expect(SUPPORTED_LOCALES).toHaveLength(21);
});
it("includes English as first entry", () => {
expect(SUPPORTED_LOCALES[0].code).toBe("en");
expect(SUPPORTED_LOCALES[0].dir).toBe("ltr");
});
it("has Arabic as RTL", () => {
const ar = SUPPORTED_LOCALES.find((l) => l.code === "ar");
expect(ar).toBeDefined();
expect(ar?.dir).toBe("rtl");
});
it("all locales have required fields", () => {
for (const locale of SUPPORTED_LOCALES) {
expect(locale.code).toBeTruthy();
expect(locale.name).toBeTruthy();
expect(locale.nativeName).toBeTruthy();
expect(["ltr", "rtl"]).toContain(locale.dir);
}
});
});
describe("loadTranslations", () => {
it("returns English translations for 'en'", async () => {
const t = await loadTranslations("en");
expect(t.common.upload).toBe("Upload from computer");
});
it("returns English fallback for unsupported locale", async () => {
const t = await loadTranslations("xx-XX");
expect(t.common.upload).toBe("Upload from computer");
});
});
describe("en translation completeness", () => {
it("has all required top-level sections", () => {
const sections = Object.keys(en);
const required = [
"common",
"categories",
"tools",
"toolSettings",
"toolPage",
"homePage",
"fullscreenGrid",
"editor",
"settings",
"auth",
"changePassword",
"automate",
"nav",
"files",
"dropzone",
"reviewPanel",
"features",
"help",
"errors",
"sidebar",
"toolCard",
"appLayout",
];
for (const key of required) {
expect(sections, `missing section: ${key}`).toContain(key);
}
});
it("has 25 rotating phrases", () => {
expect(en.auth.rotatingPhrases).toHaveLength(25);
});
it("has 30 progress messages", () => {
expect(en.features.progressMessages).toHaveLength(30);
});
it("has 24 categories", () => {
expect(Object.keys(en.categories)).toHaveLength(24);
});
});