Rebuild Share and Delete Account from the privacy designs.
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.
This commit is contained in:
1 parent
5cbda35e32
commit
b6795c1f18
28 files changed
+1467
-377
No files matched your search
@@ -0,0 +1,53 @@
|
||||
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);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user