From 3126901d6e1273579f53827bda62314ac08ad721 Mon Sep 17 00:00:00 2001 From: Talisson Costa Date: Mon, 2 Mar 2026 17:19:45 -0300 Subject: [PATCH] refactor(e2e): Replace arbitrary waits with state-based waiting in flag tests Replace fixed 500ms timeouts with `waitForElementVisible('#try-it-results')` to wait for the actual loading state to complete. This approach: - Eliminates race conditions on slow CI runners - Runs faster when API responds quickly (no artificial 500ms delays) - More semantically correct (waits for the element we actually need) - Consistent with E2E best practices already used elsewhere The #try-it-results element only receives its ID when the TryIt component finishes loading (isLoading: false), making it the perfect indicator to wait for rather than guessing arbitrary timeout values. Related: #6827 (increased timeouts from 500ms to 2000ms/1500ms) This PR provides a better alternative to arbitrary timeout increases. --- frontend/e2e/tests/flag-tests.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/frontend/e2e/tests/flag-tests.ts b/frontend/e2e/tests/flag-tests.ts index 09c61eec818e..3b7108f5332a 100644 --- a/frontend/e2e/tests/flag-tests.ts +++ b/frontend/e2e/tests/flag-tests.ts @@ -48,7 +48,7 @@ export default async function () { log('Try it') await t.wait(2000) await click('#try-it-btn') - await t.wait(500) + await waitForElementVisible('#try-it-results') let json = await parseTryItResults() await t.expect(json.header_size.value).eql('big') await t.expect(json.mv_flag.value).eql('big') @@ -58,9 +58,8 @@ export default async function () { await editRemoteConfig(1,12) log('Try it again') - await t.wait(500) await click('#try-it-btn') - await t.wait(500) + await waitForElementVisible('#try-it-results') json = await parseTryItResults() await t.expect(json.header_size.value).eql(12) @@ -68,9 +67,8 @@ export default async function () { await editRemoteConfig(1,false) log('Try it again 2') - await t.wait(500) await click('#try-it-btn') - await t.wait(500) + await waitForElementVisible('#try-it-results') json = await parseTryItResults() await t.expect(json.header_size.value).eql(false)