Skip to content

feat(widgets): add Scrollbar tests and fix StatusIndicator setters#699

Open
anirudhagarwal-dev wants to merge 1 commit into
Karanjot786:mainfrom
anirudhagarwal-dev:feat/widgets/scrollbar-tests
Open

feat(widgets): add Scrollbar tests and fix StatusIndicator setters#699
anirudhagarwal-dev wants to merge 1 commit into
Karanjot786:mainfrom
anirudhagarwal-dev:feat/widgets/scrollbar-tests

Conversation

@anirudhagarwal-dev
Copy link
Copy Markdown

@anirudhagarwal-dev anirudhagarwal-dev commented Jun 4, 2026

Description

This PR introduces a comprehensive unit test suite for the Scrollbar widget and fixes a state mutation bug in the StatusIndicator widget. It ensures that the scrollbar renders correctly across all orientations and that both widgets properly notify the renderer when their state changes.

Related Issue

Closes #670

Which package(s)?

@termuijs/widgets

Type of Change

  • 🐛 Bug fix (type:bug)
  • 🧪 Tests (type:testing)

Checklist

  • I have followed the structure of existing tests (e.g., Gauge.test.ts).
  • I have used the real Screen buffer for verification.
  • I have added this.markDirty() calls to state-mutating methods.
  • My changes are confined to the @termuijs/widgets package.
  • I have run bun run build && bun vitest run && bun run typecheck and all pass.

Screenshots (if applicable)

N/A - This is a testing and internal logic PR.

Additional Note for Reviewers

The Scrollbar tests cover:

  • Early return when content fits in viewport.
  • Correct track positioning for verticalRight, verticalLeft, horizontalTop, and horizontalBottom.
  • Proportional thumb placement math.
  • Arrow visibility toggling.

The StatusIndicator fix adds missing markDirty() calls to setStatus() and setLabel(), which were previously preventing the UI from refreshing when these values changed.

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • StatusIndicator now properly re-renders when its status or label is updated, eliminating the need for external render triggers.
  • Tests

    • Added comprehensive test coverage for the Scrollbar widget to verify correct rendering across different orientations and configuration changes.

@github-actions github-actions Bot added needs-star PR author has not starred the repo. type:feature +10 pts. New feature. labels Jun 4, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 4, 2026

Hi @anirudhagarwal-dev 👋

Star this repo before your PR merges.

Why? GSSoC 2026 contributors who star get priority review and points credit. After you star, push any commit (or re-run this check). The needs-star label lifts automatically.

Thanks for your contribution to TermUI.

@github-actions github-actions Bot added area:widgets @termuijs/widgets type:testing +10 pts. Tests. labels Jun 4, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 475f3220-0cb1-468d-9688-23aba7381722

📥 Commits

Reviewing files that changed from the base of the PR and between c36cc8c and 202e1f9.

📒 Files selected for processing (2)
  • packages/widgets/src/data/StatusIndicator.ts
  • packages/widgets/src/feedback/Scrollbar.test.ts

📝 Walkthrough

Walkthrough

This PR adds a markDirty call to StatusIndicator's setStatus and setLabel methods to ensure re-rendering on state changes, and introduces a comprehensive 179-line Vitest suite for Scrollbar covering edge cases, all orientation modes, arrow toggling, proportional thumb positioning, and state mutation verification.

Changes

Widget state mutation and rendering

Layer / File(s) Summary
StatusIndicator markDirty fix
packages/widgets/src/data/StatusIndicator.ts
setStatus(isUp) and setLabel(label) now call markDirty() after state mutations to ensure immediate re-rendering instead of relying on external render triggering.
Scrollbar comprehensive test suite
packages/widgets/src/feedback/Scrollbar.test.ts
Full Vitest suite validating Scrollbar rendering: edge case when content fits viewport, correct layout for verticalRight/verticalLeft/horizontalBottom/horizontalTop modes, arrow marker toggling via showArrows, proportional thumb offset movement via setPosition, and verification that setPosition, setContentLength, and setViewportLength each call markDirty exactly once.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • Karanjot786/TermUI#632: Adds StatusIndicator test suite that asserts rendered output after status/label updates, directly complementing this PR's markDirty implementation fix.

Suggested labels

gssoc:approved, type:testing, area:widgets, level:intermediate

Suggested reviewers

  • Karanjot786

Poem

🐰 A scrollbar spins and status shifts true,
With markDirty calls, the widgets renew!
Tests dance across screens both wide and tall,
Arrows toggle, thumbs slide—we've tested it all! 📊✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately captures both main changes: adding Scrollbar tests and fixing StatusIndicator setters. It uses the conventional 'feat' prefix and clearly summarizes the primary objectives.
Description check ✅ Passed The description covers all required sections: clear explanation of changes, linked issue reference (#670), package scope, checked change types, completed checklist items, and notes for reviewers with specific test coverage details.
Linked Issues check ✅ Passed The PR successfully implements all coding requirements from issue #670: comprehensive Scrollbar test suite covering all orientations, viewport edge cases, proportional thumb placement, arrow visibility, and markDirty() calls; plus StatusIndicator setters fix adding missing markDirty() invocations.
Out of Scope Changes check ✅ Passed All changes are properly scoped to @termuijs/widgets package; modifications limited to Scrollbar.test.ts (new) and StatusIndicator.ts (setters), with no unrelated files or out-of-scope refactoring touched.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 Thanks for your first PR to TermUI, @anirudhagarwal-dev.

Before your PR merges:

  1. Star the repo. Required. The star-check job blocks your merge otherwise.
  2. ✅ All checks green: build, test, typecheck.
  3. 🏷 PR title follows type: short description. Example: fix: handle empty list.
  4. 🔗 Link your closing issue in the description.

GSSoC 2026 points come from labels after merge:

  • gssoc:approved. +50 base points.
  • level:beginner / intermediate / advanced / critical. +20 / +35 / +55 / +80.
  • quality:clean / exceptional. x 1.2 / x 1.5.
  • type:*. Stackable bonus.

Your reviewer responds within 48 hours. Ping @Karanjot786 on Discord for urgent help.

🚀 Welcome to the cohort.

@Karanjot786 Karanjot786 added gssoc:approved Approved PR. Earns +50 base points. quality:clean x 1.2 multiplier. Clean implementation. level:beginner +20 pts. Entry-level task. labels Jun 4, 2026
@shineetejol9
Copy link
Copy Markdown
Contributor

I'd like to work on this project under gssoc2026. Please assign this to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:widgets @termuijs/widgets gssoc:approved Approved PR. Earns +50 base points. level:beginner +20 pts. Entry-level task. needs-star PR author has not starred the repo. quality:clean x 1.2 multiplier. Clean implementation. type:feature +10 pts. New feature. type:testing +10 pts. Tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(widgets): Add markDirty calls to StatusIndicator setters

3 participants