23 lines
1.3 KiB
TypeScript
23 lines
1.3 KiB
TypeScript
import type { Page } from "@playwright/test";
|
|
|
|
import { apiEnvelope } from "../data/common";
|
|
import { createPaymentOrderResponse, paidPaymentOrderStatusResponse, paymentPlansResponse, tipPaymentPlansResponse, vipStatusResponse } from "../data/payment";
|
|
|
|
export async function registerPaymentMocks(page: Page) {
|
|
await page.route("**/api/payment/commercial-offers/*/accept", async (route) => route.fulfill({ json: apiEnvelope({
|
|
commercialOfferId: "13ec8a10-58d7-4d24-b66b-8db5699a1aa8",
|
|
planId: "vip_annual",
|
|
subscriptionType: "vip",
|
|
discountPercent: 30,
|
|
pricePercent: 70,
|
|
expiresAt: "2026-07-24T08:00:00+00:00",
|
|
message: "I got it for you.",
|
|
promotionType: "commercial_seven_discount",
|
|
}) }));
|
|
await page.route("**/api/payment/plans**", async (route) => route.fulfill({ json: apiEnvelope(paymentPlansResponse) }));
|
|
await page.route("**/api/payment/tip-plans**", async (route) => route.fulfill({ json: apiEnvelope(tipPaymentPlansResponse) }));
|
|
await page.route("**/api/payment/create-order", async (route) => route.fulfill({ json: apiEnvelope(createPaymentOrderResponse) }));
|
|
await page.route("**/api/payment/order-status**", async (route) => route.fulfill({ json: apiEnvelope(paidPaymentOrderStatusResponse) }));
|
|
await page.route("**/api/payment/vip-status", async (route) => route.fulfill({ json: apiEnvelope(vipStatusResponse) }));
|
|
}
|