Skip to content

Complete unit test coverage for all hooks and lib modules#29

Merged
hotlong merged 3 commits intomainfrom
copilot/complete-development-testing
Feb 9, 2026
Merged

Complete unit test coverage for all hooks and lib modules#29
hotlong merged 3 commits intomainfrom
copilot/complete-development-testing

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 9, 2026

11 hooks and 2 lib modules had zero test coverage. This closes the gap, bringing the suite from 413/45 to 493/58 (tests/suites).

New hook tests

  • useFileUpload (13) — upload, image/camera/document pick, download, share, permission denial, cancellation
  • useFeatureFlag (9) — flag evaluation, payload access, subscription lifecycle, cleanup on unmount
  • useRemoteConfig (6) — typed config values, fallback defaults, reactive updates
  • useAnalyticsTracking (7) — page view on mount, re-track on screen change, action tracking
  • useNetworkStatus (5) — connectivity polling, offline state propagation, error resilience
  • useQueryBuilder (12) — filter tree CRUD, nested groups, toggle logic, serialization
  • useOfflineSync (9) — queue drain for create/update/delete, 409 conflict detection, max-retry failure
  • usePackages, useBatchMutation, useSavedViews (1 each) — barrel re-export identity checks
  • useObjectStack (4) — validates all 17 re-exported hooks are defined

New lib tests

  • server-url (7) — SecureStore persistence, validateServerUrl with health/HEAD fallback chain
  • auth-client (4) — initial creation, reinitializeAuthClient URL swap, expo plugin wiring

Docs

Updated test counts in NEXT-PHASE.md, PROJECT-STATUS.md, ROADMAP.md.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits February 9, 2026 15:32
New test files:
- __tests__/hooks/useFileUpload.test.ts (13 tests)
- __tests__/hooks/useFeatureFlag.test.ts (9 tests)
- __tests__/hooks/useRemoteConfig.test.ts (6 tests)
- __tests__/hooks/useAnalyticsTracking.test.ts (7 tests)
- __tests__/hooks/useNetworkStatus.test.ts (5 tests)
- __tests__/hooks/useQueryBuilder.test.ts (12 tests)
- __tests__/hooks/useOfflineSync.test.ts (9 tests)
- __tests__/hooks/usePackages.test.ts (1 test)
- __tests__/hooks/useBatchMutation.test.ts (1 test)
- __tests__/hooks/useSavedViews.test.ts (1 test)
- __tests__/hooks/useObjectStack.test.ts (4 tests)
- __tests__/lib/server-url.test.ts (7 tests)
- __tests__/lib/auth-client.test.ts (4 tests)

Total: 493 tests, 58 suites (up from 413/45)

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot AI changed the title [WIP] Complete development testing for v1.0 GA Complete unit test coverage for all hooks and lib modules Feb 9, 2026
Copilot AI requested a review from hotlong February 9, 2026 15:37
@hotlong hotlong marked this pull request as ready for review February 9, 2026 15:39
Copilot AI review requested due to automatic review settings February 9, 2026 15:39
@hotlong hotlong merged commit f7aba35 into main Feb 9, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR closes remaining unit test coverage gaps by adding Jest/RNTL test suites for previously-untested hooks and lib modules, and updates project documentation to reflect the new test totals (493 tests across 58 suites).

Changes:

  • Added new unit tests for multiple hooks (e.g., file upload, feature flags, remote config, analytics tracking, network status, query builder, offline sync, barrel/alias exports).
  • Added new unit tests for lib/server-url and lib/auth-client.
  • Updated roadmap/status docs with new suite/test counts and revised success criteria.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
docs/ROADMAP.md Updates “关键路径” test totals to 493 tests / 58 suites.
docs/PROJECT-STATUS.md Updates executive summary, coverage section, and test status totals.
docs/NEXT-PHASE.md Updates status wording, test totals, and GA success criteria.
tests/lib/server-url.test.ts Adds persistence + validation tests for server URL management.
tests/lib/auth-client.test.ts Adds tests for auth client creation and reinitialization behavior.
tests/hooks/useSavedViews.test.ts Verifies useSavedViews alias identity.
tests/hooks/useRemoteConfig.test.ts Tests reactive remote config hooks with subscription updates.
tests/hooks/useQueryBuilder.test.ts Tests filter tree CRUD/toggling/serialization behavior for query builder hook.
tests/hooks/usePackages.test.ts Verifies usePackages alias identity.
tests/hooks/useOfflineSync.test.ts Tests queue draining, conflict detection, and retry limit behavior.
tests/hooks/useObjectStack.test.ts Verifies barrel exports are present/defined.
tests/hooks/useNetworkStatus.test.ts Tests connectivity polling behavior and offline propagation.
tests/hooks/useFileUpload.test.ts Tests upload/pick/capture/document/share flows and error handling.
tests/hooks/useFeatureFlag.test.ts Tests reactive feature-flag evaluation/payload updates/unmount cleanup.
tests/hooks/useBatchMutation.test.ts Verifies useBatchMutation alias identity.
tests/hooks/useAnalyticsTracking.test.ts Tests page view tracking and action tracking helpers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +83 to +87
it("falls back to HEAD request when /api/health fails", async () => {
global.fetch = jest
.fn()
.mockRejectedValueOnce(new Error("health failed"))
.mockResolvedValueOnce({ status: 200 }) as any;
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

These tests intentionally trigger validateServerUrl()'s error path (mocked fetch rejection). In lib/server-url.ts, the setTimeout(..., 8000) created for the AbortController is only cleared after a successful await fetch(...), so when fetch rejects the timeout is never cleared. That can leave pending timers/open handles and slow the Jest run. Suggest fixing validateServerUrl to always clearTimeout(timeout) in a finally block for both the health and HEAD attempts (preferred), or switch this test suite to fake timers and flush pending timers after each test.

Copilot uses AI. Check for mistakes.
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.

3 participants