fix-mock-network-tests.md 1.7 KB

Fix Failing Mock-Network UI Tests

Problem

2 of 11 new UI tests fail — both are Phase 3 mock-network tests:

  1. testAlbumTracksWithMockData — fails at line 198: "Album category should be visible with mock data"
  2. testDecodingErrorShowsMessage — fails at line 186: "Should show either Not Connected or Browse section"

Both fail because the -MockNetwork launch argument isn't being picked up by the app to register the MockURLProtocol, so the mock data never reaches the views.

Goal

Both mock-network tests pass when run via xcodebuild test.

Non-goals

  • No changes to Phase 1/2 tests (they pass)
  • No changes to the existing 20 UI tests (they pass)
  • No new test scenarios

Acceptance Criteria

  • testAlbumTracksWithMockData passes
  • testDecodingErrorShowsMessage passes
  • All other tests still pass (311 unit + existing UI + Phase 1/2)
  • -MockNetwork launch arg correctly registers MockURLProtocol in the app

Appetite

  • 2-3 files changed max
  • Fix the wiring, don't redesign the mock approach

Investigation needed

  1. Check MixBoardApp.swift — does it check for -MockNetwork launch argument?
  2. Check MockURLProtocol — is it in the app target (Sources/) or only in the test target (UITests/)?
  3. Check the test files — are they passing -MockNetwork via app.launchArguments?
  4. The issue is likely: MockURLProtocol exists only in UITests target, so the app can't see it. Fix: either move mock registration to the app target with conditional compilation, or use a different approach.

Technical Constraint

MockURLProtocol must be available to the main app target (not just UITests) for runtime URL interception to work. Use #if DEBUG guard so it's stripped from release builds.