Skip to content

fix(tests): 修复凭证 tab 数硬编码与音频证据落盘竞态两条 CI 红 - #2839

Merged
wehos merged 2 commits into
mainfrom
fix/ci-red-tab-count-and-audio-evidence-race
Aug 13, 2026
Merged

fix(tests): 修复凭证 tab 数硬编码与音频证据落盘竞态两条 CI 红#2839
wehos merged 2 commits into
mainfrom
fix/ci-red-tab-count-and-audio-evidence-race

Conversation

@wehos

@wehos wehos commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

背景

main 从 #2819 合入后每次 push 都红,PR 上还叠了一条 Windows 独有的抖动。分诊下来是两条互相独立的测试自身问题,都不是产品缺陷。

1. 凭证 tab 数硬编码(main 持续红)

test_credentials_tabs_are_wired_to_the_single_tab_paneltab-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_dataawait recorder.close() 返回后立刻 target.iterdir()。但 close() 只给写线程 _ACK_TIMEOUT_SECONDS = 0.05 的确认窗口,超时静默返回——它本来就不是落盘保证。Windows runner 磁盘一抖,目录还没建出来就 FileNotFoundError: [WinError 3]

改成轮询等 index.jsonl 落地(上限 10s,正常路径下几毫秒返回)。不动生产的短超时语义:这是 opt-in 的调试功能,宁可丢证据也不卡关闭路径,为了测试把超时拉长会拖慢真实收尾。

变异验证

变异 期望 实测
tab-btn class 改名(正则失配) RED RED
合规新增第 12 个凭证源 GREEN GREEN
新增源漏 aria-controls RED RED
ack 超时归零 + 保留轮询 GREEN GREEN
ack 超时归零 + 撤掉轮询 RED RED

最后两行确认轮询不是空转——撤掉修复确实会变红。

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • 改进音频证据写入测试,支持异步目录和索引文件生成,减少因写入延迟导致的测试失败。
    • 更新凭证标签页校验,适应按钮数量变化,同时确保标签切换功能及无障碍属性保持正确。

两条互相独立、都不是产品缺陷,都是测试自身的问题:

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>
@cursor

cursor Bot commented Aug 12, 2026

Copy link
Copy Markdown

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.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 73088dd0-de9d-4c62-be85-59d9e54926c2

📥 Commits

Reviewing files that changed from the base of the PR and between 96caf59 and a33ad0d.

📒 Files selected for processing (2)
  • tests/unit/asr_client/endpointing/test_audio_evidence.py
  • tests/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)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/unit/test_window_pin_static_contracts.py

Walkthrough

本次更新包含两项测试调整:等待音频证据完整写入,并动态校验标签按钮与 switchTab 调用喵。

Changes

音频证据写入测试

Layer / File(s) Summary
异步写入等待与验证
tests/unit/asr_client/endpointing/test_audio_evidence.py
新增完整 JSON 记录计数和超时轮询逻辑。测试在读取运行目录前等待目标记录完成写入喵。

标签页静态契约

Layer / File(s) Summary
动态标签按钮契约
tests/unit/test_window_pin_static_contracts.py
移除固定的 10 个按钮断言。测试校验 switchTab 调用数大于零,并确保每个按钮恰好对应一次调用喵。

Estimated code review effort: 2 (Simple) | ~10 minutes

Mergeability Score: ⚪ Minimal · up to a33ad

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

异步记录逐行落盘喵
测试等待不再慌张喵
标签按钮动态校验喵
switchTab 调用对齐喵
契约通过喵

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed 标题准确概括了凭证 tab 数量断言和音频证据落盘竞态两项测试修复,内容清晰且具体喵。
Description check ✅ Passed 描述说明了背景、修改内容、设计理由、验证结果及生产代码影响,已覆盖模板要求的关键信息喵。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread tests/unit/asr_client/endpointing/test_audio_evidence.py Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6c5ad62 and 96caf59.

📒 Files selected for processing (2)
  • tests/unit/asr_client/endpointing/test_audio_evidence.py
  • tests/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)

Comment thread tests/unit/asr_client/endpointing/test_audio_evidence.py Outdated
Comment thread tests/unit/test_window_pin_static_contracts.py
回应 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>
@wehos
wehos merged commit 080a5b4 into main Aug 13, 2026
11 checks passed
@wehos
wehos deleted the fix/ci-red-tab-count-and-audio-evidence-race branch August 13, 2026 03:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant