From 2238d7391e73cf08d6dad1ce33372ddb7f4d55ee Mon Sep 17 00:00:00 2001 From: Asher Date: Fri, 25 Jun 2021 12:05:13 -0500 Subject: [PATCH] Fix occasional logout failure It seems a dialog sometimes appears asking if you want to lose changes (even though we have no changes; it seems based on timers in some way). Playwright defaults to dismissing them (so quickly you might not even see them) so accepting instead fixes navigation to the logout page getting canceled. --- test/e2e/baseFixture.ts | 5 +++++ test/e2e/logout.test.ts | 6 ------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/test/e2e/baseFixture.ts b/test/e2e/baseFixture.ts index e67d09b8d..a18722ed4 100644 --- a/test/e2e/baseFixture.ts +++ b/test/e2e/baseFixture.ts @@ -56,6 +56,11 @@ export const test = base.extend({ authenticated: false, codeServer: undefined, // No default; should be provided through `test.use`. codeServerPage: async ({ authenticated, codeServer, page }, use) => { + // It's possible code-server might prevent navigation because of unsaved + // changes (seems to happen based on timing even if no changes have been + // made too). In these cases just accept. + page.on("dialog", (d) => d.accept()) + const codeServerPage = new CodeServerPage(codeServer, page) await codeServerPage.setup(authenticated) await use(codeServerPage) diff --git a/test/e2e/logout.test.ts b/test/e2e/logout.test.ts index 61a0615ac..052e438d0 100644 --- a/test/e2e/logout.test.ts +++ b/test/e2e/logout.test.ts @@ -10,12 +10,6 @@ describe("logout", true, () => { expect(await codeServerPage.page.isVisible(logoutButton)).toBe(true) await codeServerPage.page.hover(logoutButton) - // TODO(@jsjoeio) - // Look into how we're attaching the handlers for the logout feature - // We need to see how it's done upstream and add logging to the - // handlers themselves. - // They may be attached too slowly, hence why we need this timeout - await codeServerPage.page.waitForTimeout(2000) // Recommended by Playwright for async navigation // https://github.com/microsoft/playwright/issues/1987#issuecomment-620182151