From 7f2b1dcd22a886319e5dd40424c248560d9b75fc Mon Sep 17 00:00:00 2001 From: Teffen Ellis Date: Wed, 15 Sep 2021 13:55:21 -0400 Subject: [PATCH] Fix outdated selector. Add debug info. --- test/e2e/browser.test.ts | 2 +- test/e2e/models/CodeServer.ts | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/test/e2e/browser.test.ts b/test/e2e/browser.test.ts index 3c3b2411..fab3ac8a 100644 --- a/test/e2e/browser.test.ts +++ b/test/e2e/browser.test.ts @@ -8,7 +8,7 @@ describe("browser", true, () => { firefox: "Firefox", webkit: "Safari", } - const userAgent = await codeServerPage.page.evaluate("navigator.userAgent") + const userAgent = await codeServerPage.page.evaluate(() => navigator.userAgent) expect(userAgent).toContain(displayNames[browserName]) }) diff --git a/test/e2e/models/CodeServer.ts b/test/e2e/models/CodeServer.ts index 8ef160fb..3acb0cd7 100644 --- a/test/e2e/models/CodeServer.ts +++ b/test/e2e/models/CodeServer.ts @@ -177,6 +177,8 @@ export class CodeServerPage { * Reload until both checks pass */ async reloadUntilEditorIsReady() { + this.codeServer.logger.debug("Waiting for editor to be ready...") + const editorIsVisible = await this.isEditorVisible() const editorIsConnected = await this.isConnected() let reloadCount = 0 @@ -199,25 +201,36 @@ export class CodeServerPage { } await this.page.reload() } + + this.codeServer.logger.debug("Editor is ready!") } /** * Checks if the editor is visible */ async isEditorVisible() { + this.codeServer.logger.debug("Waiting for editor to be visible...") // Make sure the editor actually loaded await this.page.waitForSelector(this.editorSelector) - return await this.page.isVisible(this.editorSelector) + const visible = await this.page.isVisible(this.editorSelector) + + this.codeServer.logger.debug(`Editor is ${visible ? "not visible" : "visible"}!`) + + return visible } /** * Checks if the editor is visible */ async isConnected() { + this.codeServer.logger.debug("Waiting for network idle...") + await this.page.waitForLoadState("networkidle") const host = new URL(await this.codeServer.address()).host - const hostSelector = `[title="Editing on ${host}"]` + // NOTE: This seems to be pretty brittle between version changes. + const hostSelector = `[aria-label="remote ${host}"]` + this.codeServer.logger.debug(`Waiting selector: ${hostSelector}`) await this.page.waitForSelector(hostSelector) return await this.page.isVisible(hostSelector)