Skip to content

Commit 459a38e

Browse files
authored
fix(e2e): fix flaky settings screenshots by waiting for tooltips to dismiss (#3276)
* fix(e2e): fix flaky settings screenshots by waiting for tooltips to dismiss Add waitForTooltipsToDismiss helper function to ensure tooltips are fully dismissed before taking screenshots, preventing inconsistent visual states in settings tests. * 'chore: WIP' * fix(e2e): increase wait timeout to fix flaky chat test Increase the page wait timeout from 1000ms to 3000ms in the chat E2E test to reduce flakiness and improve test reliability.
1 parent 4fb123a commit 459a38e

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

apps/playwright-e2e/helpers/webview-helpers.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,18 @@ export async function clickSaveSettingsButton(webviewFrame: FrameLocator): Promi
100100
}
101101
}
102102

103+
/**
104+
* Waits for all tooltips to be dismissed before proceeding.
105+
* This is necessary when tooltips appear after clicking elements and need to animate away
106+
* before taking screenshots to avoid inconsistent visual states.
107+
*/
108+
export async function waitForTooltipsToDismiss(webviewFrame: FrameLocator): Promise<void> {
109+
const tooltipContent = webviewFrame.locator('[data-slot="tooltip-content"]')
110+
await tooltipContent.waitFor({ state: "detached", timeout: 3000 }).catch(() => {
111+
// If timeout, tooltips should be gone by now anyway
112+
})
113+
}
114+
103115
/**
104116
* Freezes all GIFs on the page by converting them to static PNG images.
105117
* Also sets up a MutationObserver to handle dynamically added GIFs.

apps/playwright-e2e/tests/chat.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ test.describe("E2E Chat Test", () => {
1717
await waitForWebviewText(page, "Generate, refactor, and debug code with AI assistance")
1818

1919
await (await getChatInput(page)).focus()
20-
await page.waitForTimeout(1000) // Let the page settle to avoid flakes
20+
await page.waitForTimeout(3000) // Let the page settle to avoid flakes
2121
await takeScreenshot("ready-to-chat")
2222

2323
// Don't take any more screenshots after the reponse starts-

apps/playwright-e2e/tests/settings.test.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { test, expect, type TestFixtures } from "./playwright-base-test"
2-
import { findWebview, upsertApiConfiguration, verifyExtensionInstalled, clickSaveSettingsButton } from "../helpers"
2+
import {
3+
findWebview,
4+
upsertApiConfiguration,
5+
verifyExtensionInstalled,
6+
clickSaveSettingsButton,
7+
waitForTooltipsToDismiss,
8+
} from "../helpers"
39

410
test.describe("Settings", () => {
511
test("screenshots", async ({ workbox: page, takeScreenshot }: TestFixtures) => {
@@ -8,9 +14,10 @@ test.describe("Settings", () => {
814

915
// Open the settings then move the mouse to avoid triggering the tooltip
1016
const webviewFrame = await findWebview(page)
11-
page.locator('[aria-label*="Settings"], [title*="Settings"]').first().click()
12-
await clickSaveSettingsButton(webviewFrame)
17+
await page.locator('[aria-label*="Settings"], [title*="Settings"]').first().click()
18+
await page.mouse.move(0, 0) // Move cursor to top-left corner to avoid triggering hover states
1319

20+
await clickSaveSettingsButton(webviewFrame)
1421
await expect(webviewFrame.locator('[role="tablist"]')).toBeVisible({ timeout: 10000 })
1522
console.log("✅ Settings view loaded")
1623

@@ -35,6 +42,7 @@ test.describe("Settings", () => {
3542
const sectionId = testId?.replace("tab-", "") || `section-${i}`
3643

3744
await clickSaveSettingsButton(webviewFrame) // To avoid flakey screenshots
45+
await waitForTooltipsToDismiss(webviewFrame) // Wait for tooltips to dismiss before screenshot
3846
await takeScreenshot(`${i}-settings-${sectionId}-${tabName.toLowerCase().replace(/\s+/g, "-")}`)
3947
}
4048

0 commit comments

Comments
 (0)