Skip to content

Add iOS Unit Test Suite - 91 Tests#32

Merged
Jing-yilin merged 2 commits into
developfrom
feature/ios-tests
Feb 28, 2026
Merged

Add iOS Unit Test Suite - 91 Tests#32
Jing-yilin merged 2 commits into
developfrom
feature/ios-tests

Conversation

@Jing-yilin
Copy link
Copy Markdown
Contributor

Summary

This PR adds a comprehensive iOS unit test suite covering core functionality across ViewModels, APIClient, models, Keychain, and ImageCache.

Test Coverage

  • 91 total unit tests across the iOS codebase
  • AlertsViewModel tests
  • DiscoverViewModel tests
  • APIClient tests
  • DTO/Model tests
  • KeychainHelper tests
  • ImageCache tests
  • Mock implementations for testing (MockAPIClient, MockURLProtocol)

Additional Changes

This branch includes several backend improvements and features:

  • ScrapingBee integration for Kickstarter crawling
  • Campaign backfill endpoint (POST /api/admin/backfill)
  • Enhanced campaign model with backers_count field
  • Configurable crawl depth via environment variables
  • Category and subcategory crawling
  • Database schema improvements (p_id → pid migration)
  • Enhanced investor metrics and momentum alerts
  • CI/CD improvements and security enhancements

Test Plan

  • All 91 iOS unit tests pass
  • Backend tests passing in CI

🤖 Generated with Claude Code

@Jing-yilin Jing-yilin changed the base branch from main to develop February 27, 2026 16:03
Copy link
Copy Markdown
Contributor Author

@Jing-yilin Jing-yilin left a comment

Choose a reason for hiding this comment

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

Codex Review

[Low] testLoadCategoriesSkipsIfAlreadyLoaded does not observe the code path it is meant to protect

DiscoverViewModel.loadCategories() calls fetchCategories(), but this test snapshots mock.fetchCampaignsCalls.count instead. Because MockAPIClient does not record category fetches, the assertion still passes even if loadCategories() regresses to hitting the categories endpoint on every call. In practice, the suite is not actually covering the "skip refetch when already loaded" behavior this test claims to verify.
Refs: ios/KickWatch/Tests/DiscoverViewModelTests.swift:159, ios/KickWatch/Tests/MockAPIClient.swift:38

Validation

  • cd backend && go test ./...
  • cd ios && export DEVELOPMENT_TEAM=7Q28CBP3S5 && xcodegen generate
  • cd ios && xcodebuild -project KickWatch.xcodeproj -scheme KickWatch -destination 'platform=iOS Simulator,name=iPhone 17' test
  • Result: backend suite passed; iOS suite passed with 91 tests on February 28, 2026.

Reviewed by Codex

testLoadCategoriesSkipsIfAlreadyLoaded was checking fetchCampaignsCalls.count
instead of fetchCategories calls, so the test would pass even if the
skip-refetch logic broke.

- Add fetchCategoriesCalled flag to MockAPIClient
- Update test to check fetchCategoriesCalled instead of fetchCampaignsCalls
- Set flag in fetchCategories() implementation

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@Jing-yilin Jing-yilin merged commit b8de7b6 into develop Feb 28, 2026
@Jing-yilin Jing-yilin deleted the feature/ios-tests branch February 28, 2026 03:57
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