fix(test): PORT-007 fails on hidden tooltip copy, not on a rendered banner - #2458
fix(test): PORT-007 fails on hidden tooltip copy, not on a rendered banner#2458dcccrypto wants to merge 1 commit into
Conversation
…anner The Risk Lev. label swapped its `title=` attribute for an <InfoIcon> (90be44c). <Tooltip> keeps its copy mounted permanently and hides it with inline visibility/opacity (it animates in on hover), so the text is invisible to users but still visible to queryByText. RISK_LEVERAGE_TITLE ends with '...Extra collateral lowers liquidation risk.', which the /i assertion in PORT-007 'renders nothing when no position is at risk' then matched — failing on hidden tooltip prose rather than on a rendered AtRiskBanner. Scopes both negative assertions with `ignore: '[role="tooltip"]'`: hidden tooltip copy is not a rendered banner and must not satisfy them. Verified it still binds, not silenced: neutralising AtRiskBanner's `if (atRisk.length === 0) return null;` guard makes the test FAIL again, and restoring it passes. Deterministic, not flaky — fails 3/3 on fb53c2f, passes at b828e02 (before the tooltip change).
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 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 broke
Portfolio.test.tsx→ PORT-007 "renders nothing (zero height) when no position is at risk" now fails onplayground.It is deterministic, not flaky: fails 3/3 on
fb53c2ff, passes atb828e025(before the trade-UI batch).Root cause
90be44c0swapped the Risk Lev. label'stitle=attribute for an<InfoIcon tooltip={RISK_LEVERAGE_TITLE}>.<Tooltip>keeps its copy mounted permanently and hides it with inlinevisibility/opacity(it animates in on hover):So the text is invisible to users but still visible to
queryByText(which filters onlyscript, style). And:which the assertion
queryByText(/Liquidation risk/i)matches. The test was failing on hidden tooltip prose, not on a renderedAtRiskBanner.The component behaviour is intentional (that's how the animated tooltip works) — the assertion was too loose.
Fix
Scope both negative assertions with
ignore: '[role="tooltip"]'. Hidden tooltip copy is not a rendered banner, so it must not satisfy them. The sibling positive test already distinguishedAtRiskBannerfromPositionCard's per-row banner by case; this extends the same care to the negative case.Verification — it still binds, it is not silenced
An
ignorethat hides a failure would be worse than the bug, so I mutation-tested it:AtRiskBanner'sif (atRisk.length === 0) return null;guard neutralisedThe assertion still catches a genuinely mis-rendered banner.
Full suite (
app/), with the open test-repair PRs stacked: 2805 passed, 0 failed.Note
This was invisible to CI — see #2447:
Unit Tests/Integration Tests/Coverage Gatereport SKIPPED while the Merge Gate still reports SUCCESS.🤖 Generated with Claude Code