fix(tests): 修复凭证 tab 数硬编码与音频证据落盘竞态两条 CI 红 - #2839
Conversation
两条互相独立、都不是产品缺陷,都是测试自身的问题: 1. test_credentials_tabs_are_wired_to_the_single_tab_panel 把 tab-btn 个数 锁死成 10。#2819 加了 QQ 音乐凭证源变成 11,main 自那以后每次 push 都红。 数量断言的真实作用只是防止正则失配测出 0 个假绿,改成和 switchTab 调用数 交叉比对:正则一失配立刻不等,新增凭证源不再误红。 2. test_audio_evidence_writes_local_wav_and_index_under_data 在 close() 返回后 立刻 iterdir。close() 只给写线程 50ms 确认窗口,本来就不是落盘保证, Windows runner 磁盘一抖就 FileNotFoundError。改成轮询等 index.jsonl 落地。 只动测试,不动生产的短超时语义(opt-in 调试功能,宁可丢证据也不卡关闭路径)。 变异验证:正则失配→红、漏 aria-controls→红、合规新增第 12 个源→绿; 把 ack 超时归零后带轮询→绿、撤掉轮询→红。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🔗 Linked repositories identifiedCodeRabbit considers these linked repositories for cross-repo context during reviews:
🚧 Files skipped from review as they are similar to previous changes (1)
Walkthrough本次更新包含两项测试调整:等待音频证据完整写入,并动态校验标签按钮与 Changes音频证据写入测试
标签页静态契约
Estimated code review effort: 2 (Simple) | ~10 minutes Mergeability Score: ⚪ Minimal · up to This PR makes two localized test-only fixes for brittle credential-tab counting and asynchronous audio evidence writes; no actionable merge-blocking risk remains beyond normal checks and review. Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 96caf59e8d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/unit/asr_client/endpointing/test_audio_evidence.py`:
- Around line 16-30: Update _wait_for_written_run_dir to consider a run ready
only after index.jsonl contains at least one complete, successfully parsed JSONL
record, rather than checking file existence alone. Add a validation predicate
for the expected record if appropriate, and make timeout failure explicit
instead of returning potentially incomplete directories.
Apply the same fix in `@tests/unit/asr_client/endpointing/test_audio_evidence.py`
at line 75.
In `@tests/unit/test_window_pin_static_contracts.py`:
- Around line 257-259: Update the assertions around switch_calls and tab_buttons
to count switchTab calls within each individual button, and in the existing
button-validation loop assert each button contains exactly one call. Retain the
dynamic count check while removing reliance on the template-wide count that can
include unrelated markup.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: bf9b651a-d845-4581-8962-8ea488556e60
📒 Files selected for processing (2)
tests/unit/asr_client/endpointing/test_audio_evidence.pytests/unit/test_window_pin_static_contracts.py
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
Project-N-E-K-O/N.E.K.O.-PC(manual)
回应 review 的两条: 1. index.jsonl 存在不等于写完 —— _writer_loop 是先 open 再 write 再 flush, 只判存在会读到空文件或半行,Windows 抖动下 assert len(records) == 1 照样红。 就绪条件改成能解析出足够条数的整行 JSON,超时改成显式报错带现场。 2. template.count 是全模板计数,"这里漏一次、别处多一次"能互相抵消。 循环里补一条每个按钮恰好一次调用的断言。保留全模板计数是有意的: 只从按钮里数会让总数相等退化成同义反复,丢掉正则部分失配的检测。 变异验证:漏按钮接线+别处补数→红、写线程 open 后卡住+新条件→绿、 同样卡住但退回只判 exists→红、正则部分失配→仍红。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
背景
main 从 #2819 合入后每次 push 都红,PR 上还叠了一条 Windows 独有的抖动。分诊下来是两条互相独立的测试自身问题,都不是产品缺陷。
1. 凭证 tab 数硬编码(main 持续红)
test_credentials_tabs_are_wired_to_the_single_tab_panel把tab-btn个数锁死成 10。#2819 加了 QQ 音乐凭证源变成 11,之后 main 上连红 4 次以上(#2811 / #2714 / #2823 / #2833 的 push run 全是这一条)。这个数量断言的真实作用只是防止正则失配测出 0 个按钮的假绿——凭证源本身会持续增删,锁死具体个数只会让每个新源都红一次。改成和
switchTab('调用数交叉比对:正则一失配立刻不等,新增源不再误红,逐按钮的role="tab"/aria-controls="main-panel"校验原样保留。2. 音频证据落盘竞态(Windows flake)
test_audio_evidence_writes_local_wav_and_index_under_data在await recorder.close()返回后立刻target.iterdir()。但close()只给写线程_ACK_TIMEOUT_SECONDS = 0.05的确认窗口,超时静默返回——它本来就不是落盘保证。Windows runner 磁盘一抖,目录还没建出来就FileNotFoundError: [WinError 3]。改成轮询等
index.jsonl落地(上限 10s,正常路径下几毫秒返回)。不动生产的短超时语义:这是 opt-in 的调试功能,宁可丢证据也不卡关闭路径,为了测试把超时拉长会拖慢真实收尾。变异验证
aria-controls最后两行确认轮询不是空转——撤掉修复确实会变红。
🤖 Generated with Claude Code
Summary by CodeRabbit