RuleTemplate seed and create flow
This commit is contained in:
@@ -94,9 +94,7 @@ describe("Page Flow Integration", () => {
|
||||
).toBeInTheDocument();
|
||||
|
||||
// Rule Stack section
|
||||
expect(
|
||||
screen.getByRole("heading", { name: "Consensus clusters" }),
|
||||
).toBeInTheDocument();
|
||||
expect(screen.getByRole("heading", { name: "Circles" })).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByRole("heading", { name: "Elected Board" }),
|
||||
).toBeInTheDocument();
|
||||
@@ -177,17 +175,20 @@ describe("Page Flow Integration", () => {
|
||||
expect(sectionNumbers.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
test("rule stack displays all four governance types", async () => {
|
||||
test("rule stack shows four featured templates and link to full catalog", async () => {
|
||||
render(<Page />);
|
||||
|
||||
// Wait for dynamically imported RuleStack component
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText("Consensus clusters")).toBeInTheDocument();
|
||||
expect(screen.getByText("Circles")).toBeInTheDocument();
|
||||
});
|
||||
expect(screen.queryByText("Solidarity Network")).not.toBeInTheDocument();
|
||||
expect(screen.getByText("Elected Board")).toBeInTheDocument();
|
||||
expect(screen.getByText("Consensus")).toBeInTheDocument();
|
||||
expect(screen.getByText("Petition")).toBeInTheDocument();
|
||||
|
||||
const seeAll = screen.getByRole("link", { name: "See all templates" });
|
||||
expect(seeAll).toHaveAttribute("href", "/templates");
|
||||
|
||||
// Check that create rule button is present
|
||||
const createButton = screen.getByRole("button", {
|
||||
name: "Create CommunityRule",
|
||||
@@ -253,7 +254,7 @@ describe("Page Flow Integration", () => {
|
||||
expect(screen.getByText("How CommunityRule works")).toBeInTheDocument();
|
||||
|
||||
// 3. Rule types show different governance options
|
||||
expect(screen.getByText("Consensus clusters")).toBeInTheDocument();
|
||||
expect(screen.getByText("Circles")).toBeInTheDocument();
|
||||
|
||||
// 4. Features highlight benefits
|
||||
expect(
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
import {
|
||||
renderWithProviders as render,
|
||||
screen,
|
||||
cleanup,
|
||||
} from "../utils/test-utils";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { describe, test, expect, afterEach, beforeEach } from "vitest";
|
||||
import TemplatesPage from "../../app/(marketing)/templates/page";
|
||||
import { testRouter } from "../mocks/navigation";
|
||||
import { GOVERNANCE_TEMPLATE_CATALOG } from "../../lib/templates/governanceTemplateCatalog";
|
||||
|
||||
beforeEach(() => {
|
||||
testRouter.push.mockClear();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
});
|
||||
|
||||
describe("Templates page (/templates)", () => {
|
||||
test("renders title, intro, and full catalog", () => {
|
||||
render(<TemplatesPage />);
|
||||
|
||||
expect(
|
||||
screen.getByRole("heading", { name: "Templates", level: 1 }),
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByText(/mutual aid and open source communities/i),
|
||||
).toBeInTheDocument();
|
||||
|
||||
for (const entry of GOVERNANCE_TEMPLATE_CATALOG) {
|
||||
expect(screen.getByText(entry.title)).toBeInTheDocument();
|
||||
}
|
||||
});
|
||||
|
||||
test("each template card navigates to review flow for its slug", async () => {
|
||||
const user = userEvent.setup();
|
||||
render(<TemplatesPage />);
|
||||
|
||||
const consensusCard = screen.getByText("Consensus").closest("div");
|
||||
await user.click(consensusCard);
|
||||
expect(testRouter.push).toHaveBeenCalledWith(
|
||||
"/create/review-template/consensus",
|
||||
);
|
||||
|
||||
testRouter.push.mockClear();
|
||||
const solidarity = screen.getByText("Solidarity Network").closest("div");
|
||||
await user.click(solidarity);
|
||||
expect(testRouter.push).toHaveBeenCalledWith(
|
||||
"/create/review-template/solidarity-network",
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -70,7 +70,7 @@ describe("User Journey Integration", () => {
|
||||
|
||||
// Wait for dynamically imported RuleStack component
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText("Consensus clusters")).toBeInTheDocument();
|
||||
expect(screen.getByText("Circles")).toBeInTheDocument();
|
||||
});
|
||||
expect(screen.getByText("Elected Board")).toBeInTheDocument();
|
||||
expect(screen.getByText("Consensus")).toBeInTheDocument();
|
||||
@@ -250,7 +250,7 @@ describe("User Journey Integration", () => {
|
||||
() => {
|
||||
// Check for any of the governance card titles
|
||||
const hasGovernanceContent =
|
||||
screen.queryByText(/Consensus clusters/i) ||
|
||||
screen.queryByText(/Circles/i) ||
|
||||
screen.queryByText(/Elected Board/i) ||
|
||||
screen.queryByText(/Petition/i);
|
||||
expect(hasGovernanceContent).toBeTruthy();
|
||||
|
||||
Reference in New Issue
Block a user