mirror of
https://github.com/coder/code-server.git
synced 2024-12-25 18:52:34 +03:00
feat: add isConnected method to CodeServer model
This commit is contained in:
parent
0d9fe6ff44
commit
2cb499385a
@ -38,6 +38,10 @@ test.describe("CodeServer", () => {
|
||||
expect(await codeServer.isEditorVisible()).toBe(true)
|
||||
})
|
||||
|
||||
test.only("should always have a connection", options, async ({ page }) => {
|
||||
expect(await codeServer.isConnected()).toBe(true)
|
||||
})
|
||||
|
||||
test("should show the Integrated Terminal", options, async ({ page }) => {
|
||||
await codeServer.focusTerminal()
|
||||
expect(await page.isVisible("#terminal")).toBe(true)
|
||||
|
@ -56,6 +56,25 @@ export class CodeServer {
|
||||
return await this.page.isVisible(this.editorSelector)
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the editor is visible
|
||||
*/
|
||||
async isConnected() {
|
||||
await this.page.waitForLoadState("networkidle")
|
||||
|
||||
// See [aria-label="Remote Host"]
|
||||
const hostElement = await this.page.$(`[aria-label="Remote Host"]`)
|
||||
// Returns something like " localhost:8080"
|
||||
const host = await hostElement?.innerText()
|
||||
|
||||
// Check if host (localhost:8080) is in the CODE_SERVER_ADDRESS
|
||||
// if it is, we're connected!
|
||||
// if not, we may need to reload the page
|
||||
// Make sure to trim whitespace too
|
||||
const isEditorConnected = host ? CODE_SERVER_ADDRESS.includes(host.trim()) : false
|
||||
return isEditorConnected
|
||||
}
|
||||
|
||||
/**
|
||||
* Focuses Integrated Terminal
|
||||
* by using "Terminal: Focus Terminal"
|
||||
|
Loading…
Reference in New Issue
Block a user