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
57 lines
2.1 KiB
TypeScript
57 lines
2.1 KiB
TypeScript
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
import { render, screen, waitFor } from "@testing-library/react";
|
|
import userEvent from "@testing-library/user-event";
|
|
|
|
// add-sku-barcodes polish: list copy uses the singular noun ("No supplier rows yet", "Add supplier row"),
|
|
// not the plural tab label ("No suppliers rows yet").
|
|
|
|
const auth = vi.hoisted(() => ({ hasModule: vi.fn(() => true), loading: false }));
|
|
vi.mock("@/app/lib/AdminAuthContext", () => ({
|
|
useAdminAuth: () => ({ hasModule: auth.hasModule, loading: auth.loading }),
|
|
}));
|
|
|
|
const svc = vi.hoisted(() => ({ listCatalogRows: vi.fn() }));
|
|
vi.mock("@/app/lib/services/adminCatalog", () => ({
|
|
listCatalogRows: (list: string) => svc.listCatalogRows(list),
|
|
createCatalogRow: vi.fn(),
|
|
updateCatalogRow: vi.fn(),
|
|
toggleCatalogRowStatus: vi.fn(),
|
|
uploadCatalogImage: vi.fn(),
|
|
}));
|
|
|
|
import CatalogSetupPage from "./page";
|
|
|
|
beforeEach(() => {
|
|
svc.listCatalogRows.mockReset();
|
|
svc.listCatalogRows.mockResolvedValue([]);
|
|
});
|
|
|
|
describe("catalogue list copy", () => {
|
|
it("says 'supplier' in the Suppliers empty state and add dialog", async () => {
|
|
const user = userEvent.setup();
|
|
render(<CatalogSetupPage />);
|
|
|
|
await user.click(await screen.findByRole("tab", { name: "Suppliers" }));
|
|
await waitFor(() => expect(svc.listCatalogRows).toHaveBeenCalledWith("supplier"));
|
|
|
|
expect(await screen.findByText("No supplier rows yet — add the first one.")).toBeInTheDocument();
|
|
await user.click(screen.getByRole("button", { name: "Add row" }));
|
|
expect(screen.getByRole("heading", { name: "Add supplier row" })).toBeInTheDocument();
|
|
});
|
|
|
|
it("says 'price type' in the Price types empty state", async () => {
|
|
const user = userEvent.setup();
|
|
render(<CatalogSetupPage />);
|
|
|
|
await user.click(await screen.findByRole("tab", { name: "Price types" }));
|
|
|
|
expect(await screen.findByText("No price type rows yet — add the first one.")).toBeInTheDocument();
|
|
});
|
|
|
|
it("keeps 'brand' for Brand", async () => {
|
|
render(<CatalogSetupPage />);
|
|
|
|
expect(await screen.findByText("No brand rows yet — add the first one.")).toBeInTheDocument();
|
|
});
|
|
});
|