Files
Anirban SinghaandBandhan Majumder 0d164da8dd fix: implement missing password validation (#27634)
* fix: validate password presence and requirements

* chore: add error code for invalid passwords

* chore: avoid trimming password

* chore: add test for password validation

* fix: update password to delete user

* fix: create user password following protocol

* test: simplify deleteMeHandler password validation tests

* fix: address coderabbit

* fix: modify login params for failing tests

* fix: failing e2e tests

---------

Co-authored-by: Bandhan Majumder <133476557+bandhan-majumder@users.noreply.github.com>
2026-06-22 10:37:09 +05:30

36 lines
1.1 KiB
TypeScript

import { expect } from "@playwright/test";
import { test } from "../lib/fixtures";
test.afterEach(({ users }) => users.deleteAll());
test("Can delete user account", async ({ page, users }) => {
const deletionPassword = "Deleteme1";
const user = await users.create({
username: "delete-me",
password: deletionPassword,
});
await user.apiLogin(undefined, deletionPassword);
await page.goto(`/settings/my-account/profile`);
await page.waitForLoadState("networkidle");
await page.waitForSelector("[data-testid=dashboard-shell]");
const deleteAccountButton = page.locator(
'[data-testid="delete-account"]:visible'
);
await expect(deleteAccountButton).toBeVisible({ timeout: 30_000 });
await deleteAccountButton.click();
expect(user.username).toBeTruthy();
const $passwordField = page.locator("[data-testid=password]");
await $passwordField.fill(deletionPassword);
await Promise.all([
page.waitForURL((url) => url.pathname === "/auth/logout"),
page.click("text=Delete my account"),
]);
await expect(page.locator(`[id="modal-title"]`)).toHaveText("You've been logged out");
});