Skip to content

Commit ca6f8c7

Browse files
committed
feat(e2e): add reloadUntilTestExtensionIsLoaded method
1 parent 8919848 commit ca6f8c7

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

test/e2e/models/CodeServer.ts

Lines changed: 26 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.page.reload()
306+
}
307+
308+
this.codeServer.logger.debug("Test extenion has loaded!")
309+
}
310+
285311
/**
286312
* Checks if the editor is visible
287313
*/

0 commit comments

Comments
 (0)