Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
test(desktop): 用文件级 beforeAll 焐热 SUT 冷 import (#3685)
Lizi6e114a3576a1
diff --git a/apps/desktop/src/main/maker-host/__tests__/codexProxyHost.test.ts b/apps/desktop/src/main/maker-host/__tests__/codexProxyHost.test.tsindex bbbc3b75ac..021039c44a 100644--- a/apps/desktop/src/main/maker-host/__tests__/codexProxyHost.test.ts+++ b/apps/desktop/src/main/maker-host/__tests__/codexProxyHost.test.ts@@ -1,7 +1,7 @@import fs from 'node:fs';import os from 'node:os';import path from 'node:path';-import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';+import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';import { TEST_XD_GATEWAY_BASE_URL as XD_GATEWAY_BASE_URL } from '../../../test/vitest/clientEndpointsFixture';type Registry = {@@ -142,6 +142,14 @@ async function freshCodexProxyHost() {return import('../codex-proxy-host.js');}+// CI 忙时本文件首次 import SUT 要付 Vitest transform 整个模块图的冷启动钱:Linux 分片+// 实测超默认 5s,Windows 分片超 15s,继续抬单测超时只是把死亡线后推。这笔成本属于环境+// 冷启动,不属于任何断言 —— 文件级 beforeAll 先把模块图焐热(hook 超时独立计),之后各+// 用例里 resetModules + import 只剩模块求值开销,回到默认超时内。+beforeAll(async () => {+ await import('../codex-proxy-host.js');+}, 60_000);+describe('withCodexUpstreamRecording', () => {const DEFAULT_UPSTREAM = 'https://gateway.example/v1';const ctxFor = (threadId?: string) => ({@@ -151,7 +159,6 @@ describe('withCodexUpstreamRecording', () => {headers: threadId ? { 'thread-id': threadId } : {},}) as never;- // Linux CI shard 下本文件首次 resetModules + import SUT 经常超过默认 5s;断言未变。it('records the override upstream origin for the request thread', async () => {const host = await freshCodexProxyHost();host.resetCodexThreadUpstreamForTest();@@ -166,7 +173,7 @@ describe('withCodexUpstreamRecording', () => {expect(host.getCodexThreadUpstreamOrigin('t-xai')).toBe('https://api.x.ai');// 没记录过的 thread 不借用别人的结论。expect(host.getCodexThreadUpstreamOrigin('t-other')).toBe(null);- }, 15_000);+ });it('falls back to the default upstream when the decision does not override it', async () => {const host = await freshCodexProxyHost();