Skip to content

Commit d8ab7d7

Browse files
committed
feat(e2e): add test extension methods to model
This adds two new methods to assist with testing the test extension in our e2e tests, namely these two methods: - isTestExtensionLoaded - reloadUntilTestExtensionIsLoaded Sometimes code-server loads without loading the test extension. These methods allow us to reload and guarantee it's loaded.
1 parent b14f9e0 commit d8ab7d7

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

test/e2e/models/CodeServer.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,32 @@ export class CodeServerPage {
282282
this.codeServer.logger.debug("Editor is ready!")
283283
}
284284

285+
/**
286+
* Checks if the test extension has loaded
287+
*
288+
* Reload until both checks pass
289+
*/
290+
async reloadUntilTestExtensionIsLoaded() {
291+
this.codeServer.logger.debug("Waiting for test extenion to load...")
292+
293+
const extensionIsLoaded = await this.isTestExtensionLoaded()
294+
let reloadCount = 0
295+
296+
while (!extensionIsLoaded) {
297+
await this.page.waitForLoadState("load")
298+
// Give it an extra second just in case it's feeling extra slow
299+
await this.page.waitForTimeout(1000)
300+
reloadCount += 1
301+
if (await this.isTestExtensionLoaded()) {
302+
this.codeServer.logger.debug(`test extension loaded after ${reloadCount} reloads`)
303+
break
304+
}
305+
await this.reloadUntilEditorIsReady()
306+
}
307+
308+
this.codeServer.logger.debug("Test extenion has loaded!")
309+
}
310+
285311
/**
286312
* Checks if the editor is visible
287313
*/
@@ -296,6 +322,21 @@ export class CodeServerPage {
296322
return visible
297323
}
298324

325+
/**
326+
* Checks if the test extension loaded
327+
*/
328+
async isTestExtensionLoaded() {
329+
const selector = "text=test extension loaded"
330+
this.codeServer.logger.debug("Waiting for test extension to load...")
331+
332+
await this.page.waitForLoadState("load")
333+
const loaded = await this.page.isVisible(selector)
334+
335+
this.codeServer.logger.debug(`Test extension has ${loaded ? "" : "not"} loaded`)
336+
337+
return loaded
338+
}
339+
299340
/**
300341
* Focuses the integrated terminal by navigating through the command palette.
301342
*

0 commit comments

Comments
 (0)