33 lines
967 B
TypeScript
33 lines
967 B
TypeScript
import type { Page } from "@playwright/test";
|
|
|
|
import {
|
|
apiEnvelope,
|
|
chatSendResponse,
|
|
emptyChatHistoryResponse,
|
|
guestLoginResponse,
|
|
paymentPlansResponse,
|
|
vipStatusResponse,
|
|
} from "./test-data";
|
|
|
|
export async function mockCoreApis(page: Page): Promise<void> {
|
|
await page.route("**/api/auth/guest", async (route) => {
|
|
await route.fulfill({ json: apiEnvelope(guestLoginResponse) });
|
|
});
|
|
|
|
await page.route("**/api/chat/history**", async (route) => {
|
|
await route.fulfill({ json: apiEnvelope(emptyChatHistoryResponse) });
|
|
});
|
|
|
|
await page.route("**/api/chat/send", async (route) => {
|
|
await route.fulfill({ json: apiEnvelope(chatSendResponse) });
|
|
});
|
|
|
|
await page.route("**/api/payment/plans**", async (route) => {
|
|
await route.fulfill({ json: apiEnvelope(paymentPlansResponse) });
|
|
});
|
|
|
|
await page.route("**/api/payment/vip-status**", async (route) => {
|
|
await route.fulfill({ json: apiEnvelope(vipStatusResponse) });
|
|
});
|
|
}
|