Files
lotteryLaravel/e2e/global-setup.ts
kang 6ec9634704
Some checks failed
lotterLaravel CI / test (push) Has been cancelled
feat: 添加E2E测试环境配置支持
添加LOTTERY_E2E环境变量来控制E2E测试相关功能,
包括绕过验证码、登录限制和钱包API URL验证,
同时更新composer.json以包含E2E专用的提供者和服务。
2026-06-18 14:42:22 +08:00

26 lines
853 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Playwright global setup指向 mock 主站钱包、tick 期号调度。
*/
import { request as pwRequest } from '@playwright/test';
export default async function globalSetup(): Promise<void> {
const api = process.env.PLAYWRIGHT_API_URL ?? 'http://127.0.0.1:8000';
const mockPort = process.env.E2E_MOCK_WALLET_PORT ?? '5555';
const ctx = await pwRequest.newContext({ baseURL: api });
const walletResp = await ctx.post('/api/v1/_e2e/site/wallet-api', {
data: {
base_url: `http://127.0.0.1:${mockPort}`,
wallet_api_key: 'e2e-mock-key',
},
});
if (!walletResp.ok()) {
const body = await walletResp.text().catch(() => '');
throw new Error(`e2e wallet-api setup failed: ${walletResp.status()} ${body.slice(0, 400)}`);
}
await ctx.post('/api/v1/_e2e/draw/tick', { data: {} });
await ctx.dispose();
}