Files
cozsweet-frontend-nextjs/e2e/specs/mock/auth/logout-from-profile.spec.ts
T
Codex 30122a44db
Docker Image / Build and Push Docker Image (push) Successful in 2m7s
fix(multi-role): enable Maya and Nayeli commercial flows
2026-07-23 10:24:13 +08:00

49 lines
1.6 KiB
TypeScript

import { expect, test } from "@playwright/test";
import { mockCoreApis } from "@e2e/fixtures/api-mocks";
import {
clearBrowserState,
defaultCharacterProfilePath,
defaultCharacterSplashPath,
defaultCharacterChatUrl,
enterChatFromSplash,
getSplashStartChatButton,
submitEmailLogin,
switchToEmailSignIn,
} from "@e2e/fixtures/test-helpers";
test.beforeEach(async ({ baseURL, context, page }) => {
await clearBrowserState(context, page, baseURL);
await mockCoreApis(page);
});
test("user can log out from the profile after email login", async ({
page,
}) => {
await enterChatFromSplash(page);
await page
.getByRole("button", { name: "Sign up to unlock more features" })
.click();
await expect(page).toHaveURL(/\/auth(?:\?.*)?$/);
await switchToEmailSignIn(page);
await submitEmailLogin(page, { expectedUrl: defaultCharacterChatUrl });
await page.getByRole("link", { name: "Back to home" }).click();
await expect(page).toHaveURL(
new RegExp(defaultCharacterSplashPath.replace("?", "\\?") + "$"),
);
await page.getByRole("button", { name: "Menu" }).click();
await expect(page).toHaveURL(
new RegExp(defaultCharacterProfilePath.replace("?", "\\?") + "$"),
);
const logoutRequestPromise = page.waitForRequest("**/api/auth/logout");
await page.getByRole("button", { name: /Log out/i }).click();
const logoutRequest = await logoutRequestPromise;
expect(logoutRequest.method()).toBe("POST");
await expect(page).toHaveURL(new RegExp(`${defaultCharacterSplashPath}$`));
await expect(getSplashStartChatButton(page)).toBeVisible();
});