Skip to content

Commit 2238d73

Browse files
committed
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.
1 parent 43c6ffc commit 2238d73

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

test/e2e/baseFixture.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ export const test = base.extend<TestFixtures>({
5656
authenticated: false,
5757
codeServer: undefined, // No default; should be provided through `test.use`.
5858
codeServerPage: async ({ authenticated, codeServer, page }, use) => {
59+
// It's possible code-server might prevent navigation because of unsaved
60+
// changes (seems to happen based on timing even if no changes have been
61+
// made too). In these cases just accept.
62+
page.on("dialog", (d) => d.accept())
63+
5964
const codeServerPage = new CodeServerPage(codeServer, page)
6065
await codeServerPage.setup(authenticated)
6166
await use(codeServerPage)

test/e2e/logout.test.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ describe("logout", true, () => {
1010
expect(await codeServerPage.page.isVisible(logoutButton)).toBe(true)
1111

1212
await codeServerPage.page.hover(logoutButton)
13-
// TODO(@jsjoeio)
14-
// Look into how we're attaching the handlers for the logout feature
15-
// We need to see how it's done upstream and add logging to the
16-
// handlers themselves.
17-
// They may be attached too slowly, hence why we need this timeout
18-
await codeServerPage.page.waitForTimeout(2000)
1913

2014
// Recommended by Playwright for async navigation
2115
// https://github.com/microsoft/playwright/issues/1987#issuecomment-620182151

0 commit comments

Comments
 (0)