fix(e2e): stabilize authenticated unlock flows
This commit is contained in:
@@ -7,7 +7,6 @@ import {
|
||||
defaultCharacterChatUrl,
|
||||
expectInsufficientCreditsDialog,
|
||||
expectVipChatSubscriptionUrl,
|
||||
setEmailSessionStorage,
|
||||
submitEmailLogin,
|
||||
switchToEmailSignIn,
|
||||
} from "@e2e/fixtures/test-helpers";
|
||||
@@ -36,13 +35,10 @@ test("guest unlocks a promoted image through email login and top-up", async ({
|
||||
await expect(page).toHaveURL(/\/auth\?redirect=/);
|
||||
|
||||
await switchToEmailSignIn(page);
|
||||
await submitEmailLogin(page, { expectedUrl: defaultCharacterChatUrl });
|
||||
|
||||
await setEmailSessionStorage(page);
|
||||
const unlockRequestPromise = page.waitForRequest(
|
||||
"**/api/chat/unlock-private",
|
||||
);
|
||||
await page.reload();
|
||||
await submitEmailLogin(page, { expectedUrl: defaultCharacterChatUrl });
|
||||
|
||||
const unlockRequest = await unlockRequestPromise;
|
||||
expect(unlockRequest.method()).toBe("POST");
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
import { mockCoreApis } from "@e2e/fixtures/api-mocks";
|
||||
import { paidImageMessageId } from "@e2e/fixtures/test-data";
|
||||
import {
|
||||
paidImageDisplayMessageId,
|
||||
paidImageMessageId,
|
||||
} from "@e2e/fixtures/test-data";
|
||||
import {
|
||||
clearBrowserState,
|
||||
completeVipPayment,
|
||||
@@ -10,13 +13,12 @@ import {
|
||||
enterChatFromSplash,
|
||||
expectInsufficientCreditsDialog,
|
||||
expectVipChatSubscriptionUrl,
|
||||
setEmailSessionStorage,
|
||||
submitEmailLogin,
|
||||
switchToEmailSignIn,
|
||||
} from "@e2e/fixtures/test-helpers";
|
||||
|
||||
const paidImageOverlayUrl = new RegExp(
|
||||
`${defaultCharacterChatPath}\\?image=${paidImageMessageId}$`,
|
||||
`${defaultCharacterChatPath}\\?image=${encodeURIComponent(paidImageDisplayMessageId)}$`,
|
||||
);
|
||||
|
||||
test.beforeEach(async ({ baseURL, context, page }) => {
|
||||
@@ -63,19 +65,16 @@ 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(
|
||||
`${defaultCharacterChatPath}?image=${paidImageMessageId}`,
|
||||
`${defaultCharacterChatPath}?image=${encodeURIComponent(paidImageDisplayMessageId)}`,
|
||||
);
|
||||
|
||||
await switchToEmailSignIn(page);
|
||||
await submitEmailLogin(page, {
|
||||
expectedUrl: paidImageOverlayUrl,
|
||||
});
|
||||
|
||||
await setEmailSessionStorage(page);
|
||||
const unlockRequestPromise = page.waitForRequest(
|
||||
"**/api/chat/unlock-private",
|
||||
);
|
||||
await page.goto(`${defaultCharacterChatPath}?image=${paidImageMessageId}`);
|
||||
await submitEmailLogin(page, {
|
||||
expectedUrl: paidImageOverlayUrl,
|
||||
});
|
||||
|
||||
const unlockRequest = await unlockRequestPromise;
|
||||
expect(unlockRequest.postDataJSON()).toMatchObject({
|
||||
@@ -92,7 +91,7 @@ test("guest can unlock a paid image after email login and subscription payment",
|
||||
|
||||
await expect(page).toHaveURL(
|
||||
new RegExp(
|
||||
`${defaultCharacterChatPath}(?:\\?image=msg_photo_paywall_001)?$`,
|
||||
`${defaultCharacterChatPath}(?:\\?image=${encodeURIComponent(paidImageDisplayMessageId)})?$`,
|
||||
),
|
||||
);
|
||||
expect(new URL(page.url()).pathname).toBe(defaultCharacterChatPath);
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
import { mockCoreApis } from "@e2e/fixtures/api-mocks";
|
||||
import { paidImageMessageId } from "@e2e/fixtures/test-data";
|
||||
import {
|
||||
paidImageDisplayMessageId,
|
||||
paidImageMessageId,
|
||||
} from "@e2e/fixtures/test-data";
|
||||
import {
|
||||
clearBrowserState,
|
||||
defaultCharacterChatPath,
|
||||
@@ -12,7 +15,7 @@ import {
|
||||
} from "@e2e/fixtures/test-helpers";
|
||||
|
||||
const paidImageOverlayUrl = new RegExp(
|
||||
`${defaultCharacterChatPath}\\?image=${paidImageMessageId}$`,
|
||||
`${defaultCharacterChatPath}\\?image=${encodeURIComponent(paidImageDisplayMessageId)}$`,
|
||||
);
|
||||
|
||||
test.beforeEach(async ({ baseURL, context, page }) => {
|
||||
|
||||
Reference in New Issue
Block a user