From fb636e4152f8d4615f87327ab30f8b4aed98cbec Mon Sep 17 00:00:00 2001 From: Marcel Date: Tue, 31 Mar 2026 17:13:09 +0200 Subject: [PATCH] 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 --- frontend/e2e/password-reset.spec.ts | 3 +-- frontend/src/routes/profile/PasswordChangeForm.svelte | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/e2e/password-reset.spec.ts b/frontend/e2e/password-reset.spec.ts index d2dd5366..fc864820 100644 --- a/frontend/e2e/password-reset.spec.ts +++ b/frontend/e2e/password-reset.spec.ts @@ -80,8 +80,7 @@ test.describe('Password reset', () => { await page.locator('input[name="currentPassword"]').fill(newPassword); await page.locator('input[name="newPassword"]').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.locator('button[type="submit"]').last().click(); + await page.getByTestId('submit-password').click(); // After changing password, auth_token is stale → redirect to login await expect(page).toHaveURL(/\/login/); diff --git a/frontend/src/routes/profile/PasswordChangeForm.svelte b/frontend/src/routes/profile/PasswordChangeForm.svelte index 32145da3..6c7e0b42 100644 --- a/frontend/src/routes/profile/PasswordChangeForm.svelte +++ b/frontend/src/routes/profile/PasswordChangeForm.svelte @@ -70,6 +70,7 @@ let {