File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,10 @@ test.describe("CodeServer", () => {
3838 expect ( await codeServer . isEditorVisible ( ) ) . toBe ( true )
3939 } )
4040
41+ test . only ( "should always have a connection" , options , async ( { page } ) => {
42+ expect ( await codeServer . isConnected ( ) ) . toBe ( true )
43+ } )
44+
4145 test ( "should show the Integrated Terminal" , options , async ( { page } ) => {
4246 await codeServer . focusTerminal ( )
4347 expect ( await page . isVisible ( "#terminal" ) ) . toBe ( true )
Original file line number Diff line number Diff line change @@ -56,6 +56,25 @@ export class CodeServer {
5656 return await this . page . isVisible ( this . editorSelector )
5757 }
5858
59+ /**
60+ * Checks if the editor is visible
61+ */
62+ async isConnected ( ) {
63+ await this . page . waitForLoadState ( "networkidle" )
64+
65+ // See [aria-label="Remote Host"]
66+ const hostElement = await this . page . $ ( `[aria-label="Remote Host"]` )
67+ // Returns something like " localhost:8080"
68+ const host = await hostElement ?. innerText ( )
69+
70+ // Check if host (localhost:8080) is in the CODE_SERVER_ADDRESS
71+ // if it is, we're connected!
72+ // if not, we may need to reload the page
73+ // Make sure to trim whitespace too
74+ const isEditorConnected = host ? CODE_SERVER_ADDRESS . includes ( host . trim ( ) ) : false
75+ return isEditorConnected
76+ }
77+
5978 /**
6079 * Focuses Integrated Terminal
6180 * by using "Terminal: Focus Terminal"
You can’t perform that action at this time.
0 commit comments