2022-05-14 03:02:10 +00:00
|
|
|
import { expect } from "@playwright/test";
|
2022-04-28 15:44:26 +00:00
|
|
|
|
2022-05-14 03:02:10 +00:00
|
|
|
import { test } from "./lib/fixtures";
|
2022-04-28 15:44:26 +00:00
|
|
|
import { bookTimeSlot, selectFirstAvailableTimeSlotNextMonth } from "./lib/testUtils";
|
|
|
|
|
2022-05-14 03:02:10 +00:00
|
|
|
test.describe.configure({ mode: "parallel" });
|
|
|
|
|
2022-04-28 15:44:26 +00:00
|
|
|
test.describe("hash my url", () => {
|
2022-05-14 03:02:10 +00:00
|
|
|
test.beforeEach(async ({ users }) => {
|
|
|
|
const user = await users.create();
|
|
|
|
await user.login();
|
2022-04-28 15:44:26 +00:00
|
|
|
});
|
2022-05-14 03:02:10 +00:00
|
|
|
test.afterEach(async ({ users }) => {
|
|
|
|
await users.deleteAll();
|
2022-04-28 15:44:26 +00:00
|
|
|
});
|
|
|
|
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"]');
|
2022-11-15 08:36:20 +00:00
|
|
|
await page.locator("ul[data-testid=event-types] > li a").first().click();
|
2022-04-28 15:44:26 +00:00
|
|
|
// We wait for the page to load
|
2022-09-15 16:59:48 +00:00
|
|
|
await page.locator(".primary-navigation >> text=Advanced").click();
|
2022-05-09 11:11:07 +00:00
|
|
|
// ignore if it is already checked, and click if unchecked
|
2022-09-15 16:59:48 +00:00
|
|
|
const hashedLinkCheck = await page.locator('[data-testid="hashedLinkCheck"]');
|
2022-09-07 23:29:24 +00:00
|
|
|
|
2022-09-15 16:59:48 +00:00
|
|
|
await hashedLinkCheck.click();
|
2022-09-07 23:29:24 +00:00
|
|
|
|
2022-05-09 11:11:07 +00:00
|
|
|
// 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();
|
2022-04-28 15:44:26 +00:00
|
|
|
|
2022-09-07 23:29:24 +00:00
|
|
|
// click update
|
|
|
|
await page.locator('[data-testid="update-eventtype"]').press("Enter");
|
2022-09-15 16:59:48 +00:00
|
|
|
|
|
|
|
await page.waitForLoadState("networkidle");
|
2022-05-14 03:02:10 +00:00
|
|
|
|
|
|
|
// book using generated url hash
|
2022-04-28 15:44:26 +00:00
|
|
|
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-04-28 15:44:26 +00:00
|
|
|
|
2022-05-14 03:02:10 +00:00
|
|
|
// hash regenerates after successful booking
|
2022-04-28 15:44:26 +00:00
|
|
|
await page.goto("/event-types");
|
|
|
|
// We wait until loading is finished
|
|
|
|
await page.waitForSelector('[data-testid="event-types"]');
|
2022-11-15 08:36:20 +00:00
|
|
|
await page.locator("ul[data-testid=event-types] > li a").first().click();
|
2022-04-28 15:44:26 +00:00
|
|
|
// We wait for the page to load
|
2022-09-15 16:59:48 +00:00
|
|
|
await page.locator(".primary-navigation >> text=Advanced").click();
|
2022-04-28 15:44:26 +00:00
|
|
|
// we wait for the hashedLink setting to load
|
|
|
|
const $newUrl = await page.locator('//*[@data-testid="generated-hash-url"]').inputValue();
|
|
|
|
expect($url !== $newUrl).toBeTruthy();
|
|
|
|
});
|
|
|
|
});
|