Files
co-lite/solvway-admin-portal/app/lib/i18n/defaultMessages.test.ts
T
ngqileandClaude Opus 5.5 5ee51d1913 chore: copy kept Tastefully modules and portals into Co-Lite
Backend modules from tastefully 8bd93d15: core-libs, core-session,
api-gateway, mobile-api, services-auth, services-system,
services-counter, services-member, services-log, services-email.
solvway-admin-portal from babyboo f64d096ea, solvway-customer-portal
from tastefully 8bd93d15. Copied as tracked files only.

Literal secrets replaced with environment placeholders:
- services-email: SMTP_PASSWORD, MAILGUN_API_KEY, SENDGRID_API_KEY,
  MAILJET_API_KEY, MAILJET_SECRET_KEY (optional, empty default)
- services-system: JUMIO_TOKEN, JUMIO_SECRET (optional)
- services-auth: USER_AUTH_API_SECRET (required); commented JWT secret removed
- core-libs: JWT_TOKEN default removed (required), XXL_JOB_TOKEN default
  removed, ipgeolocation key read from IPGEOLOCATION_API_KEY
- services-system EkycAppConfig: commented Jumio credentials removed

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

235 lines
11 KiB
TypeScript

import { describe, it, expect } from "vitest";
import { DEFAULT_MESSAGES } from "./defaultMessages";
import { resolveMessage } from "./t";
// Spec (add-sidebar-i18n-labels): "Every BO Code Has A Guaranteed English
// Default" -- every BO_* code used by the seeded sidebar must resolve to a
// readable English label even when no DB message row exists, so the sidebar
// never displays a raw code.
describe("DEFAULT_MESSAGES BO_* floor", () => {
it.each([
["BO_DASHBOARD", "Dashboard"],
["BO_DASHBOARD_EVENT", "Event dashboard"],
["BO_MEMBERS", "Members"],
["BO_REPORTS", "Reports"],
["BO_NETWORK", "Network"],
["BO_MESSAGES", "Messages"],
["BO_USERS", "Users"],
["BO_ROLES", "Roles"],
["BO_ADMINISTRATION", "Administration"],
["BO_SYSTEM", "Settings"], // module-id-category-order: the BO_SYSTEM group is labelled Settings
["BO_NOTIFICATIONS", "Notifications"],
["BO_LOGIN_SECURITY", "Login security"],
["BO_LOCALES", "Locales"],
["BO_MODULES", "Modules"],
["BO_CATALOG", "Catalogue"],
["BO_CATALOG_SETUP", "Catalogue setup"],
["BO_PAYMENT_METHODS", "Payment methods"],
["BO_PRODUCTS", "Products"],
["BO_WAREHOUSE_SETUP", "Warehouse setup"],
// BABYBOO-18 I2 (add-inventory-stock-in): both inventory module codes must
// resolve to readable English labels so the sidebar never shows raw codes.
["BO_STOCK_IN", "Stock in"],
["BO_STOCK_ON_HAND", "Stock on hand"],
// BABYBOO-18 I3 (add-inventory-transfers-movement-history): two more inventory
// module codes must resolve to readable English labels so the sidebar never
// shows raw codes.
["BO_STOCK_TRANSFER", "Transfers"],
["BO_MOVEMENT_HISTORY", "Movement history"],
// BABYBOO-18 I4 (add-inventory-adjustments): the adjustments module code must
// resolve to a readable English label so the sidebar never shows the raw code.
["BO_STOCK_ADJUSTMENT", "Adjustments"],
// add-stock-count-event-closeout
["BO_STOCK_COUNT", "Stock counts"],
["BO_STOCK_COUNT_APPROVE", "Approve stock counts"],
// BABYBOO-54 wallet adjustment
["BO_WALLET_ADJUST", "Wallet adjustment"],
// Event module (add-event-module-pickup-e1): the events module code must
// resolve to a readable English label so the sidebar never shows the raw code.
["BO_EVENTS", "Event setup"],
// Event POS counter-sales (add-event-pos-counter-sales, Task 10): the POS module code
// must resolve to a readable English label so the sidebar never shows the raw code.
["BO_POS", "Event POS"],
["BO_EVENT_SUMMARY", "Event summary"],
// Branch counter POS (add-branch-counter-sale): the counter module code must resolve to a
// readable English label so the sidebar never shows the raw code.
["BO_COUNTER", "Branch counter"],
// BABYBOO-18 Phase F (add-admin-do-monitoring): the online delivery-order monitor
// module code must resolve to a readable English label so the sidebar never shows the
// raw code.
["BO_DELIVERY_ORDERS", "Delivery orders"],
// (openspec/changes/add-admin-delivery-fulfilment-steps): the web-order enquiry module
// code must resolve to a readable English label so the sidebar never shows the raw code.
["BO_WEB_ORDERS", "Sales listing"],
// add-refund-requests (BABYBOO-26): the refund review queue module label.
["BO_REFUND_REQUESTS", "Refund requests"],
// babyboo-56-warranty-claims: the warranty claim review queue module label.
["BO_WARRANTY_CLAIMS", "Warranty claims"],
["BO_PROMOTIONS", "Promotions"],
["BO_PRODUCT_REVIEWS", "Product reviews"],
// add-storefront-collections
["BO_COLLECTIONS", "Collections"],
// add-cms-pages
["BO_PAGES", "Pages"],
// add-cms-forms
["BO_FORMS", "Forms"],
// add-storefront-menus
["BO_MENUS", "Menus"],
// add-shipping-rates
["BO_SHIPPING", "Shipping"],
["BO_GIFT_CARDS", "Gift cards"],
// add-admin-online-payments
["BO_ONLINE_PAYMENTS", "Online payments"],
["BO_KYC", "Know your customer"],
["BO_MEMBER_MESSAGES", "Member messages"],
["BO_RANK_REFERRAL", "Rank & referrer"], // BABYBOO-43
// BABYBOO-54: "referral" reads as the act; the person is the referrer.
["Referral", "Referrer"],
["ChangeReferral", "Change referrer"],
["RankReferralSubtitle", "Fix a member's rank or referrer. Each change needs a reason and is logged in History."],
["CorrectRankReferral", "Correct rank / referrer"],
["ReferralCorrected", "Referrer corrected."],
["MsgErr_NOT_IN_NETWORK", "This member can't be messaged."],
["MsgErr_MESSAGE_INVALID", "The message isn't valid. Check the text and images."],
["MsgErr_MESSAGE_IMAGE_NOT_OWNED", "An attached image couldn't be used. Remove it and attach it again."],
["MsgErr_MESSAGE_COMMIT_FAILED", "The message couldn't be saved. Please try again."],
["MsgErr_MESSAGE_UPLOAD_FAILED", "The image upload failed. Please try again."],
["MsgErr_EMPTY_TARGET", "No members match this selection."],
// reorganize-admin-sidebar: the sidebar layout's group headers.
["BO_NAV_SALES_ORDERS", "Sales & orders"],
["BO_NAV_EVENTS", "Event"],
["BO_NAV_MEMBERS", "Members"],
["BO_NAV_INVENTORY", "Inventory"],
["BO_NAV_CATALOGUE", "Catalogue"],
["BO_NAV_ONLINE_STORE", "Online store"],
["BO_NAV_COMMUNICATIONS", "Communications"],
["BO_NAV_SETTINGS", "Settings"],
["BO_NAV_ADMINISTRATION", "Administration"],
// rename-locations-label: the /locations module row is named "Locations & Warehouses" (also
// its ACL and route-gate key), but the page manages locations only; /warehouses owns warehouses.
["Locations & Warehouses", "Locations"],
// consolidate-admin-settings-nav: merged Settings entries and their page tabs.
["BO_NAV_LANGUAGES", "Languages"],
["BO_NAV_LOCATIONS_WAREHOUSES", "Locations & warehouses"],
["SettingsTabLanguages", "Languages"],
["SettingsTabTranslations", "Translations"],
["SettingsTabLocations", "Locations"],
["SettingsTabWarehouses", "Warehouses"],
])("%s resolves to %s via resolveMessage with an empty catalog", (code, expected) => {
expect(resolveMessage({}, code)).toBe(expected);
});
it("no longer defines BO_NAV_OTHER (module-id-category-order: no Other group)", () => {
expect(Object.keys(DEFAULT_MESSAGES)).not.toContain("BO_NAV_OTHER");
});
it("includes BO_ROOT for completeness even though it is never rendered", () => {
expect(DEFAULT_MESSAGES.BO_ROOT).toBe("babyboo admin");
});
});
// add-admin-member-management: every member status/rank code the backend can
// return must resolve to a readable label (raw codes are never shown), and no
// invented tier (Bronze/Silver/Gold) may exist.
describe("DEFAULT_MESSAGES member status/rank floor", () => {
it.each([
["MemberStatusPending", "Pending"],
["MemberStatusFailed", "Failed"],
["MemberStatusActive", "Active"],
["MemberStatusExpired", "Expired"],
["MemberStatusInactive", "Inactive"],
["MemberStatusResigned", "Resigned"],
["MemberStatusSuspended", "Suspended"],
["MemberStatusTerminated", "Terminated"],
["MemberRankNotApplicable", "Not applicable"],
["MemberRankMember", "Member"],
["MemberRankOtter", "Otter"],
["MemberRankSquirrel", "Squirrel"],
["MemberRankGiraffe", "Giraffe"],
])("%s resolves via resolveMessage with an empty catalog", (code, expected) => {
expect(resolveMessage({}, code)).toBe(expected);
});
it("never invents rank tiers (no Bronze/Silver/Gold/Platinum/Diamond labels)", () => {
const keys = Object.keys(DEFAULT_MESSAGES);
expect(keys.some(k => /Bronze|Silver|Gold|Platinum|Diamond/i.test(k))).toBe(false);
});
});
describe("first sign-in copy", () => {
it("no longer defines ResetCurrentPassword (BABYBOO-54 item 14)", () => {
expect(DEFAULT_MESSAGES).not.toHaveProperty("ResetCurrentPassword");
});
it("defines ResetChooseIntro and drops the unused ResetIntro", () => {
expect(DEFAULT_MESSAGES.ResetChooseIntro).toBe("Choose a new password to continue.");
expect(DEFAULT_MESSAGES).not.toHaveProperty("ResetIntro");
});
});
// BABYBOO-54 (wallet adjustment): every new UI code ships an English default.
describe("DEFAULT_MESSAGES wallet adjustment copy", () => {
it.each(
Object.entries({
WalletAdjTitle: "Wallet adjustment",
WalletAdjIntro:
"Add to or deduct from a member's wallet. Each adjustment is recorded in the ledger with your name and the reason.",
WalletAdjMember: "Member code",
WalletAdjMemberNotFound: "No member found with this code.",
WalletAdjWallet: "Wallet",
WalletAdjBalance: "Balance {balance}",
WalletAdjDirection: "Adjustment",
WalletAdjAdd: "Add",
WalletAdjDeduct: "Deduct",
WalletAdjAmount: "Amount",
WalletAdjAmountInvalid: "Enter an amount greater than 0 with at most 2 decimals.",
WalletAdjReason: "Reason",
WalletAdjReasonHint: "Shown in the ledger. Up to 150 characters.",
WalletAdjRequired: "Fill in every field.",
WalletAdjReview: "Review",
WalletAdjConfirmAdd: "Add {amount} to {member}'s {wallet} wallet?",
WalletAdjConfirmDeduct: "Deduct {amount} from {member}'s {wallet} wallet?",
WalletAdjSubmit: "Confirm adjustment",
WalletAdjSaved: "Adjustment saved.",
WalletAdjInsufficient: "Not enough balance in this wallet.",
WalletAdjFailed: "Could not save the adjustment.",
}),
)("%s has its English default", (code, text) => {
expect(DEFAULT_MESSAGES[code]).toBe(text);
});
});
// export-current-catalogue: the four codes of the "Download current catalogue" button and its left-out notes.
describe("DEFAULT_MESSAGES catalogue export", () => {
it.each([
["ProdImportDownloadCatalogue", "Download current catalogue"],
["ProdImportCatalogueFailed", "Failed to download the catalogue"],
["ProdImportNoOptions", "Left out of the file — products with no options yet: {codes}"],
["ProdImportUnusedSkus", "Left out of the file — SKUs not used by any product: {codes}"],
])("%s", (code, english) => {
expect((DEFAULT_MESSAGES as Record<string, string>)[code]).toBe(english);
});
});
// module-id-category-allocation: the /modules create dialog copy.
describe("DEFAULT_MESSAGES module allocation copy", () => {
it.each([
["ModulesTopLevel", "Top level"],
["ModulesBelongsTo", "Belongs to"],
["ModulesActionNeedsModule", "Choose the module this action belongs to."],
[
"ModulesBelongsToHint",
"The action takes its id from this module but is stored under the root, so granting it does not also show the module in the menu.",
],
])("%s resolves to its English default", (code, text) => {
expect(DEFAULT_MESSAGES[code]).toBe(text);
});
});
// SG phase 7b: the Event dialog's Branch select needs a readable default for its empty option.
describe("DEFAULT_MESSAGES event branch", () => {
it("has an English default for the main-branch option", () => {
expect(DEFAULT_MESSAGES.EvtMainBranch).toBe("Main branch (default)");
});
});