Skip to content

chat-scroll.ts (auto-scroll stick-to-bottom logic) has zero test coverage despite a prior dedicated bug-fix PR #7793

Description

@JSONbored

Context

apps/loopover-miner-ui/src/lib/chat-scroll.ts (isChatViewportNearBottom/scrollChatViewportToBottom/CHAT_NEAR_BOTTOM_PX) encodes the boundary threshold (<= 80px) and clamp logic for the chat stick-to-bottom auto-scroll feature. Confirmed via repo-wide grep that these exports are referenced only from apps/loopover-miner-ui/src/components/chat/message-list.tsx, and no test file imports or exercises this module's logic directly — message-list.test.tsx's coverage only checks DOM structure/StateBoundary branches, not the scroll math (jsdom doesn't meaningfully simulate scrollTop/scrollHeight there anyway).

This is exactly the kind of fiddly, easy-to-regress logic that benefits most from a unit test: per git log, it already needed one dedicated bug-fix PR (8cbcb5379, #7229/#7298). The sibling pure-logic modules in the same directory (lib/demo-data.tsdemo-data.test.ts, lib/chat-portfolio-queue-resolve.ts → covered by chat-portfolio-queue-actions.test.tsx) establish a one-test-per-pure-module convention this file is the exception to.

The current implementation was verified logically correct against boundary/short-content cases — this is a coverage gap, not an active bug.

Requirements

Add a direct unit test file for chat-scroll.ts covering isChatViewportNearBottom's boundary condition (<= 80px threshold, both sides) and scrollChatViewportToBottom's clamp behavior, following the one-test-per-pure-module convention already established by demo-data.test.ts in the same directory.

Deliverables

Test Coverage Requirements

apps/loopover-miner-ui is not covered by the src/** 99% patch gate - the new test file is this issue's own coverage deliverable.

Expected Outcome

A future regression in the stick-to-bottom auto-scroll boundary/clamp logic is caught by a direct unit test instead of requiring another dedicated bug-fix PR to notice.

Links & Resources

apps/loopover-miner-ui/src/lib/chat-scroll.ts, apps/loopover-miner-ui/src/components/chat/message-list.tsx (the only consumer), apps/loopover-miner-ui/src/lib/demo-data.ts/demo-data.test.ts (the convention to follow), PR #7229/#7298 (the prior bug this logic already needed once)

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:bugGittensor-scored bug fix — scores a 0.05x multiplier.help wantedExtra attention is needed

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions