feat(account): add deletion lifecycle
This commit is contained in:
@@ -21,6 +21,7 @@ const mockedApi = api as jest.Mocked<typeof api>;
|
||||
function renderPage(users: unknown[]) {
|
||||
mockedApi.get.mockResolvedValue({ data: users } as any);
|
||||
mockedApi.put.mockResolvedValue({ data: null } as any);
|
||||
mockedApi.delete.mockResolvedValue({ data: null } as any);
|
||||
render(
|
||||
<CssVarsProvider theme={getTheme("light") as any} defaultMode="light">
|
||||
<I18nProvider>
|
||||
@@ -82,3 +83,14 @@ test("disables demotion and deletion for the final administrator", async () => {
|
||||
expect(await screen.findByRole("button", { name: "Remove admin" })).toBeDisabled();
|
||||
expect(screen.getByRole("button", { name: "Delete" })).toBeDisabled();
|
||||
});
|
||||
|
||||
test("sends the exact account email after confirming deletion", async () => {
|
||||
renderPage([{ id: "other", email: "other@example.com", userName: "other", roles: [], emailConfirmed: true, isCurrentUser: false, canRemoveAdmin: true }]);
|
||||
|
||||
fireEvent.click(await screen.findByRole("button", { name: "Delete" }));
|
||||
fireEvent.click(within(await screen.findByRole("dialog")).getByRole("button", { name: "Delete" }));
|
||||
|
||||
await waitFor(() => expect(mockedApi.delete).toHaveBeenCalledWith("/users/other", {
|
||||
headers: { "X-Confirm-Account-Deletion": "other@example.com" },
|
||||
}));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user