Skip to content

Commit ffa5f05

Browse files
committed
feat: add CodeServer page object for e2e tests
1 parent f21884c commit ffa5f05

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

test/e2e/models/CodeServer.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { Page } from "playwright"
2+
import { CODE_SERVER_ADDRESS } from "../../utils/constants"
3+
// This is a Page Object Model
4+
// We use these to simplify e2e test authoring
5+
// See Playwright docs: https://playwright.dev/docs/pom/
6+
export class CodeServer {
7+
page: Page
8+
9+
constructor(page: Page) {
10+
this.page = page
11+
}
12+
async navigate() {
13+
await this.page.goto(CODE_SERVER_ADDRESS, { waitUntil: "networkidle" })
14+
// Make sure the editor actually loaded
15+
await this.page.isVisible("div.monaco-workbench")
16+
}
17+
/**
18+
* Opens the default folder /User if no arg passed
19+
* @param absolutePath Example: /Users/jp/.local/share/code-server/User/
20+
*
21+
*/
22+
async openFolder(absolutePath?: string) {
23+
// Check if no folder is opened
24+
const folderIsNotOpen = await this.page.isVisible("text=You have not yet opened")
25+
26+
if (folderIsNotOpen) {
27+
// Open the default folder
28+
await this.page.keyboard.press("Meta+O")
29+
await this.page.keyboard.press("Enter")
30+
await this.page.waitForLoadState("networkidle")
31+
}
32+
}
33+
}

0 commit comments

Comments
 (0)