Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
merged 11 commits into from
Jan 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Format
  • Loading branch information
presleyp committed Jan 9, 2023
commit a6497664f95a5e34882aaf95f1fa9e4725d5edf0
2 changes: 1 addition & 1 deletion site/e2e/globalSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const globalSetup = async (): Promise<void> => {
email: constants.email,
username: constants.username,
password: constants.password,
trial: false
trial: false,
})
}

Expand Down
8 changes: 6 additions & 2 deletions site/e2e/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ export const buttons = {
createWorkspace: "Create workspace",
submitCreateWorkspace: "Create workspace",
stopWorkspace: "Stop",
startWorkspace: "Start"
startWorkspace: "Start",
}
Copy link
Member

Choose a reason for hiding this comment

The 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> => {
export const fillInput = async (
page: Page,
label: string,
value: string,
): Promise<void> => {
await page.fill(`text=${label}`, value)
}
Copy link
Member

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

Copy link
Member

Choose a reason for hiding this comment

The 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!

2 changes: 1 addition & 1 deletion site/e2e/tests/basicFlow.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test } from "@playwright/test"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps the file name basicFlow.spec.ts could be more descriptive?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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";
import { clickButton, buttons, fillInput } from "../helpers"

test("Basic flow", async ({ baseURL, page }) => {
test.slow()
Expand Down