// // CollectionScreen.swift // PlantGuideUITests // // Screen object for the Collection tab. // import XCTest struct CollectionScreen { let app: XCUIApplication // MARK: - Elements var navigationBar: XCUIElement { app.navigationBars["My Plants"] } var searchField: XCUIElement { app.searchFields.firstMatch } var viewModeToggle: XCUIElement { app.buttons[UITestID.Collection.viewModeToggle] } var filterButton: XCUIElement { app.buttons[UITestID.Collection.filterButton] } var emptyStateView: XCUIElement { app.otherElements[UITestID.Collection.emptyStateView] } var scrollView: XCUIElement { app.scrollViews.firstMatch } var tableView: XCUIElement { app.tables.firstMatch } // MARK: - State Checks @discardableResult func waitForLoad(timeout: TimeInterval = 10) -> Bool { navigationBar.waitForExistence(timeout: timeout) } var hasPlants: Bool { scrollView.exists || tableView.exists } // MARK: - Actions func search(_ text: String) { XCTAssertTrue(searchField.waitForExistence(timeout: 5), "Search field missing") searchField.tap() searchField.typeText(text) } }