Files
co-lite/solvway-admin-portal/app/components/app/adminShell.i18n.test.tsx
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

63 lines
2.9 KiB
TypeScript

import { describe, it, expect, vi } from "vitest";
import { render, screen } from "@testing-library/react";
import type { ReactNode } from "react";
import { MessagesProvider } from "@/app/lib/i18n/MessagesProvider";
import { CATALOG, m } from "@/test/i18nCatalog";
// localise-admin-shell task 2.1: the shell, error pages and shared UI primitives render catalog copy.
// Every code renders as «Code» (placeholders as «Code:value»), so any English left fails the test.
vi.mock("@/app/lib/server/i18n", async () => ({ getServerT: (await import("@/test/i18nCatalog")).serverT }));
vi.mock("next/link", () => ({
default: ({ href, children, ...rest }: { href: string; children: ReactNode }) => <a href={href} {...rest}>{children}</a>,
}));
import NotFound from "@/app/not-found";
import NotAuthorizedPage from "@/app/not-authorized/page";
import { NotAuthorized } from "@/app/lib/RequireModule";
import { generateMetadata } from "@/app/layout";
import { ErrorState, TableSkeleton } from "@/app/components/ui/states";
import { DataTable } from "@/app/components/ui/data-table";
const inZh = (ui: ReactNode) => render(<MessagesProvider locale="zh_CN" messages={CATALOG}>{ui}</MessagesProvider>);
describe("server pages", () => {
it("not found", async () => {
inZh(await NotFound());
expect(screen.getByRole("heading", { name: m("NotFoundTitle") })).toBeInTheDocument();
expect(screen.getByText(m("NotFoundBody"))).toBeInTheDocument();
expect(screen.getByRole("link", { name: m("ShellBackToDashboard") })).toHaveAttribute("href", "/");
});
it("not authorised", async () => {
inZh(await NotAuthorizedPage());
expect(screen.getByRole("heading", { name: m("NotAuthorizedTitle") })).toBeInTheDocument();
expect(screen.getByText(m("NotAuthorizedBody"))).toBeInTheDocument();
expect(screen.getByRole("link", { name: m("ShellBackToDashboard") })).toBeInTheDocument();
});
it("tab title and description", async () => {
const meta = await generateMetadata();
expect(meta.title).toBe(m("BackOfficeMetaTitle"));
expect(meta.description).toBe(m("LayoutMetaDescription"));
});
});
describe("client primitives", () => {
it("the inline not-authorised state", () => {
inZh(<NotAuthorized />);
expect(screen.getByRole("heading", { name: m("NotAuthorizedTitle") })).toBeInTheDocument();
expect(screen.getByText(m("NotAuthorizedBody"))).toBeInTheDocument();
});
it("error state retry and loading skeleton", () => {
inZh(<><ErrorState message="boom" onRetry={() => {}} /><TableSkeleton /></>);
expect(screen.getByRole("button", { name: m("UiRetry") })).toBeInTheDocument();
expect(screen.getByText(m("UiLoading"))).toBeInTheDocument();
});
it("an empty table", () => {
inZh(<DataTable columns={[{ accessorKey: "a", header: "A" }]} data={[]} total={0} page={1} pageSize={20} onPageChange={() => {}} label="rows" rowKey={() => "row"} />);
expect(screen.getByText(m("UiNoResults"))).toBeInTheDocument();
});
});