Files
community-rule/tests/pages/kit.test.tsx
T

83 lines
2.8 KiB
TypeScript

import { describe, expect, test, vi } from "vitest";
import { screen } from "@testing-library/react";
import { renderWithProviders as render } from "../utils/test-utils";
import LegalDocumentPage from "../../app/(marketing)/_components/LegalDocumentPage";
import { legalPathForSlug } from "../../lib/legalSyntheticPost";
import messages from "../../messages/en/index";
vi.mock("../../lib/requestSiteOrigin", () => ({
getRequestSiteOrigin: async () => "https://communityrule.info",
}));
vi.mock("../../app/components/sections/ContentBanner", () => ({
default: ({ post, variant, updatedLabel }) => (
<section data-testid="content-banner" data-variant={variant}>
<h1>{post.frontmatter.title}</h1>
<p>{post.frontmatter.description}</p>
{updatedLabel ? (
<div>
<span>{post.frontmatter.author}</span>
<span>{updatedLabel}</span>
</div>
) : null}
</section>
),
}));
async function renderKitPage() {
const page = messages.pages.kit;
const ui = await LegalDocumentPage({
slug: "kit",
path: legalPathForSlug("kit"),
page,
});
return render(ui);
}
describe("kit page", () => {
test("covers the five meetings, the facilitator guide, and office hours", async () => {
await renderKitPage();
const page = messages.pages.kit;
expect(screen.getByTestId("content-banner")).toHaveAttribute(
"data-variant",
"guide",
);
expect(
screen.getByRole("heading", { level: 1, name: page.banner.title }),
).toBeInTheDocument();
expect(screen.getByText(page.banner.description)).toBeInTheDocument();
expect(
screen.getByRole("heading", { level: 2, name: "What is in it" }),
).toBeInTheDocument();
expect(
screen.getByRole("heading", { level: 2, name: "How the five meetings run" }),
).toBeInTheDocument();
expect(
screen.getByRole("heading", { level: 2, name: "Office hours" }),
).toBeInTheDocument();
expect(
screen.getByRole("link", { name: "Download the facilitator guide" }),
).toHaveAttribute(
"href",
"https://colorado-mutual-aid.notion.site/Workshop-facilitator-guide-40fb9b9e2d3b81b683c0ca15de007f2a",
);
expect(screen.getByRole("link", { name: "Open the board" })).toHaveAttribute(
"href",
"https://www.figma.com/board/gnQ55HnX7EtOV9nwlZcW1V?node-id=32-80",
);
expect(screen.getByRole("link", { name: "Create rule" })).toHaveAttribute(
"href",
"/create/informational",
);
expect(screen.getByRole("link", { name: "Ask an organizer" })).toHaveAttribute(
"href",
"/#ask-organizer",
);
expect(
screen.getByRole("link", { name: "Talk to a facilitator" }),
).toHaveAttribute("href", "/workshops#workshop-signup");
expect(screen.getByText(/22 February 2027/)).toBeInTheDocument();
});
});