Found by the manual e2e of the production build: - paste guests preview counted an array, so it read "[object Object]" and never offered Save guests; - New event and Add user errors now clear when the field is fixed; - "Send to all unsent" says when nothing was unsent; - the check-in lookup shows an error on an empty submit and carries the typed email or mobile into the walk-in form; - invitation emails sent over Pub/Sub now save their recipient's link, so the Emails page shows the recipient. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
47 lines
2.2 KiB
TypeScript
47 lines
2.2 KiB
TypeScript
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
import { render, screen } from "@testing-library/react";
|
|
import userEvent from "@testing-library/user-event";
|
|
|
|
const mocks = vi.hoisted(() => ({ getCheckin: vi.fn(), lookupCheckin: vi.fn(), registerWalkIn: vi.fn() }));
|
|
vi.mock("@/app/lib/services/publicInvite", () => mocks);
|
|
vi.mock("next/navigation", () => ({ useParams: () => ({ token: "chk1" }) }));
|
|
|
|
import CheckinPage from "./page";
|
|
|
|
beforeEach(() => {
|
|
mocks.getCheckin.mockReset().mockResolvedValue({
|
|
state: "OPEN", eventName: "Expo 2026", startDate: "2026-12-01", endDate: "2026-12-02", location: "KLCC", companyName: "INS",
|
|
notice: { id: 7, textEn: "We keep your data safe.", textMs: "Data anda selamat." }, interests: [],
|
|
});
|
|
mocks.lookupCheckin.mockReset().mockResolvedValue({ result: "FORM" });
|
|
});
|
|
|
|
describe("/c/[token] lookup", () => {
|
|
it("shows a visible error and does not look up when the field is empty", async () => {
|
|
const user = userEvent.setup();
|
|
render(<CheckinPage />);
|
|
await user.click(await screen.findByRole("button", { name: "Check in" }));
|
|
expect(await screen.findByText("Enter a mobile number or an email.")).toBeInTheDocument();
|
|
expect(screen.getByLabelText("Mobile number or email")).toHaveAttribute("aria-invalid", "true");
|
|
expect(mocks.lookupCheckin).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("carries a looked-up email into the walk-in form", async () => {
|
|
const user = userEvent.setup();
|
|
render(<CheckinPage />);
|
|
await user.type(await screen.findByLabelText("Mobile number or email"), "w@b.co");
|
|
await user.click(screen.getByRole("button", { name: "Check in" }));
|
|
expect(await screen.findByLabelText("Email")).toHaveValue("w@b.co");
|
|
expect(screen.getByLabelText("Mobile number")).toHaveValue("");
|
|
});
|
|
|
|
it("carries a looked-up mobile into the walk-in form", async () => {
|
|
const user = userEvent.setup();
|
|
render(<CheckinPage />);
|
|
await user.type(await screen.findByLabelText("Mobile number or email"), "0123456789");
|
|
await user.click(screen.getByRole("button", { name: "Check in" }));
|
|
expect(await screen.findByLabelText("Mobile number")).toHaveValue("0123456789");
|
|
expect(screen.getByLabelText("Email")).toHaveValue("");
|
|
});
|
|
});
|