Files
web/apps/scandic-web/tests/e2e/loginUtil.ts
Joakim Jäderberg 99497488f3 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
2025-12-03 08:52:08 +00:00

45 lines
1.1 KiB
TypeScript

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,
})
}