import { describe, expect, it } from "vitest"; import { readMergedLocaleNamespace } from "~/utils/testing/repoPaths"; const SYSTEM_EVENT_KEYS = [ "groupCreated", "projectCreated", "projectLeaderChanged", "projectLeaderChangedFrom", "memberWriteAccessGranted", "memberWriteAccessRevoked", "memberAdded", "memberRemoved", "channelPrivacyPublic", "channelPrivacyPrivate", "channelArchived", "taskCreated", "generic", ] as const; type ChatSystemTranslations = { chat: { channel: { newSystemMessageAnnouncement: string }; systemEvent: Record<(typeof SYSTEM_EVENT_KEYS)[number], string>; }; }; function readTranslations(locale: "de" | "de-formal" | "en"): ChatSystemTranslations { return readMergedLocaleNamespace(locale, "translations"); } describe("AK-P15b chat system-message translations", () => { it("ships the complete system-event contract in every supported locale", () => { for (const locale of ["de", "de-formal", "en"] as const) { const translations = readTranslations(locale); expect(Object.keys(translations.chat.systemEvent)).toEqual(SYSTEM_EVENT_KEYS); expect(translations.chat.channel.newSystemMessageAnnouncement).toContain("{{message}}"); for (const value of Object.values(translations.chat.systemEvent)) expect(value.trim()).not.toBe(""); } }); it("keeps interpolation placeholders aligned across locales", () => { const locales = [readTranslations("de"), readTranslations("de-formal"), readTranslations("en")]; for (const key of SYSTEM_EVENT_KEYS) { const placeholderSets = locales.map((locale) => placeholders(locale.chat.systemEvent[key])); expect(placeholderSets[1]).toEqual(placeholderSets[0]); expect(placeholderSets[2]).toEqual(placeholderSets[0]); } }); }); function placeholders(value: string): string[] { return [...value.matchAll(/{{\s*([^}\s]+)\s*}}/g)].map((match) => match[1] ?? "").sort(); }