From 61ae2807def62ba93d03a6a5fc0e98d8d659e851 Mon Sep 17 00:00:00 2001 From: counterweight Date: Fri, 26 Dec 2025 22:44:30 +0100 Subject: [PATCH] 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 --- frontend/e2e/profile.spec.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/frontend/e2e/profile.spec.ts b/frontend/e2e/profile.spec.ts index 4182945..a3d28b1 100644 --- a/frontend/e2e/profile.spec.ts +++ b/frontend/e2e/profile.spec.ts @@ -196,9 +196,21 @@ test.describe("Profile - Form Behavior", () => { // Clear the field - use clear() instead of fill("") for reliable clearing 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)).not.toBeVisible({ timeout: 5000 }); + await page.waitForLoadState("networkidle"); // Reload and wait for page to fully load before checking await page.reload();