fix(e2e): replace fragile .last() selector with data-testid on password form submit
The password-reset E2E test was using button[type="submit"].last() to target the password change button on the profile page. The profile page has two submit buttons with identical text, so .last() is layout-order-dependent and breaks if the form order ever changes. Add data-testid="submit-password" to PasswordChangeForm and use getByTestId() in the test. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -80,8 +80,7 @@ test.describe('Password reset', () => {
|
|||||||
await page.locator('input[name="currentPassword"]').fill(newPassword);
|
await page.locator('input[name="currentPassword"]').fill(newPassword);
|
||||||
await page.locator('input[name="newPassword"]').fill(originalPassword);
|
await page.locator('input[name="newPassword"]').fill(originalPassword);
|
||||||
await page.locator('input[name="confirmPassword"]').fill(originalPassword);
|
await page.locator('input[name="confirmPassword"]').fill(originalPassword);
|
||||||
// Profile page has two "Speichern" buttons — the password form is the last one
|
await page.getByTestId('submit-password').click();
|
||||||
await page.locator('button[type="submit"]').last().click();
|
|
||||||
// After changing password, auth_token is stale → redirect to login
|
// After changing password, auth_token is stale → redirect to login
|
||||||
await expect(page).toHaveURL(/\/login/);
|
await expect(page).toHaveURL(/\/login/);
|
||||||
|
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ let {
|
|||||||
|
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
|
data-testid="submit-password"
|
||||||
class="mt-5 rounded-sm bg-primary px-5 py-2 font-sans text-xs font-bold tracking-widest text-primary-fg uppercase transition-opacity hover:opacity-80"
|
class="mt-5 rounded-sm bg-primary px-5 py-2 font-sans text-xs font-bold tracking-widest text-primary-fg uppercase transition-opacity hover:opacity-80"
|
||||||
>
|
>
|
||||||
{m.btn_save()}
|
{m.btn_save()}
|
||||||
|
|||||||
Reference in New Issue
Block a user