Files
co-lite/solvway-admin-portal/app/components/events/EventForm.clearErrors.test.tsx
T
ngqileandClaude Opus 5.5 b4d36175d3 fix: paste guests, form errors, send feedback, check-in errors, invite recipients
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
2026-12-02 01:38:37 +08:00

24 lines
1.0 KiB
TypeScript

import { render, screen, waitFor } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { describe, it, expect, vi } from "vitest";
vi.mock("@/app/lib/services/adminEvents", () => ({ listSalespersonOptions: vi.fn().mockResolvedValue([]) }));
import { EventForm } from "./EventForm";
import { pickDate } from "@/test/pickDate";
describe("EventForm error clearing", () => {
it("clears a field's error as soon as that field is filled", async () => {
render(<EventForm onSubmit={vi.fn()} />);
await userEvent.click(screen.getByRole("button", { name: /create/i }));
expect(await screen.findByText("Name is required.")).toBeInTheDocument();
await userEvent.type(screen.getByLabelText("Name"), "A");
expect(screen.queryByText("Name is required.")).not.toBeInTheDocument();
expect(screen.getByText("Location is required.")).toBeInTheDocument();
pickDate("Start date", "2026-12-10");
await waitFor(() => expect(screen.queryByText("Start date is required.")).not.toBeInTheDocument());
});
});