@@ -5,6 +5,7 @@ import { CODE_SERVER_ADDRESS } from "../../utils/constants"
5
5
// See Playwright docs: https://playwright.dev/docs/pom/
6
6
export class CodeServer {
7
7
page : Page
8
+ editorSelector = "div.monaco-workbench"
8
9
9
10
constructor ( page : Page ) {
10
11
this . page = page
@@ -30,15 +31,18 @@ export class CodeServer {
30
31
// but usually a reload or two fixes it
31
32
// TODO@jsjoeio @oxy look into Firefox reconnection/timeout issues
32
33
while ( ! editorIsVisible ) {
34
+ // When a reload happens, we want to wait for all resources to be
35
+ // loaded completely. Hence why we use that instead of DOMContentLoaded
36
+ // Read more: https://thisthat.dev/dom-content-loaded-vs-load/
37
+ await this . page . waitForLoadState ( "load" )
38
+ // Give it an extra second just in case it's feeling extra slow
39
+ await this . page . waitForTimeout ( 1000 )
33
40
reloadCount += 1
34
41
if ( await this . isEditorVisible ( ) ) {
35
42
console . log ( ` Editor became visible after ${ reloadCount } reloads` )
36
43
break
37
44
}
38
- // When a reload happens, we want to wait for all resources to be
39
- // loaded completely. Hence why we use that instead of DOMContentLoaded
40
- // Read more: https://thisthat.dev/dom-content-loaded-vs-load/
41
- await this . page . reload ( { waitUntil : "load" } )
45
+ await this . page . reload ( )
42
46
}
43
47
}
44
48
@@ -49,7 +53,7 @@ export class CodeServer {
49
53
// Make sure the editor actually loaded
50
54
// If it's not visible after 5 seconds, something is wrong
51
55
await this . page . waitForLoadState ( "networkidle" )
52
- return await this . page . isVisible ( "div.monaco-workbench" , { timeout : 5000 } )
56
+ return await this . page . isVisible ( this . editorSelector )
53
57
}
54
58
55
59
/**
@@ -63,7 +67,9 @@ export class CodeServer {
63
67
const isTerminalVisible = await this . page . isVisible ( "#terminal" )
64
68
if ( isTerminalVisible ) {
65
69
await this . page . keyboard . press ( `Control+Backquote` )
66
- // TODO fix this
70
+
71
+ // Make sure everything is laoded
72
+ await this . page . waitForLoadState ( "load" )
67
73
// Wait for terminal to receive focus
68
74
await this . page . waitForSelector ( "div.terminal.xterm.focus" )
69
75
// Sometimes the terminal reloads
0 commit comments