Skip to content

Commit 3e81dd8

Browse files
authored
Merge pull request #1498 from Kilo-Org/fix-settings-screenshot-flakes
Avoid flakey setting snapshot tests
2 parents 256b637 + d8bcbba commit 3e81dd8

File tree

3 files changed

+13
-33
lines changed

3 files changed

+13
-33
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ test.describe("E2E Chat Test", () => {
1010

1111
await configureApiKeyThroughUI(page)
1212
await waitForWebviewText(page, "Generate, refactor, and debug code with AI assistance")
13-
await takeScreenshot("ready-to-chat")
1413

15-
await sendMessage(page, "Fill in the blanks for this phrase: 'hello w_r_d'")
14+
await page.waitForTimeout(1000) // Let the page settle to avoid flakey screenshots
15+
await takeScreenshot("ready-to-chat")
1616

1717
// Don't take any more screenshots after the reponse starts-
1818
// llm responses aren't deterministic any capturing the reponse would cause screenshot flakes
19+
await sendMessage(page, "Fill in the blanks for this phrase: 'hello w_r_d'")
1920
await waitForWebviewText(page, "hello world", 30_000)
2021
})
2122
})

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export const test = base.extend<TestFixtures>({
5454
"--disable-updates",
5555
"--skip-welcome",
5656
"--skip-release-notes",
57+
"--skip-getting-started",
5758
"--disable-workspace-trust",
5859
"--disable-telemetry",
5960
"--disable-crash-reporter",

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

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,60 +5,38 @@ test.describe("Settings Screenshots", () => {
55
test("should take screenshots of all settings tabs", async ({ workbox: page, takeScreenshot }: TestFixtures) => {
66
await verifyExtensionInstalled(page)
77

8-
// Configure API to ensure settings are accessible
98
await upsertApiConfiguration(page)
109

11-
// Open the settings by clicking the settings button in the activity bar
12-
const settingsButton = page.locator('[aria-label*="Settings"], [title*="Settings"]').first()
13-
if (await settingsButton.isVisible()) {
14-
await settingsButton.click()
15-
} else {
16-
// Alternative: Use keyboard shortcut to open command palette and run settings command
17-
const modifier = process.platform === "darwin" ? "Meta" : "Control"
18-
await page.keyboard.press(`${modifier}+Shift+P`)
19-
await page.keyboard.type("Kilo Code: Settings")
20-
await page.keyboard.press("Enter")
21-
}
10+
// Open the settings
11+
page.locator('[aria-label*="Settings"], [title*="Settings"]').first().click()
12+
await page.mouse.move(0, 0) // Move the mouse to (0, 0) to avoid triggering the tooltip!
2213

23-
// Wait for the webview to load
2414
const webviewFrame = await findWebview(page)
25-
26-
// Wait for settings view to be visible by checking for the tablist role
2715
await expect(webviewFrame.locator('[role="tablist"]')).toBeVisible({ timeout: 10000 })
2816
console.log("✅ Settings view loaded")
2917

30-
// Wait for the tab list to be visible
3118
await expect(webviewFrame.locator('[data-testid="settings-tab-list"]')).toBeVisible()
3219
console.log("✅ Settings tab list visible")
3320

34-
// Find all tab buttons with role="tab"
3521
const tabButtons = webviewFrame.locator('[role="tab"]')
3622
const tabCount = await tabButtons.count()
3723
console.log(`✅ Found ${tabCount} settings tabs`)
3824

39-
// Take screenshot of each tab
40-
for (let i = 0; i < tabCount; i++) {
25+
// Take screenshot of each tab (except for the last two)
26+
// MCP settings page is flakey and the info page has the version which changes
27+
for (let i = 0; i < tabCount - 2; i++) {
4128
const tabButton = tabButtons.nth(i)
29+
await tabButton.click()
30+
await page.waitForTimeout(500)
4231

43-
// Get the tab name from the text content
4432
const tabText = await tabButton.textContent()
4533
const tabName = tabText?.trim() || `tab-${i}`
4634

47-
// Get the data-testid attribute to get the section ID
4835
const testId = await tabButton.getAttribute("data-testid")
4936
const sectionId = testId?.replace("tab-", "") || `section-${i}`
5037

5138
console.log(`📸 Taking screenshot of tab: ${tabName} (${sectionId})`)
52-
53-
// Click the tab to activate it
54-
await tabButton.click()
55-
56-
// Wait a moment for the content to load
57-
await page.waitForTimeout(500)
58-
59-
// Take screenshot with descriptive name
60-
const screenshotName = `settings-${sectionId}-${tabName.toLowerCase().replace(/\s+/g, "-")}`
61-
await takeScreenshot(screenshotName)
39+
await takeScreenshot(`settings-${sectionId}-${tabName.toLowerCase().replace(/\s+/g, "-")}`)
6240
}
6341

6442
console.log("✅ All settings tabs screenshots completed")

0 commit comments

Comments
 (0)