-
Notifications
You must be signed in to change notification settings - Fork 20
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
[SSDK-541] Add searchbox validation, change Demo to searchbox #164
Conversation
…541-add-searchbox-validation Conflicts: Sources/MapboxSearch/InternalAPI/Engine/ApiType+Core.swift Sources/MapboxSearch/PublicAPI/Engine/ApiType.swift Sources/MapboxSearch/PublicAPI/MapboxSearchVersion.swift Sources/MapboxSearch/PublicAPI/Use Cases/Discover API/Discover.swift
…sts - SSDK-541 - Test mocking needs to support different API engine types to make this easier
Depends on #179 which generalizes tests and associates mock data with the API type so that it is clear and easy to understand which API type a test should use (geocoding, SBS, autofill, search-box). |
…541-add-searchbox-validation
- Add name prefixes for SBS_ and SearchBox_. - To display in the Xcode UI test classes must coexist in the global namespace so we have to use old-fashioned prefixes. - Add note to reorganize SBS mock data in the future. - Add SearchBoxMockResponse, initially based on SBS, to provide data for search-box API tests. - Fix namespace collision within MockWebServer.setResponse function clobbering response function argument.
will be fixed in SAPI-1176 |
…peQuery by correcting mocked delegate behavior
@@ -1,16 +1,18 @@ | |||
import XCTest | |||
|
|||
class CategorySuggestionsIntegrationTestCase: MockSBSServerUITestCase { | |||
// Rename to UITestCase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the UI test cases have "Integration" in the name rather than "UI" and this conflicts with the actual integration tests which also have "integration" in their names.
This rename operation and other clean-up changes (split MockResponse enum instances into separate files, rename MockResponse cases) can occur in a separate PR to reduce noise.
@@ -1,6 +1,7 @@ | |||
import XCTest | |||
|
|||
class FavoritesIntegrationTestCase: MockSBSServerUITestCase { | |||
// Rename to UITestCase | |||
class FavoritesIntegrationTestCase: MockSearchBoxUITestCase { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Favorites UI tests are failing on Minsk name in results and this will be fixed in SAPI-1176
func testSuggestionTypeQuery() throws { | ||
try server.setResponse(.recursion) | ||
|
||
let updateExpectation = delegate.updateExpectation | ||
searchEngine.query = "Recursion" | ||
wait(for: [updateExpectation], timeout: 10) | ||
|
||
let firstSuggestion = try XCTUnwrap(searchEngine.suggestions.first) | ||
searchEngine.select(suggestion: firstSuggestion) | ||
|
||
/// Mock that a subsequent retrieve call has been made and succeeds. | ||
/// This is not implemented in the stub delegate (it reports success). | ||
/// We have validated that the chained operations are connected. | ||
let nextUpdateExpectation = delegate.updateExpectation | ||
wait(for: [nextUpdateExpectation], timeout: 10) | ||
XCTAssertFalse(searchEngine.suggestions.isEmpty) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@azarovalex this test function is passing locally but failing on CircleCI, does anything stand-out as wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I've just tried running these tests in Xcode as well as make ci-full-test
and it failed both times.
Could it be that we can't wait for an expectation that was already fulfilled before? Or maybe expectedFulfillmentCount
to 2.
Also some other tests from this file fail for me on aa1b605
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those other tests will be fixed in SAPI-1176
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I found that, oddly, the CircleCI tests were hitting the subsequent retrieve
request but local tests were jumping right to the fulfilled expectation.
On CircleCI I ran modifications of just this test to triage and captured that in commit b370ae3
MapboxSearchIntegrationTests.SearchBox_SearchEngineIntegrationTests
testSuggestionTypeQuery, XCTAssertEqual failed: ("Optional("Search Result resolution failed, Layer:[MapboxServerAPIDataProvider], Name:[Recursion Software]")") is not equal to ("Optional("")")
/Users/distiller/project/Tests/MapboxSearchIntegrationTests/search-box/SearchBox_SearchEngineIntegrationTests.swift:193
wait(for: [nextExpect], timeout: 10)
XCTAssertEqual(delegate.error?.localizedDescription, "")
XCTAssertFalse(searchEngine.suggestions.isEmpty)
Please review when you can!
CircleCI is failing with an error object, narrowing this down ``` MapboxSearchIntegrationTests.SearchBox_SearchEngineIntegrationTests testSuggestionTypeQuery, XCTAssertEqual failed: ("Optional("Search Result resolution failed, Layer:[MapboxServerAPIDataProvider], Name:[Recursion Software]")") is not equal to ("Optional("")") /Users/distiller/project/Tests/MapboxSearchIntegrationTests/search-box/SearchBox_SearchEngineIntegrationTests.swift:193 ``` wait(for: [nextExpect], timeout: 10) XCTAssertEqual(delegate.error?.localizedDescription, "") XCTAssertFalse(searchEngine.suggestions.isEmpty) ``` ```
|
||
if !timeRange.contains(value) { | ||
info( | ||
"search-box API time_deviation must be within 1 minute and 30 minutes (found \(value.value) seconds)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(just my thoughts)
so if the argument is out of bounds we just silently log and do nothing?
maybe we should force change deviation
to be in bounds or log with higher log level, like warning
or maybe fail the request alltogether
unit: UnitDuration.minutes | ||
) | ||
.converted(to: .seconds) | ||
let timeRange = (minimumTime...maximumTime) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can extract some logic here in a function to reuse it down below
Description
Checklist
CHANGELOG