Skip to content

Commit 16a0fa1

Browse files
committed
fix(test): use response interception for wrong-password test reliability
Replace unreliable waitForLoadState('networkidle') with explicit waitForResponse() in the "should reject change with wrong current password" test. Since the form uses fetch() (AJAX), networkidle can resolve before the DOM is updated from the response, causing the #globalMessage visibility check to fail intermittently. The new approach: - Intercepts the server response to /user/updatePassword - Asserts the server correctly returns success=false - Waits for the #globalMessage div to become visible
1 parent c016718 commit 16a0fa1

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

playwright/tests/profile/change-password.spec.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,24 @@ test.describe('Change Password', () => {
9292
await page.waitForLoadState('networkidle');
9393

9494
// Try to change password with wrong current password
95+
// Listen for the server response to verify error handling
96+
const responsePromise = page.waitForResponse(
97+
response => response.url().includes('/user/updatePassword') && response.request().method() === 'POST'
98+
);
99+
95100
await updatePasswordPage.changePassword('wrongCurrentPassword123!', 'NewTest@Pass123!');
96-
await page.waitForLoadState('networkidle');
97101

98-
// Should show error or stay on page
102+
// Wait for the server response
103+
const response = await responsePromise;
104+
const responseBody = await response.json();
105+
106+
// Server should indicate failure
107+
expect(responseBody.success).toBe(false);
108+
109+
// Wait for the error message to appear in the DOM
110+
await updatePasswordPage.waitForMessage(5000);
111+
112+
// Should show error
99113
const isError = await updatePasswordPage.isErrorMessage() ||
100114
await updatePasswordPage.hasCurrentPasswordError();
101115
expect(isError).toBe(true);

0 commit comments

Comments
 (0)