test(miner-ui): add unit coverage for chat-scroll stick-to-bottom logic - #7847
Conversation
apps/loopover-miner-ui/src/lib/chat-scroll.ts (isChatViewportNearBottom, scrollChatViewportToBottom, CHAT_NEAR_BOTTOM_PX) had no direct test despite already needing a dedicated bug-fix once (JSONbored#7229/JSONbored#7298), and message-list.test.tsx only covers DOM structure, not the scroll math. Add a co-located unit test following the one-test-per-pure-module convention (demo-data.test.ts): cover isChatViewportNearBottom's <= 80px boundary on both sides, short-content and custom-threshold cases, and scrollChatViewportToBottom's Math.max(0, ...) clamp.
|
🚨 Contributor flagged. Click here for more info: Superagent Dashboard |
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
|
Warning ⏸️ LoopOver review result - manual review recommendedReview updated: 2026-07-21 15:08:15 UTC
Review summary Nits — 3 non-blocking
Flagged checks (non-blocking)
Decision drivers
Context & advisory signals — never blocks the verdict
Linked issue satisfactionAddressed Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://loopover.ai/docs/loopover-commands 🧪 Experimental — new and may change. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.
|
What & why
Closes #7793.
apps/loopover-miner-ui/src/lib/chat-scroll.ts(isChatViewportNearBottom,scrollChatViewportToBottom,CHAT_NEAR_BOTTOM_PX) encodes the boundary threshold and clamp math for the chat stick-to-bottom auto-scroll — fiddly logic that already needed a dedicated bug-fix once (#7229/#7298). No test exercised it directly:message-list.test.tsxonly checks DOM structure/StateBoundary branches, and jsdom doesn't meaningfully simulatescrollTop/scrollHeightthere. This closes that gap, following the one-test-per-pure-module conventiondemo-data.test.tsestablishes in the same directory.What's tested (a co-located
chat-scroll.test.ts)isChatViewportNearBottom: distance 0 (at bottom); exactly at the 80px boundary (<= 80→ true) and one pixel past it (81 > 80→ false) — the both-sides boundary case that motivated the prior bug-fix; scrolled well up → false; short content (viewport taller than content, negative distance) → true; a custom threshold overriding the default (proving the arg is used); and thatCHAT_NEAR_BOTTOM_PX === 80.scrollChatViewportToBottom: setsscrollToptoscrollHeight - clientHeightfor scrollable content, and theMath.max(0, …)clamp pinning it to 0 when content is shorter than the viewport.Pure coverage addition — no source change. Per the issue,
apps/loopover-miner-uiis not under thesrc/**99% patch gate; this new test file is the issue's own coverage deliverable.Validation
apps/loopover-miner-uivitest run: 9 tests pass;tsc --noEmitexit 0; eslint clean; Prettier clean.<=→<) and dropping theMath.max(0, …)clamp each fail a test.main, mergeable-clean.