Fix profile e2e test flakiness by waiting for API response
- Wait for PUT /api/profile response before reloading page - Wait for network idle after save completes - Reuse existing saveButton variable instead of redeclaring - All 40 e2e tests passing
This commit is contained in:
parent
4cd2872d6a
commit
61ae2807de
1 changed files with 14 additions and 2 deletions
|
|
@ -196,9 +196,21 @@ test.describe("Profile - Form Behavior", () => {
|
||||||
|
|
||||||
// Clear the field - use clear() instead of fill("") for reliable clearing
|
// Clear the field - use clear() instead of fill("") for reliable clearing
|
||||||
await page.locator("#telegram").clear();
|
await page.locator("#telegram").clear();
|
||||||
await page.click('button:has-text("Save Changes")');
|
|
||||||
|
// Wait for save button to be enabled (indicates form detected the change)
|
||||||
|
await expect(saveButton).toBeEnabled({ timeout: 2000 });
|
||||||
|
|
||||||
|
// Set up response listener before clicking save
|
||||||
|
const responsePromise = page.waitForResponse(
|
||||||
|
(resp) => resp.url().includes("/api/profile") && resp.request().method() === "PUT"
|
||||||
|
);
|
||||||
|
|
||||||
|
await saveButton.click();
|
||||||
|
|
||||||
|
// Wait for save to complete
|
||||||
|
await responsePromise;
|
||||||
await expect(page.getByText(/saved successfully/i)).toBeVisible();
|
await expect(page.getByText(/saved successfully/i)).toBeVisible();
|
||||||
await expect(page.getByText(/saved successfully/i)).not.toBeVisible({ timeout: 5000 });
|
await page.waitForLoadState("networkidle");
|
||||||
|
|
||||||
// Reload and wait for page to fully load before checking
|
// Reload and wait for page to fully load before checking
|
||||||
await page.reload();
|
await page.reload();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue