feat(private-zone): add paid video moments

This commit is contained in:
Codex
2026-07-24 20:17:28 +08:00
parent ff2759cf0f
commit a44fc4860e
25 changed files with 1578 additions and 43 deletions
+35 -3
View File
@@ -13,6 +13,7 @@ const characters = [
displayName: "Elio Silvestri",
shortName: "Elio",
cover: "elio.png",
splashCover: "elio.png",
},
{
id: "maya-tan",
@@ -20,6 +21,7 @@ const characters = [
displayName: "Maya Tan",
shortName: "Maya",
cover: "maya.webp",
splashCover: "maya-home.webp",
},
{
id: "nayeli-cervantes",
@@ -27,6 +29,7 @@ const characters = [
displayName: "Nayeli Cervantes",
shortName: "Nayeli",
cover: "nayeli.webp",
splashCover: "nayeli.webp",
},
] as const;
@@ -56,9 +59,11 @@ for (const character of characters) {
await page.goto(`/characters/${character.slug}/splash`);
const cover = page.locator(`img[src*="${character.cover}"]`);
const cover = page.locator(`img[src*="${character.splashCover}"]`);
await expect(cover).toBeVisible();
await expect(page.getByText(character.displayName).last()).toBeVisible();
await expect(
page.getByRole("navigation", { name: "Primary navigation" }),
).toContainText("Private Zone");
await expect
.poll(() =>
cover.evaluate((image: HTMLImageElement) =>
@@ -84,6 +89,13 @@ for (const character of characters) {
test(`${character.displayName} can open a character-scoped Private Zone`, async ({
page,
}) => {
const momentsRequest = page.waitForRequest((request) => {
const url = new URL(request.url());
return (
url.pathname === "/api/private-zone/posts" &&
url.searchParams.get("characterId") === character.id
);
});
const albumRequest = page.waitForRequest((request) => {
const url = new URL(request.url());
return (
@@ -94,7 +106,11 @@ for (const character of characters) {
await page.goto(`/characters/${character.slug}/private-zone`);
await albumRequest;
await Promise.all([momentsRequest, albumRequest]);
await expect(
page.getByRole("heading", { name: "Private moments" }),
).toBeVisible();
await page.getByRole("tab", { name: "Albums" }).click();
await expect(
page.getByRole("heading", { name: "Private albums" }),
).toBeVisible();
@@ -147,11 +163,27 @@ test("a real Private Zone request failure still offers Retry", async ({
await page.goto("/characters/maya/private-zone");
await page.getByRole("tab", { name: "Albums" }).click();
await expect(page.getByRole("button", { name: "Retry" })).toBeVisible();
await expect(page.getByRole("button", { name: "Refresh" })).toHaveCount(0);
});
async function registerMultiRoleCommercialMocks(page: Page): Promise<void> {
await page.route("**/api/private-zone/posts**", async (route) => {
const url = new URL(route.request().url());
const characterId = url.searchParams.get("characterId") ?? "elio";
await route.fulfill({
json: apiEnvelope({
characterId,
items: [],
nextCursor: null,
hasMore: false,
creditBalance: 1000,
currency: "credits",
}),
});
});
await page.route("**/api/private-zone/albums**", async (route) => {
const url = new URL(route.request().url());
const characterId = url.searchParams.get("characterId") ?? "elio";