Repository navigation
test: cover renderer separators, ANSI edge cases and settings errors - #660
Merged
sirmalloc merged 1 commit intoOct 6, 2026
Merged
Conversation
Powerline separator colors (same, single and missing backgrounds, both normal and inverted), caps on widgets without a background, bold resets at flex gaps and end caps, preserved command colors, and auto-align padding for merged groups had no tests, and neither did inherited and override colors on standard-mode separators and padding. These paths decide whether a status line keeps a continuous color band or shows gaps, wrong arrow colors and leaked bold. The ANSI parser gets direct tests for 8-bit C1 CSI/OSC, unterminated sequences, two-character escapes, flags, ZWJ emoji sequences and hyperlink closing on truncation, so widths and truncation stay right for custom command output. Claude settings gain tests for loadClaudeSettingsSync, refresh-interval reads and writes against unreadable settings, a failed .orig backup not blocking install, invalid ccstatusline configs not syncing hooks, and the getRemoteControlStatus manifest lookup.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds 65 tests for three core utilities. Test files only; no production code changes.
src/utils/renderer.tspreserveColors); auto-align padding for merged groups, and merges across or into widgets that rendered empty.defaultSeparatortaking the previous widget's colors withinheritSeparatorColors(including its default color), the background override on separators,,and-separator spacing, padding colored with the widget background on each padding side, the preview width infull-minus-40, and widget types this version doesn't know.src/utils/ansi.ts(newansi.test.ts): 8-bit C1 CSI/OSC sequences, non-hyperlink OSC (window titles), unterminated CSI/OSC, two-characterESC xescapes, flags, ZWJ emoji sequences, stray combining marks, and truncation that never splits a flag or ZWJ sequence and closes hyperlinks correctly.src/utils/claude-settings.ts:loadClaudeSettingsSync,getRefreshInterval/setRefreshIntervalagainst unreadable settings, a failed.origbackup during install, invalid or malformed ccstatusline configs during install, andgetRemoteControlStatus.Why
inheritSeparatorColors(for separator widgets and the automaticdefaultSeparator) and the background override on separators and padding had no tests. If they break, a configured color band breaks at every separator and padding space.getRemoteControlStatus, behind the Remote Control widget, had no direct tests (the widget's tests mock it). How it handles a missing sessions directory, non-manifest files, malformed manifests and other sessions was unverified.installStatusLinemust still install when the.origbackup can't be written, and must not sync hooks from a ccstatusline config that fails validation or isn't valid JSON.How
ansi.test.ts,renderer-powerline-separators.test.tsandrenderer-separator-colors.test.ts. Everything else extends the existing test file for that topic (renderer-dim,renderer-flex-width,renderer-padding-side,renderer-separator-collapse,claude-settings).hex:values, which produce raw truecolor codes whatever chalk detects about the terminal. The one place that needs a widget's named default color pinschalk.leveland restores it afterwards, asrenderer-config-warning.test.tsalready does.terminalWidthexplicitly (0 for "width unknown"), so nothing depends on the terminal running the tests.CLAUDE_CONFIG_DIR, like the rest ofclaude-settings.test.ts. A failed backup write and an unreadable session manifest both come from a directory sitting where the file should be. Nothing spies onfs,child_processoros.readdirreturns.Left uncovered on purpose:
claude-settings.ts:isNpmAvailable,isNpxAvailable,isBunAvailable,isBunxAvailableandgetPackageCommandAvailability, which runwhich/wherein a child process; and the Windows (cmd.exe) branch of the--configpath quoting, which needsprocess.platformmocked towin32.renderer.ts: the fallback for an unknownflexMode(settings are validated against the three modes on load), thecatcharound widget rendering (nothing inside throws for a registered widget), and the default-separator branch for an element without a widget (every element has one).ansi.ts: the fallback for runtimes without Unicode property escapes, guards for indices that can't be out of range, and truncation's "nothing was cut" return, which needs an escape sequence inside a single emoji cluster.Demo
No demo: test-only, nothing visible changes.
Testing
bun test --coverage:src/utils/renderer.ts: 90.41% → 99.35%src/utils/ansi.ts: 84.54% → 98.31%src/utils/claude-settings.ts: 81.90% → 95.81%bun test: 2423 pass, 0 fail, 151 files (main: 2358 pass, 148 files), so 65 new tests.bun run lint: clean.node node_modules/vitest/vitest.mjs runon the 8 touched files: 230 tests, 219 pass, and all 65 new tests pass. The 11 failures are the existingexecSyncspies inclaude-settings.test.ts, which fail the same way onmain.ansi.ts; using the wrong text color for the inverted same-background arrow, dropping the bold reset before a flex gap, or dropping the22;1bold restore inrenderer.ts; ignoring the previous widget's background on inherited separators; dropping the placeholder for unknown widget types; and removing the empty-session-id guard, the.jsonfilter or the schema check before hook sync inclaude-settings.ts. Each one made at least one new test fail.