Show invited people the Rule, let them copy its cards for their community, and replace an expired invitation link.
This commit is contained in:
1 parent
727a92a9ac
commit
3c984e00c5
37 files changed
+1962
-19
No files matched your search
@@ -0,0 +1,63 @@
|
||||
import { describe, expect, it, vi, beforeEach } from "vitest";
|
||||
import { renderWithProviders as render, screen } from "../utils/test-utils";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
import { ExpiredInviteScreen } from "../../app/(app)/invite/_components/ExpiredInviteScreen";
|
||||
|
||||
const { navMock, resendMock } = vi.hoisted(() => ({
|
||||
navMock: {
|
||||
searchParams: new URLSearchParams("token=abcdefghijkl"),
|
||||
push: vi.fn(),
|
||||
},
|
||||
resendMock: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("next/navigation", () => ({
|
||||
useRouter: () => ({
|
||||
push: navMock.push,
|
||||
replace: vi.fn(),
|
||||
prefetch: vi.fn(),
|
||||
refresh: vi.fn(),
|
||||
back: vi.fn(),
|
||||
forward: vi.fn(),
|
||||
}),
|
||||
useSearchParams: () => navMock.searchParams,
|
||||
usePathname: () => "/invite/expired",
|
||||
}));
|
||||
|
||||
vi.mock("../../lib/create/api", () => ({
|
||||
resendExpiredStakeholderInvite: (...args: unknown[]) => resendMock(...args),
|
||||
}));
|
||||
|
||||
describe("ExpiredInviteScreen", () => {
|
||||
beforeEach(() => {
|
||||
navMock.searchParams = new URLSearchParams("token=abcdefghijkl");
|
||||
navMock.push.mockReset();
|
||||
resendMock.mockReset();
|
||||
resendMock.mockResolvedValue({ ok: true });
|
||||
});
|
||||
|
||||
it("asks for the invited email and sends a new link", async () => {
|
||||
const user = userEvent.setup();
|
||||
render(<ExpiredInviteScreen />);
|
||||
|
||||
expect(
|
||||
screen.getByRole("heading", { name: "This link has expired" }),
|
||||
).toBeInTheDocument();
|
||||
await user.type(
|
||||
screen.getByLabelText("Email address"),
|
||||
"inv@example.com",
|
||||
);
|
||||
await user.click(
|
||||
screen.getByRole("button", { name: "Send a new link" }),
|
||||
);
|
||||
|
||||
expect(resendMock).toHaveBeenCalledWith(
|
||||
"abcdefghijkl",
|
||||
"inv@example.com",
|
||||
);
|
||||
expect(
|
||||
await screen.findByRole("heading", { name: "Check your email" }),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user