Repository navigation
test(web): fix flaky ProjectFaviconPickerDialog preview test races - #29
Merged
Merged
Conversation
…rojectFaviconPickerDialog preview test The preview test failed intermittently in CI in two ways. A row only subscribes to its asset atom in a passive effect after the IntersectionObserver render that calls createUrl. The test publishes the URL as soon as createUrl is called, and the registry discards a value set on an atom with no subscriber, so the row could stay on its fallback forever. Keep the mocked asset atoms alive like other browser tests do. expectPreview also polled naturalWidth and then asserted the fallback was gone synchronously, but the image decodes before its load event commits. Poll the complete loaded state instead.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
关联 #28 #27
问题
apps/web/src/components/settings/ProjectFaviconPickerDialog.browser.test.tsx的loads previews asynchronously and only acquires offscreen images after scrolling在 CI Test Web 中偶发失败,两次的报错不同:AssertionError: expected SVGSVGElement{ …(2) } to be null,位置expectPreview:171,由 :192 调用。图片已解码(naturalWidth = 8),但回退图标还在。AssertionError: expected undefined to be 8(Matcher did not succeed in time),位置expectPreview:170,由 :203 调用。滚动到最后一行并发布 URL 后,该行始终没有<img>。两次都只有这一个用例失败(Tests 1 failed | 8473 passed)。
根因
ProjectFaviconThumbnail.tsx:13-31)在 IntersectionObserver 回调里setInView(true),重新渲染时调用createUrl;但useAtomValue(底层是useSyncExternalStore)要到之后的 passive effect 才订阅 atom。测试(:195-202)一看到createUrl被调用就publishUrl。effect 的AtomRegistry会在调度任务里移除没有订阅者的非 keepAlive 节点(AtomRegistry.jscreateNode/scheduleAtomRemoval),在这个窗口内写入的成功值会随节点一起丢掉,行订阅后读到的是初始值,永远不会出现<img>。CI 负载高时 passive effect 延后,这个窗口就更容易被命中。expectPreview(:169-172)先轮询naturalWidth === 8,然后同步断言回退 svg 已移除。但图片解码(naturalWidth 可用)早于load事件派发;组件在onLoad里setLoadedUrl并重新渲染后才移除回退图标(ProjectFaviconThumbnail.tsx:34-48)。同文件的keeps the file icon until the image load is acknowledged用例本身就说明,"naturalWidth 为 8 而 svg 仍在"是合法的中间状态。组件行为是正确的,问题都在测试本身。
改动(仅测试,1 个文件)
addFiles中的 mock asset atom 改为Atom.make(...).pipe(Atom.keepAlive)(与ProjectSettingsPanel.browser.test.tsx等现有测试的写法一致),这样无论订阅何时完成,发布的 URL 都不会丢。expectPreview改为轮询完整的最终状态{ width: 8, fallback: false },不再"轮询前置条件 + 同步断言"。验证(本地,Node 24 + 仓库内 vp,单文件运行)
load事件延迟 200ms 再派发。两个都失败,报错与 CI 一致:expected undefined to be 8和expected SVGSVGElement{ …(2) } to be null。换成修复后的 helper,同样两个用例都通过(9/9)。vp fmt --check和vp lint通过。未验证