import { beforeEach, describe, expect, it, vi } from 'vitest'; const apiClientMocks = vi.hoisted(() => ({ requestJson: vi.fn(), })); vi.mock('./apiClient', async () => { const actual = await vi.importActual('./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, }, ); }); });