cal.pub0.org/apps/web/playwright/hash-my-url.e2e.ts

57 lines
2.2 KiB
TypeScript
Raw Normal View History

2022-05-14 03:02:10 +00:00
import { expect } from "@playwright/test";
2022-05-14 03:02:10 +00:00
import { test } from "./lib/fixtures";
import { bookTimeSlot, selectFirstAvailableTimeSlotNextMonth } from "./lib/testUtils";
2022-05-14 03:02:10 +00:00
test.describe.configure({ mode: "parallel" });
2023-01-07 16:50:02 +00:00
// TODO: This test is very flaky. Feels like tossing a coin and hope that it won't fail. Needs to be revisited.
test.fixme("hash my url", () => {
2022-05-14 03:02:10 +00:00
test.beforeEach(async ({ users }) => {
const user = await users.create();
await user.login();
});
2022-05-14 03:02:10 +00:00
test.afterEach(async ({ users }) => {
await users.deleteAll();
});
test("generate url hash", async ({ page }) => {
// await page.pause();
await page.goto("/event-types");
// We wait until loading is finished
await page.waitForSelector('[data-testid="event-types"]');
await page.locator("ul[data-testid=event-types] > li a").first().click();
// We wait for the page to load
await page.locator(".primary-navigation >> text=Advanced").click();
// ignore if it is already checked, and click if unchecked
const hashedLinkCheck = await page.locator('[data-testid="hashedLinkCheck"]');
await hashedLinkCheck.click();
// we wait for the hashedLink setting to load
2022-05-14 03:02:10 +00:00
const $url = await page.locator('//*[@data-testid="generated-hash-url"]').inputValue();
// click update
await page.locator('[data-testid="update-eventtype"]').press("Enter");
await page.waitForLoadState("networkidle");
2022-05-14 03:02:10 +00:00
// book using generated url hash
await page.goto($url);
await selectFirstAvailableTimeSlotNextMonth(page);
await bookTimeSlot(page);
// Make sure we're navigated to the success page
2022-05-11 16:46:52 +00:00
await expect(page.locator("[data-testid=success-page]")).toBeVisible();
2022-05-14 03:02:10 +00:00
// hash regenerates after successful booking
await page.goto("/event-types");
// We wait until loading is finished
await page.waitForSelector('[data-testid="event-types"]');
await page.locator("ul[data-testid=event-types] > li a").first().click();
// We wait for the page to load
await page.locator(".primary-navigation >> text=Advanced").click();
// we wait for the hashedLink setting to load
const $newUrl = await page.locator('//*[@data-testid="generated-hash-url"]').inputValue();
expect($url !== $newUrl).toBeTruthy();
});
});