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
45 lines
2.0 KiB
TypeScript
45 lines
2.0 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { interpolate, resolveMessage } from "./t";
|
|
|
|
describe("interpolate", () => {
|
|
it("replaces {named} and {0} placeholders, leaving unknowns intact", () => {
|
|
expect(interpolate("Hi {name}", { name: "Sam" })).toBe("Hi Sam");
|
|
expect(interpolate("{0} of {1}", { "0": 1, "1": 3 })).toBe("1 of 3");
|
|
expect(interpolate("plain")).toBe("plain");
|
|
expect(interpolate("{missing}", { other: "x" })).toBe("{missing}");
|
|
});
|
|
});
|
|
|
|
describe("resolveMessage", () => {
|
|
it("prefers the catalog value", () => {
|
|
expect(resolveMessage({ BackOfficeTitle: "后台管理" }, "BackOfficeTitle")).toBe("后台管理");
|
|
});
|
|
|
|
// BackOfficeTitle's default differs from its code, so this distinguishes a
|
|
// catalog miss that hit the built-in default from one that fell through to
|
|
// the raw code.
|
|
it("falls back to the built-in English default when not in catalog", () => {
|
|
expect(resolveMessage({}, "BackOfficeTitle")).toBe("Co-Lite");
|
|
});
|
|
|
|
it("defaults the browser tab title to Co-Lite :: BackOffice", () => {
|
|
expect(resolveMessage({}, "BackOfficeMetaTitle")).toBe("Co-Lite :: BackOffice");
|
|
});
|
|
|
|
// The services-system message.code column is case-insensitive (utf8mb3_general_ci), so the
|
|
// catalog may key a code in a different case than the source uses (legacy SIGNIN vs SignIn).
|
|
it("matches a catalog code case-insensitively, preferring the exact case", () => {
|
|
expect(resolveMessage({ SIGNIN: "Sign In" }, "SignIn")).toBe("Sign In");
|
|
expect(resolveMessage({ SIGNIN: "upper", SignIn: "exact" }, "SignIn")).toBe("exact");
|
|
});
|
|
|
|
it("falls back to the raw code when missing everywhere, never an empty string", () => {
|
|
expect(resolveMessage({}, "TotallyUnknownCode")).toBe("TotallyUnknownCode");
|
|
expect(resolveMessage({}, "TotallyUnknownCode")).not.toBe("");
|
|
});
|
|
|
|
it("interpolates params after resolving", () => {
|
|
expect(resolveMessage({ Greeting: "Hi {name}" }, "Greeting", { name: "Sam" })).toBe("Hi Sam");
|
|
});
|
|
});
|