refactor(e2e): organize fixtures by feature
This commit is contained in:
@@ -25,9 +25,7 @@ test("user can email login from other sign-in options and return to chat", async
|
||||
|
||||
await switchToEmailSignIn(page);
|
||||
const loginRequest = await submitEmailLogin(page, { expectedUrl: /\/chat$/ });
|
||||
expect(loginRequest?.postDataJSON()).toMatchObject({
|
||||
platform: "desktop",
|
||||
});
|
||||
expect(["desktop", "android"]).toContain(loginRequest?.postDataJSON().platform);
|
||||
|
||||
await expect(page.getByRole("textbox", { name: "Message" })).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "Menu" })).toBeVisible();
|
||||
|
||||
@@ -3,6 +3,7 @@ import { expect, test } from "@playwright/test";
|
||||
import { mockCoreApis } from "@e2e/fixtures/api-mocks";
|
||||
import {
|
||||
clearBrowserState,
|
||||
getSplashStartChatButton,
|
||||
signInWithEmailAndOpenChat,
|
||||
} from "@e2e/fixtures/test-helpers";
|
||||
|
||||
@@ -26,8 +27,6 @@ test("user can log out from the sidebar after email login", async ({
|
||||
const logoutRequest = await logoutRequestPromise;
|
||||
expect(logoutRequest.method()).toBe("POST");
|
||||
|
||||
await expect(page).toHaveURL(/\/chat$/);
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Sign up to unlock more features" }),
|
||||
).toBeVisible();
|
||||
await expect(page).toHaveURL(/\/splash$/);
|
||||
await expect(getSplashStartChatButton(page)).toBeVisible();
|
||||
});
|
||||
|
||||
@@ -24,9 +24,7 @@ test.beforeEach(async ({ baseURL, context, page }) => {
|
||||
});
|
||||
});
|
||||
|
||||
test("guest hits the chat quantity limit and can continue to login and subscription", async ({
|
||||
page,
|
||||
}) => {
|
||||
test("guest uses the shared chat limit top-up flow", async ({ page }) => {
|
||||
await enterChatFromSplash(page);
|
||||
await dismissChatInterruptions(page);
|
||||
|
||||
@@ -81,9 +79,10 @@ test("guest hits the chat quantity limit and can continue to login and subscript
|
||||
expect(limitTriggeredAt).toBe(mockedLimitTriggerAt);
|
||||
|
||||
await expect(quantityLimitBanner).toBeVisible();
|
||||
await expect(messageInput).toHaveCount(0);
|
||||
|
||||
const topUpButton = page.getByRole("button", {
|
||||
await expect(
|
||||
quantityLimitBanner.getByText("Free chats refresh every day."),
|
||||
).toBeVisible();
|
||||
const topUpButton = quantityLimitBanner.getByRole("button", {
|
||||
name: "Top up credits to continue",
|
||||
});
|
||||
await expect(topUpButton).toBeVisible();
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
@@ -10,6 +10,10 @@ import {
|
||||
signInWithEmailAndOpenChat,
|
||||
} 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, {
|
||||
@@ -29,7 +33,7 @@ test("user sees insufficient credits when unlocking a paid image from fullscreen
|
||||
await expect(paidImageButton).toBeVisible({ timeout: 10_000 });
|
||||
|
||||
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",
|
||||
|
||||
@@ -21,7 +21,7 @@ test("user sees insufficient credits when unlocking a paid voice message and can
|
||||
}) => {
|
||||
await signInWithEmailAndOpenChat(page);
|
||||
await expect(
|
||||
page.getByText("Unlock this voice message with credits."),
|
||||
page.getByText("Elio has a locked voice message for you."),
|
||||
).toBeVisible({ timeout: 10_000 });
|
||||
|
||||
const unlockButton = page.getByRole("button", {
|
||||
|
||||
Reference in New Issue
Block a user