Files
Genarrative/src/services/frontendRuntimeConfigService.test.ts
T
kdletters 00ff425e03 改造充值订单过期补偿流程
新增 SpacetimeDB 原生充值订单过期 timer 与 expired 状态。

移除 api-server 轮询 worker,改为 HTTP 角色订阅 Pending 到 Expired 事件并查单补偿。

统一微信下单 5 分钟 time_expire,并恢复前端支付通道选择与 expired 展示。

补齐生成绑定、前后端契约、测试和项目文档。
2026-07-10 01:37:53 +08:00

45 lines
1.2 KiB
TypeScript

import { beforeEach, describe, expect, it, vi } from 'vitest';
const apiClientMocks = vi.hoisted(() => ({
requestJson: vi.fn(),
}));
vi.mock('./apiClient', async () => {
const actual =
await vi.importActual<typeof import('./apiClient')>('./apiClient');
return {
...actual,
requestJson: apiClientMocks.requestJson,
};
});
import { loadFrontendRuntimeConfig } from './frontendRuntimeConfigService';
describe('frontendRuntimeConfigService', () => {
beforeEach(() => {
vi.clearAllMocks();
apiClientMocks.requestJson.mockResolvedValue({
imageEditorAgentSidebarEnabled: false,
});
});
it('loads frontend runtime config with local auth impact', async () => {
await expect(loadFrontendRuntimeConfig()).resolves.toEqual({
imageEditorAgentSidebarEnabled: false,
});
expect(apiClientMocks.requestJson).toHaveBeenCalledWith(
'/api/runtime/frontend-config',
{ method: 'GET' },
'读取前端运行时配置失败',
{
authImpact: 'local',
skipAuth: true,
skipRefresh: true,
notifyAuthStateChange: false,
clearAuthOnUnauthorized: false,
},
);
});
});