Merged in chore/ignore-e2e-tests-in-ci (pull request #3285)
chore: ignore e2e tests when running yarn test * chore: ignore e2e tests when running yarn test
This commit is contained in:
44
apps/scandic-web/tests/e2e/loginUtil.ts
Normal file
44
apps/scandic-web/tests/e2e/loginUtil.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { expect, type Page } from "@playwright/test"
|
||||
|
||||
const AUTH_URL_REGEX =
|
||||
/https:\/\/.*\.scandichotels\.com\/authn\/authenticate\/scandic/i
|
||||
|
||||
export async function performLogin({
|
||||
page,
|
||||
username,
|
||||
password,
|
||||
}: {
|
||||
page: Page
|
||||
username: string
|
||||
password: string
|
||||
}) {
|
||||
await page.goto("/en")
|
||||
const loginLink = page.getByRole("link", { name: /log in\/join/i })
|
||||
await expect(loginLink).not.toBeDisabled()
|
||||
|
||||
await loginLink.click()
|
||||
|
||||
await expect(page).toHaveURL(AUTH_URL_REGEX)
|
||||
|
||||
// Fill in the login form
|
||||
|
||||
const usernameTextBox = page.getByRole("textbox", {
|
||||
name: /email \/ membership number/i,
|
||||
})
|
||||
await usernameTextBox.fill(username)
|
||||
|
||||
const passwordTextBox = page.getByRole("textbox", { name: /password/i })
|
||||
await passwordTextBox.fill(password)
|
||||
|
||||
const signInButton = page.getByRole("button", { name: /log in/i })
|
||||
await signInButton.click()
|
||||
|
||||
const profileButton = await getProfileButton(page)
|
||||
await expect(profileButton).toBeVisible()
|
||||
}
|
||||
|
||||
export async function getProfileButton(page: Page) {
|
||||
return page.getByRole("button", {
|
||||
name: /^\p{L}{2} hi \p{L}+!/iu,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user