test(api): kimi-code spec inherits queued one-shot fetch responses, so shuffled order changes results
維護者通常 3 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 新手友好度
- 77/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- typescript
- 領域
- testing
研究方向
從 src/api/providers/__tests__/kimi-code.spec.ts 開始,著重查看第 181 和 204 行附近的 401 重試測試,以及「does not force-refresh on non-401 OAuth failures」測試。閱讀 src/test-utils/reset.ts,了解 clearAllMocks() 會重設哪些內容,接著使用 seed 100 執行 issue 中的 Vitest 隨機排序命令。完成條件是 spec 在隨機排序下通過,而且非 401 測試無法取用由較早測試排入佇列的回應。
由索引模型根據 Issue 內容生成。
描述
Symptom
src/api/providers/__tests__/kimi-code.spec.ts is order dependent. Under --sequence.shuffle at seed 100 the test "does not force-refresh on non-401 OAuth failures" resolves instead of rejecting. It passes in declaration order, which is what CI runs.
Measured
- Fails at abort-signal head
2f0d1d878518and also at the previous head780688ab2f67with this round's edits reverted, and it fails when that spec is run alone under the same seed. - Passes in declaration order at both heads.
- Repro:
cd src && npx vitest run api/providers/__tests__/kimi-code.spec.ts --sequence.shuffle --seed 100
Cause
The suite's beforeEach calls clearAllMocks() from src/test-utils/reset.ts, which is vi.clearAllMocks(). That clears mock.calls, instances and results but keeps implementations, so a response queued with mockResolvedValueOnce by an earlier test - here the 401-retry tests around lines 181 and 204, which queue globalThis.fetch responses - is still in the queue when the next test starts. Under shuffle the 500-path test can therefore consume a queued 401-body response from the previous test and take the refresh branch it is supposed to prove does not happen.
export function clearAllMocks(): void {
vi.clearAllMocks()
}
Expected
The suite must not depend on execution order. Either reset the once-queues between tests - mockReset() on the mocks that receive queued-once responses, or a helper in test-utils/reset.ts that also drops queued implementations - or give each test its own fetch stub in the test body instead of inheriting a queue. A test that asserts a refresh did not happen should not be able to inherit the response a previous test queued.
Why it matters
The abort-signal series adds tests that queue one-shot fetch responses around OAuth refresh. Every added test increases the chance that a shuffle exposes this, and CI moving to randomised order would turn it into a permanent flake.
- 主要語言
- TypeScript
- 星號
- 2k
- 分支
- 301
- 平均合併
- 3 天 14 小時
- 30 天內合併 PR
- 103
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
Zoo-Code-Org/Zoo-Code 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 70/100
Zoo-Code-Org/Zoo-Code#2773 · 1 則留言 ·
維護者通常 3 天內回覆
-
難度 2/5 1-3 小時 新手友好度 68/100
Zoo-Code-Org/Zoo-Code#2717 · 1 則留言 ·
維護者通常 3 天內回覆
-
fix(scripts): stryker-diff.mjs spawns the extensionless .bin shim and cannot run on Windows可能已有人在做 @easonLiangWorldedtech 於 16 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
Zoo-Code-Org/Zoo-Code#2514 ·
維護者通常 3 天內回覆
-
[BUG] search_files hides matching text on long lines可能已有人在做 @DananjayaNadun 於 9 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 74/100
Zoo-Code-Org/Zoo-Code#2496 · 1 則留言 · 已指派 1 人 ·
維護者通常 3 天內回覆
-
難度 2/5 1-3 小時 新手友好度 68/100
Zoo-Code-Org/Zoo-Code#2493 ·
維護者通常 3 天內回覆
查看 Zoo-Code-Org/Zoo-Code 的全部 Issue
相似的 Issue
-
enhancement feature/signals self-driving team/self-driving
難度 2/5 1-3 小時 新手友好度 78/100
PostHog/posthog#144208 · 1 則留言 ·
維護者通常 1 天內回覆
-
bug good first issue web
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
triage: not actionable
難度 2/5 1-3 小時 新手友好度 66/100
oxc-project/oxc#30518 · 1 則留言 ·
維護者通常 1 天內回覆
-
bug Claude useability
難度 2/5 1-3 小時 新手友好度 78/100
-
難度 2/5 1-3 小時 新手友好度 70/100
wazuh/wazuh-dashboard-plugins#9751 ·
維護者通常 1 天內回覆