test(chat): enforce locked image URL masking
This commit is contained in:
@@ -19,10 +19,6 @@ import {
|
||||
switchToEmailSignIn,
|
||||
} from "@e2e/fixtures/test-helpers";
|
||||
|
||||
const paidImageOverlayUrl = new RegExp(
|
||||
`${defaultCharacterChatPath}\\?image=${encodeURIComponent(paidImageDisplayMessageId)}$`,
|
||||
);
|
||||
|
||||
test.beforeEach(async ({ baseURL, context, page }) => {
|
||||
await clearBrowserState(context, page, baseURL);
|
||||
await mockCoreApis(page, {
|
||||
@@ -48,26 +44,18 @@ test("guest can unlock a paid image after email login and subscription payment",
|
||||
message: "给我发图片",
|
||||
});
|
||||
|
||||
const paidImageButton = page.getByRole("button", {
|
||||
name: "Open image in fullscreen",
|
||||
const lockedImageCard = page.getByRole("group", {
|
||||
name: "Locked private image",
|
||||
}).last();
|
||||
await expect(paidImageButton).toBeVisible();
|
||||
|
||||
await paidImageButton.click();
|
||||
await expect(page).toHaveURL(paidImageOverlayUrl);
|
||||
|
||||
const lockedImageDialog = page.getByRole("dialog", {
|
||||
name: "Locked fullscreen image",
|
||||
});
|
||||
await expect(lockedImageDialog).toBeVisible();
|
||||
|
||||
await lockedImageDialog
|
||||
.getByRole("button", { name: "Unlock high-definition large image" })
|
||||
await expect(lockedImageCard).toBeVisible();
|
||||
await expect(lockedImageCard.locator("img")).toHaveCount(0);
|
||||
await lockedImageCard
|
||||
.getByRole("button", { name: "Unlock private image" })
|
||||
.click();
|
||||
|
||||
await expect(page).toHaveURL(/\/auth\?redirect=/);
|
||||
expect(new URL(page.url()).searchParams.get("redirect")).toBe(
|
||||
`${defaultCharacterChatPath}?image=${encodeURIComponent(paidImageDisplayMessageId)}`,
|
||||
defaultCharacterChatPath,
|
||||
);
|
||||
|
||||
await switchToEmailSignIn(page);
|
||||
@@ -75,7 +63,7 @@ test("guest can unlock a paid image after email login and subscription payment",
|
||||
"**/api/chat/unlock-private",
|
||||
);
|
||||
await submitEmailLogin(page, {
|
||||
expectedUrl: paidImageOverlayUrl,
|
||||
expectedUrl: new RegExp(`${defaultCharacterChatPath}$`),
|
||||
});
|
||||
|
||||
const unlockRequest = await unlockRequestPromise;
|
||||
|
||||
@@ -2,22 +2,16 @@ import { expect, test } from "@playwright/test";
|
||||
|
||||
import { mockCoreApis } from "@e2e/fixtures/api-mocks";
|
||||
import {
|
||||
paidImageDisplayMessageId,
|
||||
paidImageMessageId,
|
||||
} from "@e2e/fixtures/test-data";
|
||||
import {
|
||||
clearBrowserState,
|
||||
defaultCharacterChatPath,
|
||||
dismissChatInterruptions,
|
||||
expectInsufficientCreditsDialog,
|
||||
expectVipChatSubscriptionUrl,
|
||||
signInWithEmailAndOpenChat,
|
||||
} from "@e2e/fixtures/test-helpers";
|
||||
|
||||
const paidImageOverlayUrl = new RegExp(
|
||||
`${defaultCharacterChatPath}\\?image=${encodeURIComponent(paidImageDisplayMessageId)}$`,
|
||||
);
|
||||
|
||||
test.beforeEach(async ({ baseURL, context, page }) => {
|
||||
await clearBrowserState(context, page, baseURL);
|
||||
await mockCoreApis(page, {
|
||||
@@ -25,30 +19,23 @@ test.beforeEach(async ({ baseURL, context, page }) => {
|
||||
});
|
||||
});
|
||||
|
||||
test("user sees insufficient credits when unlocking a paid image from fullscreen and can navigate to subscription", async ({
|
||||
test("user sees insufficient credits when unlocking from the locked image card and can navigate to subscription", async ({
|
||||
page,
|
||||
}) => {
|
||||
await signInWithEmailAndOpenChat(page);
|
||||
await dismissChatInterruptions(page);
|
||||
|
||||
const paidImageButton = page.getByRole("button", {
|
||||
name: "Open image in fullscreen",
|
||||
const lockedImageCard = page.getByRole("group", {
|
||||
name: "Locked private image",
|
||||
}).last();
|
||||
await expect(paidImageButton).toBeVisible({ timeout: 10_000 });
|
||||
|
||||
await paidImageButton.click();
|
||||
await expect(page).toHaveURL(paidImageOverlayUrl);
|
||||
|
||||
const lockedImageDialog = page.getByRole("dialog", {
|
||||
name: "Locked fullscreen image",
|
||||
});
|
||||
await expect(lockedImageDialog).toBeVisible();
|
||||
await expect(lockedImageCard).toBeVisible({ timeout: 10_000 });
|
||||
await expect(lockedImageCard.locator("img")).toHaveCount(0);
|
||||
|
||||
const unlockRequestPromise = page.waitForRequest(
|
||||
"**/api/chat/unlock-private",
|
||||
);
|
||||
await lockedImageDialog
|
||||
.getByRole("button", { name: "Unlock high-definition large image" })
|
||||
await lockedImageCard
|
||||
.getByRole("button", { name: "Unlock private image" })
|
||||
.click();
|
||||
|
||||
const unlockRequest = await unlockRequestPromise;
|
||||
|
||||
Reference in New Issue
Block a user