Keep draft notes off the How it works guide, link the conflict article, and print only the rule card.
This commit is contained in:
1 parent
453139c783
commit
95f7291c45
7 files changed
+136
-61
No files matched your search
@@ -19,7 +19,7 @@ describe("HowItWorksShareRow", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("copies wiki markdown and prints the page", async () => {
|
||||
it("copies wiki markdown and prints only the rule card", async () => {
|
||||
const print = vi.spyOn(window, "print").mockImplementation(() => {});
|
||||
|
||||
render(
|
||||
@@ -48,6 +48,11 @@ describe("HowItWorksShareRow", () => {
|
||||
|
||||
fireEvent.click(screen.getByRole("button", { name: "Print the card" }));
|
||||
expect(print).toHaveBeenCalled();
|
||||
const printStyle = document.getElementById("how-it-works-card-print");
|
||||
expect(printStyle?.textContent).toContain("#how-it-works-rule-card");
|
||||
expect(printStyle?.textContent).toContain("visibility: hidden");
|
||||
window.dispatchEvent(new Event("afterprint"));
|
||||
expect(document.getElementById("how-it-works-card-print")).toBeNull();
|
||||
print.mockRestore();
|
||||
});
|
||||
});
|
||||
@@ -3,7 +3,10 @@ import { screen, waitFor } from "@testing-library/react";
|
||||
import { renderWithProviders as render } from "../utils/test-utils";
|
||||
import HowItWorksPage from "../../app/(marketing)/how-it-works/page";
|
||||
import messages from "../../messages/en/index";
|
||||
import { howItWorksReadMinutes } from "../../lib/howItWorksGuide";
|
||||
import {
|
||||
formatHowItWorksByline,
|
||||
howItWorksReadMinutes,
|
||||
} from "../../lib/howItWorksGuide";
|
||||
|
||||
vi.mock("next/dynamic", () => ({
|
||||
default: (importFn) => {
|
||||
@@ -78,10 +81,20 @@ describe("HowItWorksPage", () => {
|
||||
).toHaveAttribute("href", "#before-you-start");
|
||||
expect(
|
||||
screen.getByText(
|
||||
`By ${page.banner.author}. 18 February 2027. ${howItWorksReadMinutes(page)} minute read.`,
|
||||
formatHowItWorksByline(page, howItWorksReadMinutes(page)).trim(),
|
||||
{ exact: false },
|
||||
),
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByRole("link", { name: "Resolving Active Conflicts" }),
|
||||
).toHaveAttribute("href", "/blog/resolving-active-conflicts");
|
||||
expect(screen.queryByText(/\[Confirm how long/)).not.toBeInTheDocument();
|
||||
expect(
|
||||
screen.queryByText(/Dated entries from groups/),
|
||||
).not.toBeInTheDocument();
|
||||
expect(
|
||||
screen.queryByRole("heading", { name: "Updates from groups" }),
|
||||
).not.toBeInTheDocument();
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByTestId("related-articles")).toBeInTheDocument();
|
||||
|
||||
@@ -15,13 +15,19 @@ describe("howItWorksGuide", () => {
|
||||
expect(formatHowItWorksDate(page.banner.date)).toBe("18 February 2027");
|
||||
const minutes = howItWorksReadMinutes(page);
|
||||
expect(minutes).toBeGreaterThanOrEqual(10);
|
||||
expect(formatHowItWorksByline(page, minutes)).toBe(
|
||||
`By CommunityRule Creative Team. 18 February 2027. ${minutes} minute read. `,
|
||||
expect(formatHowItWorksByline(page, 1)).toBe(
|
||||
"By CommunityRule Creative Team. 18 February 2027. 1 minute read. ",
|
||||
);
|
||||
expect(collectHowItWorksGuideText(page)).toContain(
|
||||
expect(formatHowItWorksByline(page, minutes)).toBe(
|
||||
`By CommunityRule Creative Team. 18 February 2027. ${minutes} minutes read. `,
|
||||
);
|
||||
const guideText = collectHowItWorksGuideText(page);
|
||||
expect(guideText).toContain(
|
||||
"A Rule is a short document your community can read aloud in a few minutes.",
|
||||
);
|
||||
expect(collectHowItWorksGuideText(page)).not.toContain("](/kit)");
|
||||
expect(guideText).toContain("Resolving Active Conflicts");
|
||||
expect(guideText).not.toContain("](/kit)");
|
||||
expect(guideText).not.toMatch(/\[[^\]]*\]/);
|
||||
});
|
||||
|
||||
it("builds wiki markdown from the title, description and URL", () => {
|
||||
|
||||
Reference in new issue
Block a user