34 lines
1.6 KiB
TypeScript
34 lines
1.6 KiB
TypeScript
import { readFileSync } from "node:fs";
|
|
import { fileURLToPath } from "node:url";
|
|
import path from "node:path";
|
|
import { describe, expect, test } from "vitest";
|
|
|
|
// Guard test (#72 i18n-foundation): the tenant profile route MUST keep its
|
|
// locale picker. The picker itself lives in
|
|
// `apps/web/app/modules/users/components/UserProfileSettings.tsx`. The route
|
|
// composes the component and passes `currentSession.locale` so the UI can
|
|
// show the active language. If somebody refactors the picker out we want CI
|
|
// to scream — switching language is a privacy/UX requirement we already
|
|
// shipped, not an optional feature.
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
const profilePath = path.join(__dirname, "profile.tsx");
|
|
const settingsPath = path.resolve(__dirname, "../../../modules/users/components/UserProfileSettings.tsx");
|
|
|
|
describe("tenant profile locale picker", () => {
|
|
test("profile route loader includes the active locale in currentSession", () => {
|
|
const source = readFileSync(profilePath, "utf8");
|
|
expect(source).toContain("currentSession: getCurrentSessionSettings");
|
|
expect(source).toContain("locale: userInfo.lng");
|
|
});
|
|
|
|
test("UserProfileSettings exposes a locale-picker InputSelect", () => {
|
|
const source = readFileSync(settingsPath, "utf8");
|
|
// The picker uses `i18nConfig.supportedLngs` to render the options and
|
|
// submits the change to the root /preferences action via setLocale.
|
|
expect(source).toContain("i18nConfig.supportedLngs");
|
|
expect(source).toMatch(/changedLocale\(/);
|
|
expect(source).toContain('"setLocale"');
|
|
expect(source).toContain('"/preferences"');
|
|
});
|
|
});
|