2019-12-19 17:32:49 +00:00
|
|
|
/*
|
2023-04-06 09:44:16 +00:00
|
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
2019-12-19 17:32:49 +00:00
|
|
|
*
|
|
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2016-12-01 18:28:57 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import XCTest
|
|
|
|
|
|
|
|
|
|
final class SearchViewControllerUITests: UITestCase {
|
2017-05-16 14:30:08 +00:00
|
|
|
|
2016-12-01 18:28:57 +00:00
|
|
|
var collectionViews: XCUIElementQuery!
|
2017-05-16 14:30:08 +00:00
|
|
|
|
2016-12-01 18:28:57 +00:00
|
|
|
override func setUp() {
|
|
|
|
|
super.setUp()
|
2017-05-16 14:30:08 +00:00
|
|
|
|
2016-12-07 14:28:29 +00:00
|
|
|
collectionViews = XCUIApplication().collectionViews
|
2016-12-01 18:28:57 +00:00
|
|
|
collectionViews.cells.staticTexts["Search Autocomplete"].tap()
|
|
|
|
|
}
|
2017-05-16 14:30:08 +00:00
|
|
|
|
2016-12-01 18:28:57 +00:00
|
|
|
func test_whenLoading_thatSomeResultsAreShown() {
|
|
|
|
|
let tacos = collectionViews.cells.staticTexts["tacos"]
|
|
|
|
|
let small = collectionViews.cells.staticTexts["small"]
|
|
|
|
|
XCTAssertTrue(tacos.exists)
|
|
|
|
|
XCTAssertTrue(small.exists)
|
|
|
|
|
}
|
2017-05-16 14:30:08 +00:00
|
|
|
|
2016-12-01 18:28:57 +00:00
|
|
|
func test_whenSearchingForText_thatResultsGetFiltered() {
|
|
|
|
|
let searchField = collectionViews.searchFields.element
|
|
|
|
|
searchField.tap()
|
|
|
|
|
searchField.typeText("tac")
|
2017-05-16 14:30:08 +00:00
|
|
|
|
2016-12-01 18:28:57 +00:00
|
|
|
let tacos = collectionViews.cells.staticTexts["tacos"]
|
|
|
|
|
let small = collectionViews.cells.staticTexts["small"]
|
|
|
|
|
XCTAssertTrue(tacos.exists)
|
|
|
|
|
XCTAssertFalse(small.exists)
|
|
|
|
|
}
|
2017-05-16 14:30:08 +00:00
|
|
|
|
2016-12-01 18:28:57 +00:00
|
|
|
func test_whenClearingText_thatResultsFilterIsRemoved() {
|
|
|
|
|
let searchField = collectionViews.searchFields.element
|
|
|
|
|
searchField.tap()
|
|
|
|
|
searchField.typeText("tac")
|
|
|
|
|
searchField.buttons.element.tap()
|
2017-05-16 14:30:08 +00:00
|
|
|
|
2016-12-01 18:28:57 +00:00
|
|
|
let tacos = collectionViews.cells.staticTexts["tacos"]
|
|
|
|
|
let small = collectionViews.cells.staticTexts["small"]
|
|
|
|
|
XCTAssertTrue(tacos.exists)
|
2017-05-16 14:30:08 +00:00
|
|
|
XCTAssertTrue(small.exists)
|
2016-12-01 18:28:57 +00:00
|
|
|
}
|
|
|
|
|
}
|