feat(account): add deletion lifecycle
CI and Deploy / test (pull_request) Successful in 5m18s
CI and Deploy / deploy (pull_request) Has been skipped

This commit is contained in:
cesnimda
2026-08-15 19:03:54 +02:00
parent 1ec9dd037e
commit 842e793f69
28 changed files with 4418 additions and 129 deletions
@@ -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" },
}));
});