File tree 2 files changed +24
-0
lines changed 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,10 @@ test.describe("CodeServer", () => {
38
38
expect ( await codeServer . isEditorVisible ( ) ) . toBe ( true )
39
39
} )
40
40
41
+ test . only ( "should always have a connection" , options , async ( { page } ) => {
42
+ expect ( await codeServer . isConnected ( ) ) . toBe ( true )
43
+ } )
44
+
41
45
test ( "should show the Integrated Terminal" , options , async ( { page } ) => {
42
46
await codeServer . focusTerminal ( )
43
47
expect ( await page . isVisible ( "#terminal" ) ) . toBe ( true )
Original file line number Diff line number Diff line change @@ -56,6 +56,26 @@ export class CodeServer {
56
56
return await this . page . isVisible ( this . editorSelector )
57
57
}
58
58
59
+ /**
60
+ * Checks if the editor is visible
61
+ */
62
+ async isConnected ( ) {
63
+ // Make sure the editor actually loaded
64
+ // If it's not visible after 5 seconds, something is wrong
65
+ await this . page . waitForLoadState ( "networkidle" )
66
+
67
+ // See [aria-label="Remote Host"] text=${CODE_SERVER_ADDRESS}
68
+ const hostElement = await this . page . $ ( `[aria-label="Remote Host"]` )
69
+ // Returns something like " localhost:8080"
70
+ const host = await hostElement ?. innerText ( )
71
+
72
+ // Check if host (localhost:8080) is in the CODE_SERVER_ADDRESS
73
+ // if it is, we're connected!
74
+ // if not, we may need to reload the page
75
+ // Make sure to trim whitespace too
76
+ return host ? CODE_SERVER_ADDRESS . includes ( host . trim ( ) ) : false
77
+ }
78
+
59
79
/**
60
80
* Focuses Integrated Terminal
61
81
* by using "Terminal: Focus Terminal"
You can’t perform that action at this time.
0 commit comments