refactor(e2e): organize fixtures by feature
This commit is contained in:
@@ -9,10 +9,15 @@ import {
|
||||
enterChatFromSplash,
|
||||
expectInsufficientCreditsDialog,
|
||||
expectVipChatSubscriptionUrl,
|
||||
setEmailSessionStorage,
|
||||
submitEmailLogin,
|
||||
switchToEmailSignIn,
|
||||
} from "@e2e/fixtures/test-helpers";
|
||||
|
||||
const paidImageOverlayUrl = new RegExp(
|
||||
`/chat\\?image=${paidImageMessageId}$`,
|
||||
);
|
||||
|
||||
test.beforeEach(async ({ baseURL, context, page }) => {
|
||||
await clearBrowserState(context, page, baseURL);
|
||||
await mockCoreApis(page, {
|
||||
@@ -44,7 +49,7 @@ test("guest can unlock a paid image after email login and subscription payment",
|
||||
await expect(paidImageButton).toBeVisible();
|
||||
|
||||
await paidImageButton.click();
|
||||
await expect(page).toHaveURL(new RegExp(`/chat/image/${paidImageMessageId}$`));
|
||||
await expect(page).toHaveURL(paidImageOverlayUrl);
|
||||
|
||||
const lockedImageDialog = page.getByRole("dialog", {
|
||||
name: "Locked fullscreen image",
|
||||
@@ -57,16 +62,19 @@ test("guest can unlock a paid image after email login and subscription payment",
|
||||
|
||||
await expect(page).toHaveURL(/\/auth\?redirect=/);
|
||||
expect(new URL(page.url()).searchParams.get("redirect")).toBe(
|
||||
`/chat/image/${paidImageMessageId}`,
|
||||
`/chat?image=${paidImageMessageId}`,
|
||||
);
|
||||
|
||||
await switchToEmailSignIn(page);
|
||||
await submitEmailLogin(page, {
|
||||
expectedUrl: paidImageOverlayUrl,
|
||||
});
|
||||
|
||||
await setEmailSessionStorage(page);
|
||||
const unlockRequestPromise = page.waitForRequest(
|
||||
"**/api/chat/unlock-private",
|
||||
);
|
||||
await submitEmailLogin(page, {
|
||||
expectedUrl: new RegExp(`/chat/image/${paidImageMessageId}$`),
|
||||
});
|
||||
await page.goto(`/chat?image=${paidImageMessageId}`);
|
||||
|
||||
const unlockRequest = await unlockRequestPromise;
|
||||
expect(unlockRequest.postDataJSON()).toMatchObject({
|
||||
@@ -81,5 +89,7 @@ test("guest can unlock a paid image after email login and subscription payment",
|
||||
await expectVipChatSubscriptionUrl(page);
|
||||
await completeVipPayment(page);
|
||||
|
||||
await expect(page).toHaveURL(new RegExp(`/chat/image/${paidImageMessageId}$`));
|
||||
await expect(page).toHaveURL(/\/chat(?:\?image=msg_photo_paywall_001)?$/);
|
||||
expect(new URL(page.url()).pathname).toBe("/chat");
|
||||
await expect(page.getByRole("textbox", { name: "Message" })).toBeVisible();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user