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
68 lines
3.2 KiB
TypeScript
68 lines
3.2 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { CATALOG_TABLES, catalogTableSpec } from "./catalogTables";
|
|
|
|
// Column registry lock (spec "admin-portal-catalog-ui", task 4.1): the /catalog-setup grid
|
|
// renders EXACTLY the columns the picked list's registry declares. Unlike REFERENCE_TABLES
|
|
// (always keyed by "code"), the three catalog lists are NOT uniform: brand keys off code,
|
|
// category keys off its own name, priceType keys off its own label. Status is never an
|
|
// editable dialog field (badge: true, editable: false) — it changes only via the inline toggle.
|
|
// Collection was removed (openspec/changes/bundle-by-sku-drop-collection) — Category is
|
|
// sufficient; it had no product relationship and 0 rows.
|
|
|
|
function fieldNames(key: string): string[] {
|
|
const spec = catalogTableSpec(key);
|
|
if (!spec) throw new Error(`no registry entry for ${key}`);
|
|
return spec.columns.map((c) => c.field);
|
|
}
|
|
|
|
describe("CATALOG_TABLES column registry", () => {
|
|
it("covers exactly the four allow-listed lists", () => {
|
|
expect(CATALOG_TABLES.map((t) => t.key)).toEqual(["brand", "category", "priceType", "supplier"]);
|
|
for (const t of CATALOG_TABLES) {
|
|
expect(t.label.length).toBeGreaterThan(0);
|
|
}
|
|
});
|
|
|
|
it("brand: code (key) + name + status, keyed by code", () => {
|
|
const spec = catalogTableSpec("brand")!;
|
|
expect(spec.keyField).toBe("code");
|
|
expect(fieldNames("brand")).toEqual(["code", "name", "status"]);
|
|
expect(spec.columns.find((c) => c.field === "code")!.required).toBe(true);
|
|
expect(spec.columns.find((c) => c.field === "code")!.editable).toBe(true);
|
|
expect(spec.columns.find((c) => c.field === "name")!.required).toBe(true);
|
|
expect(spec.columns.find((c) => c.field === "name")!.editable).toBe(true);
|
|
});
|
|
|
|
it("category: the wire key IS `code` (mobile-api's CatalogRow carries every list's key in `code`, not `name`)", () => {
|
|
const spec = catalogTableSpec("category")!;
|
|
expect(spec.keyField).toBe("code");
|
|
expect(fieldNames("category")).toEqual(["code", "status"]);
|
|
expect(spec.columns.find((c) => c.field === "code")!.label).toBe("CatName");
|
|
expect(spec.columns.find((c) => c.field === "code")!.required).toBe(true);
|
|
expect(spec.columns.find((c) => c.field === "code")!.editable).toBe(true);
|
|
});
|
|
|
|
it("priceType: the wire key IS `code` too (mobile-api's CatalogRow has no `priceType` field)", () => {
|
|
const spec = catalogTableSpec("priceType")!;
|
|
expect(spec.keyField).toBe("code");
|
|
expect(fieldNames("priceType")).toEqual(["code", "status"]);
|
|
expect(spec.columns.find((c) => c.field === "code")!.label).toBe("PricingPriceType");
|
|
expect(spec.columns.find((c) => c.field === "code")!.required).toBe(true);
|
|
expect(spec.columns.find((c) => c.field === "code")!.editable).toBe(true);
|
|
});
|
|
|
|
it("status is never an editable dialog field on any list — badge, read-only in grid", () => {
|
|
for (const t of CATALOG_TABLES) {
|
|
const status = t.columns.find((c) => c.field === "status")!;
|
|
expect(status.editable).toBe(false);
|
|
expect(status.badge).toBe(true);
|
|
}
|
|
});
|
|
|
|
it("every list's keyField matches one of its own declared columns", () => {
|
|
for (const t of CATALOG_TABLES) {
|
|
expect(t.columns.some((c) => c.field === t.keyField)).toBe(true);
|
|
}
|
|
});
|
|
});
|