Share asks the person who holds the pen to confirm their community agreed before a link turns on, and deleting an account lists each owned Rule with PDF and RULE.md export. Case-study Share copies the page link instead of opening the privacy modal, and the sign-in banner stays below the header so Share remains clickable.
54 lines
1.8 KiB
TypeScript
54 lines
1.8 KiB
TypeScript
import { describe, it, expect, vi } from "vitest";
|
||
import userEvent from "@testing-library/user-event";
|
||
import { renderWithProviders as render, screen } from "../../utils/test-utils";
|
||
import "@testing-library/jest-dom/vitest";
|
||
import DeleteAccount from "../../../app/components/modals/DeleteAccount";
|
||
|
||
describe("DeleteAccount modal", () => {
|
||
it("does not render dialog when closed", () => {
|
||
render(
|
||
<DeleteAccount
|
||
isOpen={false}
|
||
onClose={vi.fn()}
|
||
onConfirm={vi.fn()}
|
||
rules={[]}
|
||
onExportPdf={vi.fn()}
|
||
onExportMarkdown={vi.fn()}
|
||
/>,
|
||
);
|
||
expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
|
||
});
|
||
|
||
it("keeps Delete account disabled until the box is ticked", async () => {
|
||
const user = userEvent.setup();
|
||
const onConfirm = vi.fn();
|
||
const onExportPdf = vi.fn();
|
||
render(
|
||
<DeleteAccount
|
||
isOpen
|
||
onClose={vi.fn()}
|
||
onConfirm={onConfirm}
|
||
rules={[{ id: "rule-1", title: "Juniper Street Food Share" }]}
|
||
onExportPdf={onExportPdf}
|
||
onExportMarkdown={vi.fn()}
|
||
/>,
|
||
);
|
||
expect(
|
||
screen.getByRole("heading", { level: 1, name: "Delete your account" }),
|
||
).toBeInTheDocument();
|
||
expect(screen.getByText("Juniper Street Food Share")).toBeInTheDocument();
|
||
const confirm = screen.getByRole("button", { name: "Delete account" });
|
||
expect(confirm).toBeDisabled();
|
||
await user.click(screen.getByRole("button", { name: "PDF" }));
|
||
expect(onExportPdf).toHaveBeenCalledWith("rule-1");
|
||
await user.click(
|
||
screen.getByRole("checkbox", {
|
||
name: "I understand this can’t be undone",
|
||
}),
|
||
);
|
||
expect(confirm).toBeEnabled();
|
||
await user.click(confirm);
|
||
expect(onConfirm).toHaveBeenCalledTimes(1);
|
||
});
|
||
});
|