Skip to content

test: add node:test coverage for section colors, render, click/wheel seek - #9

Merged
OmikronApex merged 1 commit into
mainfrom
chore/add-basic-tests
Jul 8, 2026
Merged

test: add node:test coverage for section colors, render, click/wheel seek#9
OmikronApex merged 1 commit into
mainfrom
chore/add-basic-tests

Conversation

@OmikronApex

@OmikronApex OmikronApex commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Twenty-first repo from the org test-coverage audit. screen.js has no top-level wrapping IIFE for its function declarations — only the side-effect block (5Hz poller + playSong/showScreen wrapping) at the tail is wrapped. The module.exports hook wraps that tail block in an else branch instead of a bare return, since a live setInterval handle would otherwise keep the Node test process alive after the file loads.

10 tests against small hand-rolled fake bar/audio elements (no jsdom):

  • _smGetColor: substring + case-insensitive section-name matching, default fallback
  • _smFmt: m:ss formatting with zero-padded seconds
  • _smRender: one block per section + a position marker, correct left%/width% math, numeric-suffix stripping + capitalization on labels
  • _smOnClick: seeks to the clicked fraction immediately when paused, pause→seek→resume dance while playing
  • _smOnWheel: fine-grained (0.1s) delta with Ctrl, full-second delta without, clamps to [0, duration]
  • Both handlers no-op when duration is unknown (song not yet loaded)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved screen interactions for seeking and playback controls, including more precise wheel-based seeking and correct pause/resume behavior while scrubbing.
    • Fixed section labeling and color matching so display names are cleaner and section highlights are more consistent.
    • Added safer handling for empty or zero-length audio to prevent unintended actions.
  • Tests

    • Expanded automated coverage for rendering, formatting, section matching, and click/wheel seeking behavior.

…seek

Node-only module.exports hook wrapping the side-effect IIFE
(poller + playSong/showScreen wrapping) in an else-branch so it
never runs under Node — avoids leaving a live setInterval handle
that would keep the test process alive.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

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: dcfe1b10-a6c0-4202-82ee-e147a5ef5b36

📥 Commits

Reviewing files that changed from the base of the PR and between 1a62dec and db830cc.

📒 Files selected for processing (2)
  • screen.js
  • tests/screen.test.js

📝 Walkthrough

Walkthrough

This PR adds a CommonJS export branch to screen.js, exposing internal section-map helper functions and state accessors for testing, while preserving existing browser IIFE behavior. A new test suite validates color lookup, formatting, rendering, and click/wheel seeking logic.

Changes

Section-map Test Exposure

Layer / File(s) Summary
CommonJS export branch
screen.js
Adds a Node-only branch exporting _smGetColor, _smFmt, _smCreate, _smRemove, _smUpdate, _smRender, _smOnClick, _smOnWheel, _getState(), and _setState(next); wraps existing browser side-effect code in an else branch.
Helper test suite
tests/screen.test.js
Adds tests validating section-color matching, time formatting, HTML rendering with markers, label normalization, click/wheel seeking (including ctrlKey fine-grained delta and duration=0 no-ops), and pause/seek/resume behavior during playback.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding node:test coverage for screen.js behaviors.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/add-basic-tests

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

@OmikronApex
OmikronApex merged commit f62fe2e into main Jul 8, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant