Files
co-lite/solvway-admin-portal/app/lib/i18n/errorReasonInterpolation.sweep.test.ts
T
ngqileandClaude Opus 5.5 1071ddaa2a feat(admin-portal): cut babyboo portal down to Co-Lite login, users and roles
Removes every other screen, API route, component, test and the dependencies only
they used. Cookie colite_admin, Co-Lite branding, BO_USERS/BO_ROLES modules only.
The user form no longer loads branches, events or country scope.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
2026-11-26 21:24:30 +08:00

28 lines
1.1 KiB
TypeScript

import { describe, it, expect } from "vitest";
import { readdirSync, readFileSync, statSync } from "node:fs";
import { join, relative } from "node:path";
// unsupported-image-message: a server reason interpolated into a message ("Image upload failed: {message}") may be a
// message code, so it goes through t() first. A raw `message: err.message` param would show
// the code itself to the admin, untranslated.
const ROOT = join(__dirname, "..", ".."); // solvway-admin-portal/app
function sources(dir: string): string[] {
return readdirSync(dir).flatMap((name) => {
const p = join(dir, name);
if (statSync(p).isDirectory()) return name === "node_modules" ? [] : sources(p);
return /\.tsx?$/.test(name) && !/\.test\.tsx?$/.test(name) ? [p] : [];
});
}
describe("server reasons interpolated into messages", () => {
it("are translated before interpolation", () => {
const raw = sources(ROOT).flatMap((file) =>
readFileSync(file, "utf8").split("\n").flatMap((line, i) =>
/\bmessage:\s*err\.message\b/.test(line) ? [`${relative(ROOT, file)}:${i + 1}`] : [],
),
);
expect(raw).toEqual([]);
});
});