-
Notifications
You must be signed in to change notification settings - Fork 892
chore: add e2e tests for basic template and workspace flow #5637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
57f3d52
5975f1b
3040187
1eb389a
0956627
79d5c50
1c54e0d
0a46057
a649766
279bb51
443fbc5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Page } from "@playwright/test" | ||
|
||
export const buttons = { | ||
starterTemplates: "Starter templates", | ||
dockerTemplate: "Develop in Docker", | ||
useTemplate: "Use template", | ||
createTemplate: "Create template", | ||
createWorkspace: "Create workspace", | ||
submitCreateWorkspace: "Create workspace", | ||
stopWorkspace: "Stop", | ||
startWorkspace: "Start", | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure I would decouple this page-specific constant from the test for that page. |
||
|
||
export const clickButton = async (page: Page, name: string): Promise<void> => { | ||
await page.getByRole("button", { name, exact: true }).click() | ||
} | ||
|
||
export const fillInput = async ( | ||
page: Page, | ||
label: string, | ||
value: string, | ||
): Promise<void> => { | ||
await page.fill(`text=${label}`, value) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason we made helpers for these? They seem to wrap fairly trivial built-in methods. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To address this comment and the one about the constant: previously, we wrote Playwright tests with POMs, so for each page, you'd have a file with a class and methods. I started doing that here and it felt too heavy since the current plan isn't to write many e2e tests. (Although after seeing how pleasant they were to debug, I'm reconsidering that!) So instead, I just dumped everything I would normally have put in the class into these few helpers. But I agree that it's not that much easier to read and write than just inlining everything. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As someone who isn't familiar with playwright, I appreciate them and makes test-authoring seem a bit easier. No strong opinions though! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { test } from "@playwright/test" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps the file name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, we discussed having one long test instead of several short ones since e2e tests tend to build on each other, and so I didn't have something really specific to name it. But again, now that I'm feeling more positive on e2e tests, we should probably talk as a team about whether we want to do more of them. |
||
import { email, password } from "../constants" | ||
import { SignInPage } from "../pom" | ||
import { clickButton, buttons, fillInput } from "../helpers" | ||
|
||
test("Basic flow", async ({ baseURL, page }) => { | ||
test.slow() | ||
await page.goto(baseURL + "/", { waitUntil: "networkidle" }) | ||
|
||
// Log-in with the default credentials we set up in the development server | ||
const signInPage = new SignInPage(baseURL, page) | ||
await signInPage.submitBuiltInAuthentication(email, password) | ||
|
||
// create Docker template | ||
await page.waitForSelector("text=Templates") | ||
await page.click("text=Templates") | ||
|
||
await clickButton(page, buttons.starterTemplates) | ||
|
||
await page.click(`text=${buttons.dockerTemplate}`) | ||
|
||
await clickButton(page, buttons.useTemplate) | ||
|
||
await clickButton(page, buttons.createTemplate) | ||
|
||
// create workspace | ||
await clickButton(page, buttons.createWorkspace) | ||
|
||
await fillInput(page, "Workspace Name", "my-workspace") | ||
await clickButton(page, buttons.submitCreateWorkspace) | ||
|
||
// stop workspace | ||
await page.waitForSelector("text=Started") | ||
await clickButton(page, buttons.stopWorkspace) | ||
|
||
// start workspace | ||
await page.waitForSelector("text=Stopped") | ||
await clickButton(page, buttons.startWorkspace) | ||
presleyp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
await page.waitForSelector("text=Started") | ||
}) |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1921,13 +1921,13 @@ | |
tiny-glob "^0.2.9" | ||
tslib "^2.4.0" | ||
|
||
"@playwright/test@1.26.1": | ||
version "1.26.1" | ||
resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.26.1.tgz#73ada4e70f618bca69ba7509c4ba65b5a41c4b10" | ||
integrity sha512-bNxyZASVt2adSZ9gbD7NCydzcb5JaI0OR9hc7s+nmPeH604gwp0zp17NNpwXY4c8nvuBGQQ9oGDx72LE+cUWvw== | ||
"@playwright/test@1.29.2": | ||
version "1.29.2" | ||
resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.29.2.tgz#c48184721d0f0b7627a886e2ec42f1efb2be339d" | ||
integrity sha512-+3/GPwOgcoF0xLz/opTnahel1/y42PdcgZ4hs+BZGIUjtmEFSXGg+nFoaH3NSmuc7a6GSFwXDJ5L7VXpqzigNg== | ||
dependencies: | ||
"@types/node" "*" | ||
playwright-core "1.26.1" | ||
playwright-core "1.29.2" | ||
|
||
"@pmmmwh/react-refresh-webpack-plugin@^0.5.3": | ||
version "0.5.9" | ||
|
@@ -11326,10 +11326,17 @@ pkg-dir@^5.0.0: | |
dependencies: | ||
find-up "^5.0.0" | ||
|
||
[email protected]: | ||
version "1.26.1" | ||
resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.26.1.tgz#a162f476488312dcf12638d97685144de6ada512" | ||
integrity sha512-hzFchhhxnEiPc4qVPs9q2ZR+5eKNifY2hQDHtg1HnTTUuphYCBP8ZRb2si+B1TR7BHirgXaPi48LIye5SgrLAA== | ||
[email protected]: | ||
version "1.29.2" | ||
resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.29.2.tgz#2e8347e7e8522409f22b244e600e703b64022406" | ||
integrity sha512-94QXm4PMgFoHAhlCuoWyaBYKb92yOcGVHdQLoxQ7Wjlc7Flg4aC/jbFW7xMR52OfXMVkWicue4WXE7QEegbIRA== | ||
|
||
playwright@^1.29.2: | ||
version "1.29.2" | ||
resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.29.2.tgz#d6a0a3e8e44f023f7956ed19ffa8af915a042769" | ||
integrity sha512-hKBYJUtdmYzcjdhYDkP9WGtORwwZBBKAW8+Lz7sr0ZMxtJr04ASXVzH5eBWtDkdb0c3LLFsehfPBTRfvlfKJOA== | ||
dependencies: | ||
playwright-core "1.29.2" | ||
|
||
pluralize@^8.0.0: | ||
version "8.0.0" | ||
|
Uh oh!
There was an error while loading. Please reload this page.