Skip to content

Commit 0a46057

Browse files
committed
Write tests
1 parent 1c54e0d commit 0a46057

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

site/e2e/helpers.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import { Page } from "@playwright/test"
22

3-
export const urls = {
4-
templates: "/templates",
5-
}
6-
73
export const buttons = {
84
starterTemplates: "Starter templates",
95
dockerTemplate: "Develop in Docker",
@@ -15,8 +11,8 @@ export const buttons = {
1511
startWorkspace: "Start"
1612
}
1713

18-
export const clickButtonByText = async (page: Page, text: string): Promise<void> => {
19-
await page.click(`button:has-text("${text}")`)
14+
export const clickButton = async (page: Page, name: string): Promise<void> => {
15+
await page.getByRole("button", { name, exact: true }).click()
2016
}
2117

2218
export const fillInput = async (page: Page, label: string, value: string): Promise<void> => {

site/e2e/tests/basicFlow.spec.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,39 @@
11
import { test } from "@playwright/test"
22
import { email, password } from "../constants"
33
import { SignInPage } from "../pom"
4-
import { clickButtonByText, buttons, urls, fillInput } from "../helpers";
4+
import { clickButton, buttons, fillInput } from "../helpers";
55

66
test("Basic flow", async ({ baseURL, page }) => {
7+
test.slow()
78
await page.goto(baseURL + "/", { waitUntil: "networkidle" })
89

910
// Log-in with the default credentials we set up in the development server
1011
const signInPage = new SignInPage(baseURL, page)
1112
await signInPage.submitBuiltInAuthentication(email, password)
1213

13-
await page.waitForSelector("text=Workspaces")
14-
1514
// create Docker template
16-
await page.goto(urls.templates);
17-
await clickButtonByText(page, buttons.starterTemplates)
15+
await page.waitForSelector("text=Templates")
16+
await page.click("text=Templates")
17+
18+
await clickButton(page, buttons.starterTemplates)
1819

19-
await clickButtonByText(page, buttons.dockerTemplate)
20+
await page.click(`text=${buttons.dockerTemplate}`)
2021

21-
await clickButtonByText(page, buttons.useTemplate)
22+
await clickButton(page, buttons.useTemplate)
2223

23-
await clickButtonByText(page, buttons.createTemplate)
24+
await clickButton(page, buttons.createTemplate)
2425

2526
// create workspace
26-
await page.click('span:has-text("docker")')
27-
await clickButtonByText(page, buttons.createWorkspace)
27+
await clickButton(page, buttons.createWorkspace)
2828

2929
await fillInput(page, "Workspace Name", "my-workspace")
30-
await clickButtonByText(page, buttons.submitCreateWorkspace)
30+
await clickButton(page, buttons.submitCreateWorkspace)
3131

3232
// stop workspace
33-
await clickButtonByText(page, buttons.stopWorkspace)
33+
await page.waitForSelector("text=Started")
34+
await clickButton(page, buttons.stopWorkspace)
3435

3536
// start workspace
36-
await clickButtonByText(page, buttons.startWorkspace)
37+
await page.waitForSelector("text=Stopped")
38+
await clickButton(page, buttons.startWorkspace)
3739
})

0 commit comments

Comments
 (0)