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
47 lines
2.1 KiB
TypeScript
47 lines
2.1 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { render, screen } from "@testing-library/react";
|
|
import { MemberCell } from "./MemberCell";
|
|
|
|
// fit-admin-listing-pages: one member cell for every listing — code on top (linking to the member),
|
|
// name below in small muted text; guests read "Guest" with their email or name below.
|
|
describe("MemberCell", () => {
|
|
it("shows the code as a link to the member, with the name below", () => {
|
|
render(<MemberCell code="MY3619941" name="QA TESTER" />);
|
|
const link = screen.getByRole("link", { name: "MY3619941" });
|
|
expect(link).toHaveAttribute("href", "/members/MY3619941");
|
|
const name = screen.getByText("QA TESTER");
|
|
expect(name).toHaveClass("text-xs", "text-muted-foreground");
|
|
expect(link.compareDocumentPosition(name) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
|
|
});
|
|
|
|
it("shows only the code when there is no name", () => {
|
|
const { container } = render(<MemberCell code="MY1" />);
|
|
expect(screen.getByRole("link", { name: "MY1" })).toBeInTheDocument();
|
|
expect(container.querySelectorAll(".text-muted-foreground")).toHaveLength(0);
|
|
});
|
|
|
|
it("reads Guest with the email below for a guest, with no link", () => {
|
|
render(<MemberCell guest name={null} email="amy@example.my" />);
|
|
expect(screen.getByText("Guest")).toBeInTheDocument();
|
|
expect(screen.getByText("amy@example.my")).toHaveClass("text-muted-foreground");
|
|
expect(screen.queryByRole("link")).toBeNull();
|
|
});
|
|
|
|
it("prefers the guest's name over the email", () => {
|
|
render(<MemberCell guest name="Amy Tan" email="amy@example.my" />);
|
|
expect(screen.getByText("Amy Tan")).toBeInTheDocument();
|
|
expect(screen.queryByText("amy@example.my")).toBeNull();
|
|
});
|
|
|
|
it("shows the name alone, with no link, when there is no code", () => {
|
|
render(<MemberCell code="" name="E2E Guest" />);
|
|
expect(screen.getByText("E2E Guest")).toBeInTheDocument();
|
|
expect(screen.queryByRole("link")).toBeNull();
|
|
});
|
|
|
|
it("shows a dash when there is no member at all", () => {
|
|
render(<MemberCell code={null} name={null} />);
|
|
expect(screen.getByText("—")).toBeInTheDocument();
|
|
});
|
|
});
|