fix(graph): root-cause flaky Pixi canvas race; scope Mermaid e2e locators#140
Conversation
…tors
Two documented flaky e2e tests, fixed at the source rather than absorbed
by CI retries.
graph.spec.ts "renders a nonblank Pixi graph canvas": under React
StrictMode's dev double-invoke the graph runs two createPixiGraphEngine()
inits concurrently. The canvas was attached via mount.replaceChildren()
inside the async factory — outside the effect's `active` guard — so a
slower-resolving stale init could clobber the live engine's canvas and then
empty the mount when its destroy() fired, leaving data-ready="true" over a
canvas-less stage. GraphCanvas now attaches the canvas only inside the
active guard (engine exposes a `canvas` getter); the discarded init never
touches the DOM. Production rendering is unchanged (no StrictMode there →
single attach). The spec also gates on data-render-count >= 1 before reading
the canvas contract.
wiki.spec.ts + theme.spec.ts Mermaid disclosure clicks: a bare
getByText("flowchart") also matched the <style> Mermaid injects (CSS that
mentions "flowchart"), so once a diagram had rendered the locator resolved to
two nodes and .click() threw a strict-mode violation. Both specs now scope to
the <summary> element.
Verified: graph.spec 6/6 + cold-start green (reproducibly failed before),
full e2e 57 passed / 2 skipped, vitest 910 passed, typecheck + lint clean.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughVersion bumped to 0.8.6 with two fixes: ChangesPixi StrictMode race fix and Mermaid locator scoping
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
What
Fixes the two documented flaky e2e tests at the source instead of leaning on CI retries.
1.
graph.spec.ts > renders a nonblank Pixi graph canvas(the primary documented flake)Root cause is a real StrictMode-only race in
GraphCanvas, not test timing:createPixiGraphEngine()inits concurrently.mount.replaceChildren(app.canvas)inside the async factory, i.e. outside the effect'sactiveguard.replaceChildrenclobbered the live canvas, and its subsequentdestroy()then emptied the mount entirely — leavingdata-ready="true"over a canvas-less stage. The one-shotpage.evaluatethen threwGraph Pixi stage was not rendered.retries: 2masked it on CI but [occasionally still lost all 3 attempts].Fix:
GraphCanvasattaches the canvas only inside the active guard (the engine now exposes acanvasgetter); the discarded init never touches the DOM. Production rendering is unchanged — no StrictMode double-invoke there, so it's a single attach as before. The spec additionally gates ondata-render-count >= 1(the reliable signal its sibling test already uses) before reading the canvas contract.2.
wiki.spec.ts+theme.spec.tsMermaid disclosure clicksA bare
getByText("flowchart")also matched the<style>Mermaid injects (its CSS mentionsflowchart). Confirmed empirically: once a diagram has rendered, the locator resolves to 2 nodes (summary + style) →.click()throws a Playwright strict-mode violation. Both specs now scope to the<summary>element (locator("summary", { hasText: "flowchart" })), which resolves to exactly 1.The
playwright.config.tsretries comment is updated (retries kept as a general backstop, no longer the primary mitigation for this test).Verification
graph.spec.ts6/6 consecutive passes + a cold-start full run green (it reproducibly failed before the fix).vitest: 910 passed (72 files);tsc --noEmitclean; ESLint clean; Prettier clean.Notes
package.jsonbumped0.8.5 → 0.8.6;CHANGELOG.mdentry added.🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Chores