-
Notifications
You must be signed in to change notification settings - Fork 5.9k
refactor(testing): fix flaky terminal test #3230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report
@@ Coverage Diff @@
## main #3230 +/- ##
=======================================
Coverage 46.90% 46.90%
=======================================
Files 23 23
Lines 1196 1196
Branches 237 237
=======================================
Hits 561 561
Misses 451 451
Partials 184 184 Continue to review full report at Codecov.
|
45df7b5
to
7529975
Compare
7529975
to
449c6da
Compare
// Read more: https://thisthat.dev/dom-content-loaded-vs-load/ | ||
await this.page.waitForLoadState("load") | ||
// Give it an extra second just in case it's feeling extra slow | ||
await this.page.waitForTimeout(1000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahah these things make me sad, totally fair though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol i know. sadly, this timeout was the only thing that made it consistently pass.
@@ -5,6 +5,7 @@ import { CODE_SERVER_ADDRESS } from "../../utils/constants" | |||
// See Playwright docs: https://playwright.dev/docs/pom/ | |||
export class CodeServer { | |||
page: Page | |||
editorSelector = "div.monaco-workbench" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ I realized how many places I was using this in the model so refactored it into a property of the class
// Read more: https://thisthat.dev/dom-content-loaded-vs-load/ | ||
await this.page.waitForLoadState("load") | ||
// Give it an extra second just in case it's feeling extra slow | ||
await this.page.waitForTimeout(1000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol i know. sadly, this timeout was the only thing that made it consistently pass.
// Click text=Command Palette | ||
await this.page.hover("text=Command Palette") | ||
await this.page.click("text=Command Palette") | ||
|
||
// Type Terminal: Focus Terminal | ||
await this.page.keyboard.type("Terminal: Focus Terminal") | ||
|
||
// Click Terminal: Focus Terminal | ||
await this.page.hover("text=Terminal: Focus Terminal") | ||
await this.page.click("text=Terminal: Focus Terminal") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach produces consistent results — no matter if the terminal is already focused, visible/not visible.
// which is why we wait for it twice | ||
await this.page.waitForSelector("div.terminal.xterm.focus") | ||
// Wait for terminal textarea to show up | ||
await this.page.waitForSelector("textarea.xterm-helper-textarea") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also seems to be better than looking for the div.terminal.xterm.focus
selector, which may or may not appear.
H/T to @kylecarbs for the suggestion 🎉
xterm source
// It may take a second to process | ||
await page.waitForTimeout(1000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no great way of knowing that the terminal received both the input and the enter and processed it (because it's a <canvas>
element so we can't assert the text on screen) so having this timeout accounts for any slowness that might occur.
This PR fixes a flaky implementation of the
focusTerminal
method on theCodeServer
model.This was caught after merging into #3169
main
and the e2e tests failed here 😅Changes:
reloadUntilEditorIsVisible
method. It wasn't waiting for code-server to fully load before reloading. before "Editor became visible after 11 reloads -> "Editor became visible after 1 reload"focusTerminal
method.Before
The
should show the Integrated Terminal
only passed intermittently in Firefox:e4bebc41-637c-4949-9b13-ddf10f64a6cc.mp4
What's happening: it's waiting for the selector
div.terminal.xterm.focus
to be visible, which doesn't happen for some reason and the test times-out.After