Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tests to remove reliance on UserDefaults #156

Merged
merged 16 commits into from
Feb 8, 2024

Conversation

aokj4ck
Copy link
Contributor

@aokj4ck aokj4ck commented Jan 24, 2024

Description

  • Remove all usages of UserDefaults from MapboxSearch and MapboxSearchUI
    • Replaces this with plain dependency injection
  • Add LocalhostMockServiceProvider for integration tests to provide a mocked customBaseURL
  • Add FeedbackIntegrationTestCase back to UI test suite
  • Split MockServerTestCase into UI and Integration variants because it had a namespace collision
  • Utilize customBaseURL for ServiceProvider and LocalhostMockServiceProvider
  • Stop reading from "MapboxAPIBaseURL" from NSUserDefaults in ServiceProvider.createEngine.
    • Providing a value in Info.plist is still supported.
  • Update integration tests to use LocalhostMockServiceProvider
  • This fixes a bug in the Demo app where you building and running the app or tests could use the wrong baseApiURL based on the current value in user defaults.
  • Update and correct tests for iOS 17 using all mocked data for unit and UI tests.
  • Rename SearchEngine.reverseGeocoding function to SearchEngine.reverse.
  • OfflineTests are still failing and will be address later

Checklist

  • Update CHANGELOG

Screenshots

Before After
Screenshot 2024-02-06 at 17 47 49 Screenshot 2024-02-06 at 17 28 38

- Remove all usages of UserDefaults from MapboxSearch and MapboxSearchUI
- Add LocalhostMockServiceProvider for integration tests to provide a mocked customBaseURL
- Add FeedbackIntegrationTestCase back to UI test suite
- Split MockServerTestCase into UI and Integration variants because it had a namespace collision
- Utilize customBaseURL for ServiceProvider and LocalhostMockServiceProvider
- Stop reading from NSUserDefaults
- Update integration tests to use LocalhostMockServiceProvider
@aokj4ck aokj4ck marked this pull request as ready for review January 24, 2024 21:39
@aokj4ck aokj4ck requested review from a team as code owners January 24, 2024 21:39
@aokj4ck aokj4ck requested review from Udumft and a user January 24, 2024 21:39
…e-userdefaults-from-tests

Conflicts:
	Tests/MapboxSearchIntegrationTests/CategorySearchEngineIntegrationTests.swift
	Tests/MapboxSearchIntegrationTests/SearchEngineIntegrationTests.swift
…s in MockWebServer

- This moves unit and UI-tested traffic into mocked traffic
- Add more mock data for uncovered cases
- Rename SearchEngine.reverseGeocoding to SearchEngine.reverse
- Fix SearchEngineIntegrationTests to align queries with mock data
azarovalex
azarovalex previously approved these changes Feb 7, 2024
@aokj4ck aokj4ck merged commit 5188d63 into main Feb 8, 2024
4 checks passed
@aokj4ck aokj4ck deleted the remove-userdefaults-from-tests branch February 8, 2024 16:58
aokj4ck added a commit that referenced this pull request Apr 5, 2024
- Remove all usages of UserDefaults from MapboxSearch and MapboxSearchUI
    - Replaces this with plain dependency injection
- Add LocalhostMockServiceProvider for integration tests to provide a mocked customBaseURL
- Add FeedbackIntegrationTestCase back to UI test suite
- Split MockServerTestCase into UI and Integration variants because it had a namespace collision
- Utilize customBaseURL for ServiceProvider and LocalhostMockServiceProvider
- Stop reading from  "MapboxAPIBaseURL" from NSUserDefaults in `ServiceProvider.createEngine`.
    - Providing a value in Info.plist is still supported.
- Update integration tests to use LocalhostMockServiceProvider
- This fixes a bug in the Demo app where you building and running the app or tests could use the wrong baseApiURL based on the current value in user defaults.
- Update and correct tests for iOS 17 using all mocked data for unit and UI tests.
- Rename `SearchEngine.reverseGeocoding` function to `SearchEngine.reverse`.

- [x] Update `CHANGELOG`

| Before | After |
| -- | -- |
| <img width="355" alt="Screenshot 2024-02-06 at 17 47 49" src="https://github.com/mapbox/mapbox-search-ios/assets/384288/f615ad45-efeb-4687-9373-f89d0037c982"> | <img width="356" alt="Screenshot 2024-02-06 at 17 28 38" src="https://github.com/mapbox/mapbox-search-ios/assets/384288/801d518e-c8c2-4403-93f8-1ef2336338c7"> |
Conflicts:
	CHANGELOG.md
	MapboxSearch.xcodeproj/project.pbxproj
	Sources/MapboxSearch/PublicAPI/ServiceProvider.swift
	Tests/MapboxSearchIntegrationTests/CategorySearchEngineIntegrationTests.swift
	Tests/MapboxSearchIntegrationTests/SearchEngineIntegrationTests.swift
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