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,
|
||||
})
|
||||
}
|
||||
22
apps/scandic-web/tests/e2e/profile/mybenefits.spec.ts
Normal file
22
apps/scandic-web/tests/e2e/profile/mybenefits.spec.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { expect, test } from "@playwright/test"
|
||||
|
||||
import { getProfileButton, performLogin } from "../loginUtil"
|
||||
import { testData } from "../testdata"
|
||||
|
||||
test("can navigate to my benefits page", async ({ page }) => {
|
||||
await performLogin({
|
||||
page,
|
||||
username: testData.basicUser.membershipId,
|
||||
password: testData.basicUser.password,
|
||||
})
|
||||
|
||||
const profileButton = await getProfileButton(page)
|
||||
profileButton.click()
|
||||
const myStaysLink = page.getByRole("link", { name: /my benefits/i })
|
||||
await myStaysLink.click()
|
||||
|
||||
const currentPerksAndBenefits = page.getByRole("heading", {
|
||||
name: /current perks and benefits/i,
|
||||
})
|
||||
await expect(currentPerksAndBenefits).toBeVisible()
|
||||
})
|
||||
20
apps/scandic-web/tests/e2e/profile/mypoints.spec.ts
Normal file
20
apps/scandic-web/tests/e2e/profile/mypoints.spec.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { expect, test } from "@playwright/test"
|
||||
|
||||
import { getProfileButton, performLogin } from "../loginUtil"
|
||||
import { testData } from "../testdata"
|
||||
|
||||
test("can navigate to my points page", async ({ page }) => {
|
||||
await performLogin({
|
||||
page,
|
||||
username: testData.basicUser.membershipId,
|
||||
password: testData.basicUser.password,
|
||||
})
|
||||
|
||||
const profileButton = await getProfileButton(page)
|
||||
profileButton.click()
|
||||
const myPointsLink = page.getByRole("link", { name: /my points/i })
|
||||
await myPointsLink.click()
|
||||
|
||||
const pointsToSpend = page.getByRole("heading", { name: /points to spend/i })
|
||||
await expect(pointsToSpend).toBeVisible()
|
||||
})
|
||||
22
apps/scandic-web/tests/e2e/profile/mystays.spec.ts
Normal file
22
apps/scandic-web/tests/e2e/profile/mystays.spec.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { expect, test } from "@playwright/test"
|
||||
|
||||
import { getProfileButton, performLogin } from "../loginUtil"
|
||||
import { testData } from "../testdata"
|
||||
|
||||
test("can navigate to my stays page", async ({ page }) => {
|
||||
await performLogin({
|
||||
page,
|
||||
username: testData.basicUser.membershipId,
|
||||
password: testData.basicUser.password,
|
||||
})
|
||||
|
||||
const profileButton = await getProfileButton(page)
|
||||
profileButton.click()
|
||||
const myStaysLink = page.getByRole("link", { name: /my stays/i })
|
||||
await myStaysLink.click()
|
||||
|
||||
const upcomingStays = page.getByRole("heading", {
|
||||
name: /^upcoming stays$/i,
|
||||
})
|
||||
await expect(upcomingStays).toBeVisible()
|
||||
})
|
||||
23
apps/scandic-web/tests/e2e/profile/overview.spec.ts
Normal file
23
apps/scandic-web/tests/e2e/profile/overview.spec.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { expect, test } from "@playwright/test"
|
||||
|
||||
import { getProfileButton, performLogin } from "../loginUtil"
|
||||
import { testData } from "../testdata"
|
||||
|
||||
test("can navigate to overview page", async ({ page }) => {
|
||||
await performLogin({
|
||||
page,
|
||||
username: testData.basicUser.membershipId,
|
||||
password: testData.basicUser.password,
|
||||
})
|
||||
|
||||
const profileButton = await getProfileButton(page)
|
||||
profileButton.click()
|
||||
const overviewLink = page.getByRole("link", { name: /overview/i })
|
||||
await overviewLink.click()
|
||||
|
||||
const scandicLevel = page.getByText(/level \d+/i)
|
||||
await expect(scandicLevel).toBeVisible()
|
||||
|
||||
const membershipId = page.getByText(testData.basicUser.membershipId)
|
||||
await expect(membershipId).toBeVisible()
|
||||
})
|
||||
8
apps/scandic-web/tests/e2e/testdata.ts
Normal file
8
apps/scandic-web/tests/e2e/testdata.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
export const testData = {
|
||||
basicUser: {
|
||||
membershipId: "30812500328010",
|
||||
password: "Test@12345",
|
||||
firstName: "Test",
|
||||
lastName: "Testsson",
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user