Skip to content

Migrate 5 misplaced Jest tests to browser integration tests #253

@smithrashell

Description

@smithrashell

Summary

5 Jest test files (36 tests) are testing integration-level concerns with fragile mocks. They should be migrated to the browser integration test system (src/background/core-business-tests.js) where they can run against real IndexedDB and Chrome APIs.

These tests have been marked with describe.skip and comments explaining the migration rationale.

Files to Migrate

High Priority

File Tests Reason
src/shared/db/__tests__/problems.boxlevel.test.js 8 Manually simulates IndexedDB cursor iteration with fragile mocks
src/shared/services/__tests__/background.critical.test.js 4 Tests Chrome API availability via mocked globals (circular logic)
src/shared/services/__tests__/errorRecovery.infrastructure.test.js 14 Simulates deadlocks/memory pressure on fully mocked services
src/shared/db/stores/__tests__/findPrerequisiteProblem.test.js 7 Uses fake-indexeddb with custom schema that may diverge from production

Medium Priority (Duplicate)

File Tests Reason
src/shared/db/stores/__tests__/sessions.test.js 3 Exact duplicate of browser test #20 (testSessionDateSorting)

Additional Jest tests to consider (not yet skipped)

These are lower priority but also test integration concerns with heavy mocking:

  • storageService.critical.test.js — Chrome storage context detection
  • sessionService.enhanced.test.js — Race condition tests against mocked services
  • chromeMessaging.infrastructure.test.js — Mocked Chrome messaging
  • leitnerSystem.test.js (DB cursor portions only) — reassessBoxLevel cursor simulation
  • backgroundScript.integration.test.js — Misnamed; tests handler routing with mocks
  • sessionAttribution.integration.test.js — Tests inline pure functions, not real attribution

Migration Approach

  1. Add equivalent test functions to core-business-tests.js using the existing smartTestIsolation() and CodeMaster_test database infrastructure
  2. Register new tests on globalThis following the existing pattern
  3. Verify browser tests pass in dev mode
  4. Delete the skipped Jest files

Labels

test, tech-debt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions