Skip to content

Commit 66b7d60

Browse files
committed
Refactor use email, password, username to constants
1 parent bee5e25 commit 66b7d60

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

site/e2e/constants.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Default credentials and user for running tests
2+
export const username = "admin"
3+
export const password = "password"
4+
export const organization = "acme-crop"
5+
export const email = "admin@coder.com"

site/e2e/globalSetup.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { FullConfig, request } from "@playwright/test"
2+
import { email, username, password, organization } from "./constants"
23

34
const globalSetup = async (config: FullConfig): Promise<void> => {
45
// Grab the 'baseURL' from the webserver (`coderd`)
@@ -12,10 +13,10 @@ const globalSetup = async (config: FullConfig): Promise<void> => {
1213
// Create initial user
1314
await context.post("/api/v2/user", {
1415
data: {
15-
email: "admin@coder.com",
16-
username: "admin",
17-
password: "password",
18-
organization: "acme-corp",
16+
email,
17+
username,
18+
password,
19+
organization,
1920
},
2021
})
2122
}

site/e2e/tests/login.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { test } from "@playwright/test"
22
import { SignInPage } from "../pom"
3+
import { email, password } from "../constants"
34

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

78
// Log-in with the default credentials we set up in the development server
89
const signInPage = new SignInPage(page)
9-
await signInPage.submitBuiltInAuthentication("admin@coder.com", "password")
10+
await signInPage.submitBuiltInAuthentication(email, password)
1011

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

0 commit comments

Comments
 (0)