Skip to content

test: improve test coverage across CLI, server, and frontend - #679

Merged
unhappychoice merged 30 commits into
mainfrom
improve-test-coverage-20260501-110036
May 2, 2026
Merged

unhappychoice merged 30 commits into
mainfrom
improve-test-coverage-20260501-110036

Conversation

@unhappychoice

@unhappychoice unhappychoice commented May 1, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Significantly improve test coverage across CLI, server, and frontend (backend 99%+, key frontend modules at 100%)
  • Rework Layout tests with a child-component mocking approach to shrink the bloated snapshot
  • Add: App.behavior / api / index (both frontend and backend) / store / useTheme / useSyntaxHighlighterTheme / useSettingsForm / logger / error paths for each router
  • Replace the fragile dummy-open PATH override in the CLI e2e test with the existing --no-open flag, eliminating the risk of accidentally launching a real browser
  • Remove the empty .codex file that had been committed by mistake

Test plan

  • npm run test (backend, 119 tests / 13 suites pass)
  • npm run test:frontend (frontend, 292 tests / 55 suites pass)
  • CI green

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Tests
    • Expanded unit and end-to-end test coverage for app initialization, settings management, file navigation, markdown rendering, diagram generation, and CLI operations.
    • Added tests for error handling, offline scenarios, localStorage persistence, and mobile-responsive behavior across all major features.

@netlify

netlify Bot commented May 1, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for mdts-unhappychoice ready!

Name Link
🔨 Latest commit c9ab001
🔍 Latest deploy log https://app.netlify.com/projects/mdts-unhappychoice/deploys/69f5f9bf85e816000868b149
😎 Deploy Preview https://deploy-preview-679--mdts-unhappychoice.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented May 1, 2026 •

Copy link
Copy Markdown

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR adds comprehensive unit test coverage for frontend components, hooks, Redux slices, backend routes, utilities, and entry points. It includes 30+ new test files and enhancements to existing tests, along with a simplified e2e CLI test setup.

Changes

Frontend Component & API Tests

Layer / File(s) Summary
API & Component Mocking
packages/frontend/test/unit/api.test.ts, packages/frontend/test/unit/App.test.tsx
New fetchData test suite validates JSON/text parsing and error handling. App.test.tsx mocks Material UI components and the API layer for isolated unit testing.
Component Behavior Tests
packages/frontend/test/unit/App.behavior.test.tsx
Tests settings dialog toggle and invalid darkMode recovery (websocket, file-tree fetch, theme reset, settings save).
Layout & Content Components
packages/frontend/test/unit/Layout.test.tsx, packages/frontend/test/unit/components/Content/MarkdownContent/MarkdownContent.test.tsx
Layout uses MemoryRouter, mocked child components, and tests responsive toggles and navigation. MarkdownContent tests diff-prev mode via route query parameter.
Markdown Rendering & PlantUML
packages/frontend/test/unit/components/Content/MarkdownContent/MarkdownRenderer/*
MarkdownRenderer mocks react-markdown with sentinel-based code/mermaid/table rendering. MarkdownCode tests PlantUML diagram loading states with computed hash-based cache keys.
Left/Right Pane & Settings
packages/frontend/test/unit/components/LeftPane/*, packages/frontend/test/unit/components/RightPane/Outline.test.tsx, packages/frontend/test/unit/components/SettingsDialog/*
FileTree mobile test verifies dispatch on expand/select. Outline uses renderOutline helper and tests responsive toggle + hidden content states. ColorSchemeSettingsTab and LayoutSettingsTab test callback props (handleToggleDarkMode, handleToggleTheme, setEnableBreaks).

Frontend Hooks & Store Tests

Layer / File(s) Summary
Hook Testing Utilities
packages/frontend/test/unit/hooks/*
useTheme tests auto mode with mocked matchMedia and unknown themes. useWebSocket tests close handler logging. useSettingsForm tests theme toggle and font input mode reset. useSyntaxHighlighterTheme tests theme selection with light/dark palette wrappers.
Redux Slice Tests
packages/frontend/test/unit/store/configSlice.test.ts, packages/frontend/test/unit/store/fileTreeSlice.test.ts, packages/frontend/test/unit/store/plantUMLSlice.test.ts
configSlice tests backend save failure handling. fileTreeSlice tests cache eviction when >10 paths mounted. plantUMLSlice adds hash-diagram helper and tests SVG fetch/cache with exact POST assertions.
Store Integration
packages/frontend/test/unit/store/store.test.ts, packages/frontend/test/unit/index.test.tsx
Store tests localStorage persistence, theme switching, and matchMedia listener registration. index.test.tsx tests React root creation, subscription persistence, and error logging when localStorage fails.

Backend Route, Server & Utility Tests

Layer / File(s) Summary
Route Error Handling
test/unit/server/routes/outline.test.ts, test/unit/server/routes/plantuml.test.ts
outline route tests file read failure with 500 response and logger.error invocation. plantuml route tests SVG generation failure with exact logger.error message assertions.
Server & Watcher Tests
test/unit/server/server.test.ts, test/unit/server/watcher.test.ts
server test adds watched-file-count logging assertion. watcher test enhances mock with async close() and unwatch, and tests EMFILE error handling with ulimit guidance logging.
Logger Utility Tests
test/unit/utils/logger.test.ts
Comprehensive logger test suite validates logo display, silent mode suppression, tag formatting, URL OSC-8 link conversion, and error output routing to console.error.

CLI & Entrypoint Tests

Layer / File(s) Summary
Backend CLI
test/unit/cli.test.ts, test/unit/index.test.ts
cli.test.ts adds --no-open logging and serve-failure error handling with exit code. index.test.ts tests CLI instantiation and run invocation once per startup.
E2E Simplification
test/e2e/cli.test.ts
Removes temporary open executable mock setup; now uses --no-open flag for deterministic server startup polling.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

The PR contains numerous test additions (30+ files and updates) that follow consistent patterns (mock setup, assertion chains, helper functions), but requires attention to mock logic, async test flows, and assertion correctness across heterogeneous components/hooks/routes. The scope is broad but tests are relatively self-contained, reducing per-file reasoning overhead.

Possibly related PRs


🐰 Hops through test files with glee,
Mock stores and hooks all working spree,
Coverage blooms from root to leaf,
Each assertion brings relief!
Tests shine bright, the codebase is free.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 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: improving test coverage across CLI, server, and frontend modules with many new test files and test cases.
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.

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

✨ 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 improve-test-coverage-20260501-110036

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

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

@codecov

codecov Bot commented May 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.34%. Comparing base (fd8e448) to head (c9ab001).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #679      +/-   ##
==========================================
+ Coverage   89.50%   99.34%   +9.84%     
==========================================
  Files          69       69              
  Lines        1534     1534              
  Branches      372      369       -3     
==========================================
+ Hits         1373     1524     +151     
+ Misses        160        9     -151     
  Partials        1        1              
Flag Coverage Δ
frontend 99.33% <ø> (+8.69%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@unhappychoice unhappychoice changed the title test: raise overall line coverage with one targeted test test: improve test coverage across CLI, server, and frontend May 1, 2026
PATH override + dummy `open` script was fragile and could leak real
browser launches when the override failed. Replace it with the CLI's
existing --no-open flag for a deterministic fix.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@unhappychoice
unhappychoice marked this pull request as ready for review May 2, 2026 13:25
@unhappychoice
unhappychoice merged commit f48bd56 into main May 2, 2026
9 checks passed
@unhappychoice
unhappychoice deleted the improve-test-coverage-20260501-110036 branch May 2, 2026 13:32
@unhappychoice
unhappychoice restored the improve-test-coverage-20260501-110036 branch May 2, 2026 13:37
unhappychoice added a commit that referenced this pull request May 2, 2026
…0501-110036

test: improve test coverage across CLI, server, and frontend
@unhappychoice
unhappychoice deleted the improve-test-coverage-20260501-110036 branch May 2, 2026 13:39
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