SPB Git

Repository Public BSD-3-Clause

SearchTests.swift 7.3 KB 175 lines swift

1// =============================================================================2//                  SP BOUCHER | SOFTWARE & RESEARCH3//             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// PROJECT METADATA7// -----------------------------------------------------------------------------8// Project          : ORIX Maps9// File             : Apps/ORIXMaps/Tests/ORIXMapsUITests/SearchTests.swift10// Module           : ORIXMapsUITests11// Repository       : https://git.spboucher.ai/orix-maps12// Created          : 2026-11-2513// Last Modified    : 2026-11-2514//15// =============================================================================16// AUTHOR & PROFESSIONAL AFFILIATION17// =============================================================================18//19// Author           : Simon-Pierre Boucher20// Position         : Professor of Finance21// Institution      : Université du Québec en Outaouais (UQO)22// Department       : Département des sciences administratives23// Organization     : SP Boucher24//25// Website          : https://spboucher.ai26// Git              : https://git.spboucher.ai27//28// =============================================================================29// OFFICIAL CONTACT DIRECTORY30// =============================================================================31//32// General          : info@spboucher.ai33// Professional     : contact@spboucher.ai34// Direct           : simon@spboucher.ai35// Research         : research@spboucher.ai36// Development      : dev@spboucher.ai37// Support          : support@spboucher.ai38// Security/Admin   : admin@spboucher.ai39// Notifications    : notifications@spboucher.ai40//41// Preferred Contact: support@spboucher.ai42//43// =============================================================================44// COPYRIGHT & INTELLECTUAL PROPERTY45// =============================================================================46//47// Copyright (c) 202648// Simon-Pierre Boucher49//50// All rights reserved where applicable.51//52// This file is governed by the applicable project license,53// copyright notices, institutional agreements and relevant law.54//55// Unless expressly authorized by the applicable license or56// rights holder, copying, redistribution, sublicensing,57// publication and commercial exploitation are not permitted.58//59// Existing third-party rights and notices remain unaffected.60//61// =============================================================================62// CONFIDENTIALITY & SECURITY63// =============================================================================64//65// Classification   : Public66// Distribution     : Public repository; use is governed by the project license67// Security Contact : admin@spboucher.ai68//69// Access to this source does not independently grant permission70// to redistribute or disclose confidential materials.71//72// Do not embed credentials, private keys, access tokens,73// certificates or confidential personal information.74//75// =============================================================================76// LICENSE & MAINTENANCE77// =============================================================================78//79// License          : Proprietary, all rights reserved (see license file)80// License File     : LICENSE81// Maintainer       : Simon-Pierre Boucher82// Technical Contact: dev@spboucher.ai83//84// =============================================================================85// END OF SP BOUCHER SOURCE HEADER86// =============================================================================8788import XCTest8990@MainActor91final class SearchTests: ORIXUITestCase {92    private var results: XCUIElementQuery { app.buttons.matching(identifier: "search.result") }93    private var title: XCUIElement { app.staticTexts["panel.title"] }9495    func testSearchByName() {96        launch(region: true)97        search("Stade olympique")98        let hit = require(results.containing(NSPredicate(format: "label CONTAINS[c] %@", "Stade olympique")).firstMatch, "the stadium is found by name")99        screenshot("search-name")100        hit.tap()101        require(title)102        XCTAssertTrue(title.label.contains("Stade olympique"), "place card title is \(title.label)")103        require(app.buttons["place.directions"])104        require(app.buttons["place.save"])105        screenshot("place-card")106    }107108    func testSuggestionsAppearWhileTyping() {109        launch(region: true)110        let field = require(app.textFields["search.field"])111        field.tap()112        field.typeText("Biod")113        require(results.containing(NSPredicate(format: "label CONTAINS[c] %@", "Biodôme")).firstMatch, "suggestions appear before Search is pressed")114        require(app.buttons["search.clear"]).tap()115        waitGone(results.firstMatch)116    }117118    func testSearchByAddressWithAHouseNumber() {119        launch(region: true)120        search("4545 avenue Pierre-De Coubertin")121        let hit = require(results.containing(NSPredicate(format: "label CONTAINS[c] %@", "Pierre-De Coubertin")).firstMatch, "the address is found")122        screenshot("search-address")123        XCTAssertTrue(hit.label.contains("4545"), "the first result on that street is the address itself, with its number: \(hit.label)")124        XCTAssertFalse(hit.label.contains("Street only"), hit.label)125        hit.tap()126        require(title)127        require(app.buttons["place.directions"])128    }129130    func testAnUnknownHouseNumberFallsBackToTheStreetAndSaysSo() {131        launch(region: true)132        search("99999 avenue Pierre-De Coubertin")133        require(text(containing: "Street only — number 99999 not found"), "an unknown number is reported, never invented")134    }135136    func testSearchByCategoryChip() {137        launch(region: true)138        require(app.buttons["category.cafe"]).tap()139        require(results.firstMatch, "cafés are listed around the map centre")140        XCTAssertGreaterThan(results.count, 3)141        require(app.staticTexts["Café"], "the category is the heading of the list")142        screenshot("search-category")143        results.firstMatch.tap()144        require(title)145        XCTAssertTrue(require(app.staticTexts["panel.subtitle"]).label.contains("Café"), "the card of a category result names the category")146    }147148    func testCoordinatesWorkWithNoRegionInstalled() {149        launch(camera: nil)150        require(app.staticTexts["No map downloaded yet"])151        search("45.5017, -73.5673")152        require(title, "coordinates open a place card with no region")153        XCTAssertTrue(title.label.contains("45.5017"), "title is \(title.label)")154        // Every coordinate format is offered for copy.155        require(app.buttons.containing(NSPredicate(format: "label BEGINSWITH %@", "Copy ")).firstMatch)156        XCTAssertGreaterThanOrEqual(app.buttons.matching(NSPredicate(format: "label BEGINSWITH %@", "Copy ")).count, 4)157        screenshot("search-coordinates-no-region")158    }159160    func testTextSearchWithNoRegionExplainsWhy() {161        launch(camera: nil)162        search("café")163        require(text(containing: "No installed region includes search. Coordinates still work"))164    }165166    func testNothingFound() {167        launch(region: true)168        search("zzqxjkvwpt")169        require(app.staticTexts["Nothing found"])170        require(text(containing: "Search covers the regions installed on this device."))171        XCTAssertEqual(results.count, 0)172        screenshot("search-nothing-found")173    }174}175
Files main
Menu

Theme