import { expect, test } from "@playwright/experimental-ct-react";
import { RegisterScreenVisualFixture as VisualFixture } from "../../apps/web/app/modules/users/components/RegisterScreen.visual-fixture";
test.describe("BILL-18 registration plan advisor visual baseline", () => {
test("desktop separates team sizing from the recommended plan", async ({ mount, page }) => {
await prepareCaptchaFixture(page);
const component = await mount();
await openTeamStep(component);
await expect(component).toHaveScreenshot("bill-22-registration-team-desktop.png", { animations: "disabled" });
await component.locator('[name="selectedOfficeSeatQuantity"]').fill("5");
await component.locator('[name="selectedFieldSeatQuantity"]').fill("15");
await expect(component.locator('[name="selectedSubscriptionPriceId"]')).toHaveValue("price_pro");
await component.locator('[data-ui-id="ui.auth.register.toPlanStep"]').click();
await expect(component.locator('[data-ui-id="ui.auth.register.planSelection"]')).toContainText("Core");
await expect(component).toHaveScreenshot("bill-22-registration-plan-desktop.png", { animations: "disabled" });
});
test("mobile stacks team and plan steps without horizontal overflow", async ({ mount, page }) => {
await page.setViewportSize({ width: 390, height: 844 });
await prepareCaptchaFixture(page);
const component = await mount();
await openTeamStep(component);
await expect(component).toHaveCSS("width", "390px");
await expect(page.locator("body")).toHaveJSProperty("scrollWidth", 390);
await expect(component).toHaveScreenshot("bill-22-registration-team-mobile.png", { animations: "disabled" });
await component.locator('[data-ui-id="ui.auth.register.toPlanStep"]').click();
await expect(component.locator('[data-ui-id="ui.auth.register.planSelection"]')).toBeVisible();
await expect(component).toHaveScreenshot("bill-22-registration-plan-mobile.png", { animations: "disabled" });
});
});
async function openTeamStep(component: import("@playwright/experimental-ct-react").Locator) {
await component.locator('[name="email"]').fill("ada@example.test");
await component.locator('[name="first-name"]').fill("Ada");
await component.locator('[name="last-name"]').fill("Lovelace");
await component.locator('[name="company"]').fill("Analytical Engines GmbH");
await component.locator('[data-ui-id="ui.auth.register.toTeamStep"]').click();
await expect(component.locator('[data-ui-id="ui.auth.register.planStep"]')).toBeVisible();
await expect(component.locator('[data-ui-id="ui.auth.register.teamStep"]')).toBeVisible();
}
async function prepareCaptchaFixture(page: import("@playwright/test").Page) {
await page.evaluate(() => {
if (customElements.get("cap-widget")) return;
customElements.define(
"cap-widget",
class extends HTMLElement {
connectedCallback() {
this.innerHTML =
'
Ich bin ein Mensch
';
}
}
);
});
await page.route("**/auth/registration-plan-advice**", async (route) => {
const requestUrl = new URL(route.request().url());
const officeSeatQuantity = Number(requestUrl.searchParams.get("office"));
const fieldSeatQuantity = Number(requestUrl.searchParams.get("field"));
const recommendsSwarm = officeSeatQuantity === 5 && fieldSeatQuantity === 15;
await route.fulfill({
contentType: "application/json",
body: JSON.stringify({
plans: recommendsSwarm ? swarmSizedPlans : plans,
selectedPriceId: recommendsSwarm ? "price_pro" : "price_starter",
recommendedPriceId: recommendsSwarm ? "price_pro" : "price_starter",
officeSeatQuantity,
fieldSeatQuantity,
}),
});
});
}
const plans = [
{
planId: "product_starter",
planCode: "starter",
titleKey: "Core",
descriptionKey: "Core",
priceId: "price_starter",
amountCents: 19_900,
baseAmountCents: 19_900,
currency: "EUR",
billingPeriod: 3,
includedOfficeSeatQuantity: 2,
includedFieldSeatQuantity: 5,
includedStorageGb: 100,
extraOfficeSeatQuantity: 0,
extraFieldSeatQuantity: 0,
recommended: true,
},
{
planId: "product_pro",
planCode: "pro",
titleKey: "Swarm",
descriptionKey: "Swarm",
priceId: "price_pro",
amountCents: 49_900,
baseAmountCents: 49_900,
currency: "EUR",
billingPeriod: 3,
includedOfficeSeatQuantity: 5,
includedFieldSeatQuantity: 15,
includedStorageGb: 250,
extraOfficeSeatQuantity: 0,
extraFieldSeatQuantity: 0,
recommended: false,
},
{
planId: "product_business",
planCode: "business",
titleKey: "Colony",
descriptionKey: "Colony",
priceId: "price_business",
amountCents: 99_900,
baseAmountCents: 99_900,
currency: "EUR",
billingPeriod: 3,
includedOfficeSeatQuantity: 10,
includedFieldSeatQuantity: 30,
includedStorageGb: 500,
extraOfficeSeatQuantity: 0,
extraFieldSeatQuantity: 0,
recommended: false,
},
] as const;
const swarmSizedPlans = plans.map((plan) =>
plan.planCode === "starter"
? {
...plan,
amountCents: 62_600,
extraOfficeSeatQuantity: 3,
extraFieldSeatQuantity: 10,
recommended: false,
}
: plan.planCode === "pro"
? { ...plan, recommended: true }
: plan
);