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

Skip to content

feat: Initial E2E test framework for v2 #288

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 38 commits into from
Mar 2, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
470d06d
Add playwright dependency
bryphe-coder Feb 15, 2022
ab81ef9
Add initial playwright command to run against development server
bryphe-coder Feb 15, 2022
7c970b5
feat: Initial E2E framework
bryphe-coder Feb 15, 2022
853a2b9
Merge main
bryphe-coder Feb 28, 2022
2b0f0cb
Add test/e2e job
bryphe-coder Feb 28, 2022
78ceb9c
Add test/e2e job
bryphe-coder Feb 28, 2022
5243dea
Merge branch 'main' into bryphe/feat/initial-e2e-tests
bryphe-coder Feb 28, 2022
5eb9314
Use coderd directly, create initial user in setup script
bryphe-coder Feb 28, 2022
8fc553a
Ignore e2e tests from jest
bryphe-coder Feb 28, 2022
1b0e0d3
Fix typo
bryphe-coder Feb 28, 2022
f39f59a
Consolidate test_results/test-results
bryphe-coder Feb 28, 2022
0428a62
Add junit reporter for DataDog
bryphe-coder Feb 28, 2022
94c7684
Fix junit path
bryphe-coder Feb 28, 2022
dfe0c7c
Upload E2E test results to DataDog
bryphe-coder Feb 28, 2022
8af7d02
Formatting
bryphe-coder Feb 28, 2022
18f21da
Fix lint issues
bryphe-coder Feb 28, 2022
bcef4ac
Fix unit test DataDog uploads
bryphe-coder Feb 28, 2022
91bda34
Clean up globalSetup
bryphe-coder Feb 28, 2022
08dc699
Fix upload of E2E datadog reports
bryphe-coder Mar 1, 2022
b8cc80f
Add 'category' for classifying tests in datadog (unit, integration, e2e)
bryphe-coder Mar 1, 2022
a88a722
Remove coverage collection from E2E folder
bryphe-coder Mar 1, 2022
4bad40e
Run e2e on all platforms
bryphe-coder Mar 1, 2022
3b0b4cd
Try running on mac/ubuntu for now
bryphe-coder Mar 1, 2022
15a9a11
Experiment: Unblock windows e2e tests
bryphe-coder Mar 1, 2022
081c9cf
Revert "Experiment: Unblock windows e2e tests"
bryphe-coder Mar 1, 2022
439c13b
Revert change to test/js
bryphe-coder Mar 1, 2022
d7f9257
Add link back to Windows issue
bryphe-coder Mar 1, 2022
5eedfbe
Merge branch 'main' into bryphe/feat/initial-e2e-tests
bryphe-coder Mar 1, 2022
7381ca2
Consolidate test-results/test_results in .gitignore
bryphe-coder Mar 1, 2022
d3c8e50
Update site/.eslintignore
bryphe-coder Mar 1, 2022
e66c685
Switch to using const vs function
bryphe-coder Mar 1, 2022
bee5e25
Merge branch 'bryphe/feat/initial-e2e-tests' of github.com:coder/code…
bryphe-coder Mar 1, 2022
66b7d60
Refactor use email, password, username to constants
bryphe-coder Mar 2, 2022
7c568de
Expand POM model
bryphe-coder Mar 2, 2022
41a4516
Fix broken import
bryphe-coder Mar 2, 2022
7997a16
Merge branch 'main' into bryphe/feat/initial-e2e-tests
kylecarbs Mar 2, 2022
fae6b3f
Push functionality up to BasePOM API
bryphe-coder Mar 2, 2022
787213c
Merge branch 'main' into bryphe/feat/initial-e2e-tests
bryphe-coder Mar 2, 2022
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
Refactor use email, password, username to constants
  • Loading branch information
bryphe-coder committed Mar 2, 2022
commit 66b7d60eab475fca883d2f9a35d9036295050b4c
5 changes: 5 additions & 0 deletions site/e2e/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Default credentials and user for running tests
export const username = "admin"
export const password = "password"
export const organization = "acme-crop"
export const email = "[email protected]"
9 changes: 5 additions & 4 deletions site/e2e/globalSetup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { FullConfig, request } from "@playwright/test"
import { email, username, password, organization } from "./constants"

const globalSetup = async (config: FullConfig): Promise<void> => {
// Grab the 'baseURL' from the webserver (`coderd`)
Expand All @@ -12,10 +13,10 @@ const globalSetup = async (config: FullConfig): Promise<void> => {
// Create initial user
await context.post("/api/v2/user", {
data: {
email: "[email protected]",
username: "admin",
password: "password",
organization: "acme-corp",
email,
username,
password,
organization,
},
})
}
Expand Down
3 changes: 2 additions & 1 deletion site/e2e/tests/login.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { test } from "@playwright/test"
import { SignInPage } from "../pom"
import { email, password } from "../constants"

test("Login takes user to /projects", async ({ page, baseURL }) => {
await page.goto(baseURL + "/", { waitUntil: "networkidle" })
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting that unpacking the baseURL works here since it didn't in v1 - good sign! I believe you can avoid doing the string concatenation here though if you define url in the POM.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting that unpacking the baseURL works here since it didn't in v1 - good sign!

Yep! The v1 E2E tests use a special (external) address to point to the server under test (picked up from RUNTIME_CONFIG: https://github.com/coder/m/blob/833f23892c4802bfcdf9b39c86f415a1dc70a3b2/product/coder/e2e/configuration/runtime.ts#L18)

With these tests - using the webServer automatically populates the baseURL which is convenient.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe you can avoid doing the string concatenation here though if you define url in the POM.

Good point - we have some more utilities in the POM layer in v1, I brought them over (ie, BasePOM) here in this change: 7c568de

It's a little bit awkward - since I'm passing both the baseURL and page into the POM's - let me know if you were thinking of a different approach!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Implemented @vapurrmaid 's suggestions which help improve this in: fae6b3f - I'll merge what we have so the test is in place for the NextJS -> Webpack changes, but happy to iterate on it more

Copy link
Contributor

Choose a reason for hiding this comment

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

@bryphe-coder I'm definitely in favor of this merging sooner than later for iteration, it's in a really good starting spot!


// Log-in with the default credentials we set up in the development server
const signInPage = new SignInPage(page)
await signInPage.submitBuiltInAuthentication("[email protected]", "password")
await signInPage.submitBuiltInAuthentication(email, password)

await page.waitForNavigation({ url: baseURL + "/projects", waitUntil: "networkidle" })

Expand Down