56 lines
1.9 KiB
TypeScript
56 lines
1.9 KiB
TypeScript
import { expect, test } from "@playwright/test";
|
|
|
|
import { mockCoreApis } from "@e2e/fixtures/api-mocks";
|
|
import {
|
|
clearBrowserState,
|
|
enterChatFromSplash,
|
|
expectAuthRedirectToVipChatSubscription,
|
|
} from "@e2e/fixtures/test-helpers";
|
|
|
|
test.beforeEach(async ({ baseURL, context, page }) => {
|
|
await clearBrowserState(context, page, baseURL);
|
|
await mockCoreApis(page);
|
|
});
|
|
|
|
test("renders a backend commercial action and opens the private zone", async ({
|
|
page,
|
|
}) => {
|
|
await enterChatFromSplash(page);
|
|
|
|
const input = page.getByRole("textbox", { name: "Message" });
|
|
await expect(input).toBeEnabled();
|
|
await input.fill("private album offer test");
|
|
await input.press("Enter");
|
|
|
|
const offer = page.getByLabel("Open private zone");
|
|
await expect(offer).toContainText(
|
|
"There are more private photos waiting for you.",
|
|
);
|
|
await offer.getByRole("button", { name: "Open private zone" }).click();
|
|
|
|
await expect(page).toHaveURL(/\/characters\/elio\/private-zone$/);
|
|
});
|
|
|
|
test("asks for consent before opening a user-bound discount plan", async ({
|
|
page,
|
|
}) => {
|
|
await enterChatFromSplash(page);
|
|
|
|
const input = page.getByRole("textbox", { name: "Message" });
|
|
await input.fill("discount offer test");
|
|
await input.press("Enter");
|
|
|
|
const offer = page.getByLabel("Yes, ask for me");
|
|
await expect(offer).toContainText("Want me to ask for my best private offer?");
|
|
await offer.getByRole("button", { name: "Yes, ask for me" }).click();
|
|
|
|
await expect(page).toHaveURL(/\/auth\?redirect=/);
|
|
expectAuthRedirectToVipChatSubscription(page);
|
|
const redirect = new URL(page.url()).searchParams.get("redirect");
|
|
const subscriptionUrl = new URL(redirect ?? "", "http://e2e.local");
|
|
expect(subscriptionUrl.searchParams.get("planId")).toBe("vip_annual");
|
|
expect(subscriptionUrl.searchParams.get("commercialOfferId")).toBe(
|
|
"13ec8a10-58d7-4d24-b66b-8db5699a1aa8",
|
|
);
|
|
});
|