Skip to content

test: add comprehensive Vitest test suite (123 tests, 0 → full coverage of pure modules)#63

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/analyze-test-coverage
Draft

test: add comprehensive Vitest test suite (123 tests, 0 → full coverage of pure modules)#63
Copilot wants to merge 2 commits intomainfrom
copilot/analyze-test-coverage

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 9, 2026

The codebase had zero tests and no test infrastructure. This adds Vitest as the test framework and covers all testable pure modules — stores, utilities, hooks, and services.

Infrastructure

  • Vitest 4.x + jsdom environment configured in vite.config.ts
  • @testing-library/react + @testing-library/jest-dom for hook tests
  • New scripts: test, test:watch, test:coverage
  • src/test/setup.ts bootstraps jest-dom matchers globally

Test coverage added (11 files, 123 tests)

Module Tests Notes
lib/utils.ts 8 cn() — merging, deduplication, conditionals
stores/toast.ts 14 add/update/remove, all convenience methods, default messages
stores/adb.ts 19 metainfo parsing, device/display resolution, encoder list building, TinyH264 auto-selection
stores/file.ts 9 upload, getUploads, getApps with mocked service layer
services/.../storage.ts 17 local/session R-W-D, cookie > session > local priority, jsdom integration
services/.../credentials.ts 10 token generation, persistence, clear
services/.../http-client.ts 11 setBackendBaseUrl (protocol conversion, credential extraction, URL validation), setAuthToken
utils/file.js 6 getFileSizeInMb integer/fractional/large, getFileUrl
utils/rules.js 18 All validators — required, name, email, password — pass and fail branches
utils/mapClientToDevicePosition.js 7 All rotation values (0–3), clamping, rect offset
hooks/use-mobile.ts 4 Initial value, resize event, cleanup on unmount

Notable test patterns

  • Zustand stores reset via setState({}) in beforeEach to prevent cross-test pollution
  • Date.now mocked with an incrementing counter so rapid add() calls in the toast store produce unique IDs
  • adbService and fileUploadService fully mocked to isolate store logic from HTTP

Copilot AI and others added 2 commits April 9, 2026 10:48
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.

2 participants