Skip to content

Commit 8352a22

Browse files
authored
fix(testing): reduce flakiness in extension e2e tests (#5481)
1 parent 33ee184 commit 8352a22

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

test/e2e/extensions.test.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ function runTestExtensionTests() {
88
test("should have access to VSCODE_PROXY_URI", async ({ codeServerPage }) => {
99
const address = await getMaybeProxiedCodeServer(codeServerPage)
1010

11+
await codeServerPage.waitForTestExtensionLoaded()
1112
await codeServerPage.executeCommandViaMenus("code-server: Get proxy URI")
1213

13-
const text = await codeServerPage.page.locator(".notification-list-item-message").textContent()
14+
await codeServerPage.page.waitForSelector("text=proxyUri", { timeout: 3000 })
15+
const text = await codeServerPage.page.locator("text=proxyUri").first().textContent()
1416
// Remove end slash in address
1517
const normalizedAddress = address.replace(/\/+$/, "")
16-
expect(text).toBe(`${normalizedAddress}/proxy/{{port}}`)
18+
expect(text).toBe(`Info: proxyUri: ${normalizedAddress}/proxy/{{port}}`)
1719
})
1820
}
1921

test/e2e/extensions/test-extension/extension.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import * as vscode from "vscode"
22

33
export function activate(context: vscode.ExtensionContext) {
4+
vscode.window.showInformationMessage("test extension loaded")
45
context.subscriptions.push(
56
vscode.commands.registerCommand("codeServerTest.proxyUri", () => {
67
if (process.env.VSCODE_PROXY_URI) {
7-
vscode.window.showInformationMessage(process.env.VSCODE_PROXY_URI)
8+
vscode.window.showInformationMessage(`proxyUri: ${process.env.VSCODE_PROXY_URI}`)
89
} else {
910
vscode.window.showErrorMessage("No proxy URI was set")
1011
}

test/e2e/extensions/test-extension/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"version": "0.0.1",
55
"publisher": "coder",
66
"activationEvents": [
7-
"onCommand:codeServerTest.proxyUri"
7+
"onStartupFinished"
88
],
99
"engines": {
1010
"vscode": "^1.56.0"

test/e2e/models/CodeServer.ts

+10
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,16 @@ export class CodeServerPage {
296296
return visible
297297
}
298298

299+
/**
300+
* Checks if the test extension loaded
301+
*/
302+
async waitForTestExtensionLoaded(): Promise<void> {
303+
const selector = "text=test extension loaded"
304+
this.codeServer.logger.debug("Waiting for test extension to load...")
305+
306+
await this.page.waitForSelector(selector)
307+
}
308+
299309
/**
300310
* Focuses the integrated terminal by navigating through the command palette.
301311
*

0 commit comments

Comments
 (0)