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 -1
View File
@@ -1,7 +1,7 @@
import type { Page } from "@playwright/test";
import { apiEnvelope } from "../data/common";
import { chatSendResponse, createChatSendResponse, createPaidImageHistoryResponse, createWeeklyLimitChatSendResponse, emptyChatHistoryResponse, insufficientCreditsUnlockImageResponse, insufficientCreditsUnlockVoiceResponse, paidImageChatSendResponse, paidImageUnlockHistoryResponse, paidVoiceHistoryResponse } from "../data/chat";
import { chatSendResponse, createChatSendResponse, createPaidImageHistoryResponse, createWeeklyLimitChatSendResponse, emptyChatHistoryResponse, emptyChatPreviewsResponse, insufficientCreditsUnlockImageResponse, insufficientCreditsUnlockVoiceResponse, paidImageChatSendResponse, paidImageUnlockHistoryResponse, paidVoiceHistoryResponse } from "../data/chat";
export interface ChatMockOptions {
chatLimitTriggerAt?: number;
@@ -31,6 +31,10 @@ export async function registerChatMocks(page: Page, options: ChatMockOptions, st
await route.fulfill({ json: apiEnvelope(response) });
});
await page.route("**/api/chat/previews", async (route) => {
await route.fulfill({ json: apiEnvelope(emptyChatPreviewsResponse) });
});
await page.route("**/api/chat/send", async (route) => {
sendCount += 1;
const requestBody = route.request().postDataJSON() as { message?: unknown } | undefined;