test(e2e): fix auth specs for character routes

This commit is contained in:
2026-07-20 15:38:51 +08:00
parent 7967486af7
commit bc6373f4c0
7 changed files with 62 additions and 5 deletions
@@ -5,8 +5,11 @@ import {
clearBrowserState,
defaultCharacterSidebarPath,
defaultCharacterSplashPath,
defaultCharacterChatUrl,
enterChatFromSplash,
getSplashStartChatButton,
signInWithEmailAndOpenChat,
submitEmailLogin,
switchToEmailSignIn,
} from "@e2e/fixtures/test-helpers";
test.beforeEach(async ({ baseURL, context, page }) => {
@@ -17,11 +20,19 @@ test.beforeEach(async ({ baseURL, context, page }) => {
test("user can log out from the sidebar after email login", async ({
page,
}) => {
await signInWithEmailAndOpenChat(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 expect(page.getByRole("button", { name: "Menu" })).toBeVisible();
await page.getByRole("button", { name: "Menu" }).click();
await expect(page).toHaveURL(new RegExp(`${defaultCharacterSidebarPath}$`));
await expect(page).toHaveURL(
new RegExp(defaultCharacterSidebarPath.replace("?", "\\?") + "$"),
);
const logoutRequestPromise = page.waitForRequest("**/api/auth/logout");
await page.getByRole("button", { name: /Log out/i }).click();