55 lines
3.2 KiB
TypeScript
55 lines
3.2 KiB
TypeScript
import { mkdir } from "node:fs/promises";
|
|
import path from "node:path";
|
|
|
|
import { expect, test, type Page, type TestInfo } from "@playwright/test";
|
|
|
|
const reviewDirectory = process.env.BILL14_SCREENSHOT_DIR?.trim();
|
|
|
|
async function capture(page: Page, testInfo: TestInfo, name: string): Promise<void> {
|
|
const screenshotPath = reviewDirectory ? path.join(reviewDirectory, `${name}.png`) : testInfo.outputPath(`${name}.png`);
|
|
await mkdir(path.dirname(screenshotPath), { recursive: true });
|
|
await page.screenshot({ path: screenshotPath, fullPage: true, animations: "disabled" });
|
|
}
|
|
|
|
test.describe("BILL-14 public registration plan advisor", () => {
|
|
test("keeps account data while recommending and overriding a team plan", async ({ page }, testInfo) => {
|
|
const adviceReady = page.waitForResponse((response) => {
|
|
const url = new URL(response.url());
|
|
return url.pathname === "/auth/registration-plan-advice" && response.status() === 200;
|
|
});
|
|
await page.goto("/register");
|
|
await adviceReady;
|
|
await expect(page.locator('[data-ui-id="ui.auth.register.accountStep"]')).toBeVisible();
|
|
await capture(page, testInfo, "01-register-account");
|
|
|
|
await page.locator('[data-ui-id="ui.auth.register.email"]').fill("bill14-visual@example.test");
|
|
const password = page.locator('[data-ui-id="ui.auth.register.password"]');
|
|
if (await password.isVisible().catch(() => false)) await password.fill("HiveGrid-BILL14-Visual-2026!");
|
|
await page.locator('[data-ui-id="ui.auth.register.firstName"]').fill("Ada");
|
|
await page.locator('[data-ui-id="ui.auth.register.lastName"]').fill("Lovelace");
|
|
await page.locator('[data-ui-id="ui.auth.register.company"]').fill("BILL-14 Review GmbH");
|
|
const teamStepButton = page.getByRole("button", { name: /Set team size|Teamgröße festlegen/u });
|
|
await expect(teamStepButton).toBeEnabled();
|
|
await teamStepButton.click();
|
|
|
|
const planStep = page.locator('[data-ui-id="ui.auth.register.planStep"]');
|
|
await expect(planStep).toBeVisible();
|
|
await capture(page, testInfo, "02-register-team-default");
|
|
|
|
await page.locator('[data-ui-id="ui.auth.register.officeSeats"]').getByRole("spinbutton").fill("5");
|
|
await page.locator('[data-ui-id="ui.auth.register.fieldSeats"]').getByRole("spinbutton").fill("15");
|
|
await page.getByRole("button", { name: /View plans and live prices|Tarife und Live-Preise anzeigen/u }).click();
|
|
const recommendedSwarm = planStep.getByRole("radio", { name: /Swarm/u });
|
|
await expect(recommendedSwarm).toBeChecked();
|
|
await expect(recommendedSwarm.locator("xpath=..").getByText(/Empfohlen|Recommended/u)).toBeVisible();
|
|
await capture(page, testInfo, "03-register-team-recommended");
|
|
|
|
await planStep.getByRole("radio", { name: /Core/u }).click();
|
|
await capture(page, testInfo, "04-register-team-manual-override");
|
|
await page.getByRole("button", { name: /Back to team size|Zurück zur Teamgröße/u }).click();
|
|
await page.getByRole("button", { name: /Back to account details|Zurück zu den Kontodaten/u }).click();
|
|
await expect(page.locator('[data-ui-id="ui.auth.register.company"]')).toHaveValue("BILL-14 Review GmbH");
|
|
await capture(page, testInfo, "05-register-back-navigation");
|
|
});
|
|
});
|