The form is built once to the settled field set, and a valid send is saved before anyone is emailed. Co-authored-by: Cursor <cursoragent@cursor.com>
56 lines
2.4 KiB
TypeScript
56 lines
2.4 KiB
TypeScript
import "@testing-library/jest-dom/vitest";
|
|
import { describe, expect, it } from "vitest";
|
|
import { renderWithProviders as render, screen } from "../utils/test-utils";
|
|
import WorkshopHero from "../../app/components/sections/WorkshopHero";
|
|
import WorkshopOverview from "../../app/components/sections/WorkshopOverview";
|
|
import WorkshopSignup from "../../app/components/sections/WorkshopSignup";
|
|
import messages from "../../messages/en/index";
|
|
|
|
describe("Workshops page sections", () => {
|
|
it("points every talk-to-a-facilitator button at the form", () => {
|
|
render(
|
|
<>
|
|
<WorkshopHero />
|
|
<WorkshopOverview />
|
|
</>,
|
|
);
|
|
const links = screen.getAllByRole("link", { name: "Talk to a facilitator" });
|
|
expect(links.length).toBeGreaterThanOrEqual(2);
|
|
for (const link of links) {
|
|
expect(link).toHaveAttribute("href", "#workshop-signup");
|
|
}
|
|
});
|
|
|
|
it("shows the full field set, one optional marker, and the settled challenge line", () => {
|
|
render(<WorkshopSignup issuedAt={Date.now() - 60_000} />);
|
|
expect(screen.getByText("How many members?")).toBeInTheDocument();
|
|
expect(screen.getByText("Members, member-owners or policyholders")).toBeInTheDocument();
|
|
expect(screen.getByText("Your role")).toBeInTheDocument();
|
|
expect(screen.getByRole("option", { name: "Select role..." })).toBeInTheDocument();
|
|
expect(
|
|
screen.getByText("A big change ahead, like a merger, a bylaw change or a new leader"),
|
|
).toBeInTheDocument();
|
|
expect(screen.getAllByText("Optional")).toHaveLength(2);
|
|
expect(screen.queryByText("What you want to take on.")).not.toBeInTheDocument();
|
|
expect(screen.getByRole("button", { name: "Send to a facilitator" })).toBeInTheDocument();
|
|
});
|
|
|
|
it("replaces the form with the large-organization confirmation and names no price", () => {
|
|
render(
|
|
<WorkshopSignup
|
|
issuedAt={Date.now() - 60_000}
|
|
schedulingUrl="https://calendar.example/workshop"
|
|
initialStatus="sent"
|
|
initialLarge
|
|
/>,
|
|
);
|
|
expect(screen.getAllByText(/two working days/).length).toBeGreaterThan(0);
|
|
expect(screen.getByRole("link", { name: "Choose a time" })).toHaveAttribute(
|
|
"href",
|
|
"https://calendar.example/workshop",
|
|
);
|
|
expect(screen.queryByText(/\$\d/)).not.toBeInTheDocument();
|
|
expect(messages.pages.workshops.whoRunsIt.title).not.toMatch(/paid/);
|
|
});
|
|
});
|