Repository Public
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// PROJECT METADATA7// -----------------------------------------------------------------------------8// Project : Lou-Ka iOS9// File : LouKaUITests/MainFlowUITests.swift10// Description : parcours principal — accueil, carte, filtres, phrase11// libre, fiche et analyses v3, favori, comparateur, marché,12// quartiers, annuaire. Contre l'API publique de production13// (lecture seule).14// Module : LouKaUITests15// Repository : https://git.spboucher.ai/lou-ka-ios-v316// Project Website : https://www.lou-ka.com17// Created : 2026-11-2518// Last Modified : 2026-11-2819//20// =============================================================================21// AUTHOR & PROFESSIONAL AFFILIATION22// =============================================================================23//24// Author : Simon-Pierre Boucher25// Position : Professor of Finance26// Institution : Université du Québec en Outaouais (UQO)27// Department : Département des sciences administratives28// Organization : SP Boucher29//30// Website : https://spboucher.ai31// Git : https://git.spboucher.ai32//33// =============================================================================34// OFFICIAL CONTACT DIRECTORY35// =============================================================================36//37// General : info@spboucher.ai38// Professional : contact@spboucher.ai39// Direct : simon@spboucher.ai40// Research : research@spboucher.ai41// Development : dev@spboucher.ai42// Support : support@spboucher.ai43// Security/Admin : admin@spboucher.ai44// Notifications : notifications@spboucher.ai45//46// Preferred Contact: support@spboucher.ai47//48// =============================================================================49// COPYRIGHT & INTELLECTUAL PROPERTY50// =============================================================================51//52// Copyright (c) 202653// Simon-Pierre Boucher54//55// All rights reserved where applicable.56//57// This file is governed by the applicable project license,58// copyright notices, institutional agreements and relevant law.59//60// Unless expressly authorized by the applicable license or61// rights holder, copying, redistribution, sublicensing,62// publication and commercial exploitation are not permitted.63//64// Existing third-party rights and notices remain unaffected.65//66// =============================================================================67// CONFIDENTIALITY & SECURITY68// =============================================================================69//70// Classification : Public71// Distribution : Public repository; use is governed by the project license72// Security Contact : admin@spboucher.ai73//74// Access to this source does not independently grant permission75// to redistribute or disclose confidential materials.76//77// Do not embed credentials, private keys, access tokens,78// certificates or confidential personal information.79//80// =============================================================================81// LICENSE & MAINTENANCE82// =============================================================================83//84// License : None specified (no license file in this repository)85// Maintainer : Simon-Pierre Boucher86// Technical Contact: dev@spboucher.ai87//88// =============================================================================89// END OF SP BOUCHER SOURCE HEADER90// =============================================================================9192import XCTest9394final class MainFlowUITests: XCTestCase {95 private var app: XCUIApplication!9697 override func setUp() {98 continueAfterFailure = false99 app = XCUIApplication()100 app.launchArguments = ["-LKInMemory", "YES", "-AppleLanguages", "(fr-CA)"]101 }102103 private func snap(_ name: String) {104 let a = XCTAttachment(screenshot: XCUIScreen.main.screenshot())105 a.name = name106 a.lifetime = .keepAlways107 add(a)108 }109110 private func tab(_ name: String) -> XCUIElement {111 let bar = app.tabBars.buttons[name]112 return bar.exists ? bar : app.buttons[name].firstMatch113 }114115 func testDiscoverThenExplore() {116 app.launch()117 XCTAssertTrue(app.buttons["discover.explore"].waitForExistence(timeout: 20))118 XCTAssertTrue(app.staticTexts["Ouvrez la porte à votre prochain chez-vous."].waitForExistence(timeout: 20), "l'accroche de l'accueil est affichée")119 XCTAssertTrue(app.descendants(matching: .any)["discover.count"].waitForExistence(timeout: 20), "le nombre de logements distincts est chargé")120 snap("accueil")121 app.buttons["discover.explore"].tap()122 let counter = app.staticTexts.containing(NSPredicate(format: "label MATCHES '.*[0-9] logements? dans cette zone'")).firstMatch123 XCTAssertTrue(counter.waitForExistence(timeout: 25), "le compteur de la carte affiche un total")124 snap("explorer")125 }126127 func testFiltersNarrowTheSearch() {128 app.launchArguments += ["-LKCity", "Québec"]129 app.launch()130 XCTAssertTrue(app.buttons["explore.filters"].waitForExistence(timeout: 20))131 let counter = app.descendants(matching: .any)["explore.counter"]132 XCTAssertTrue(counter.waitForExistence(timeout: 20))133 app.buttons["explore.filters"].tap()134 let chip = app.buttons["filters.rooms.4"]135 XCTAssertTrue(chip.waitForExistence(timeout: 8))136 chip.tap()137 let apply = app.buttons["filters.apply"]138 XCTAssertTrue(apply.waitForExistence(timeout: 5))139 snap("filtres")140 apply.tap()141 XCTAssertTrue(app.buttons["explore.filters"].waitForExistence(timeout: 8))142 XCTAssertTrue(app.buttons.containing(NSPredicate(format: "label CONTAINS '1 actifs'")).firstMatch.waitForExistence(timeout: 8),143 "le bouton des filtres indique un filtre actif")144 }145146 /// Phrase libre : interprétée par le serveur, elle devient des filtres (lieu, grandeur, budget, attribut).147 func testNaturalLanguageSearch() {148 app.launchArguments += ["-LKPhrase", "4½ à Québec sous 1 500 $ avec balcon"]149 app.launch()150 XCTAssertTrue(app.buttons.containing(NSPredicate(format: "label CONTAINS '3 actifs'")).firstMatch.waitForExistence(timeout: 25),151 "grandeur, budget et balcon sont devenus trois filtres")152 let counter = app.staticTexts.containing(NSPredicate(format: "label MATCHES '.*[0-9] logements? dans cette zone'")).firstMatch153 XCTAssertTrue(counter.waitForExistence(timeout: 25))154 snap("phrase")155 }156157 /// Analyses v3 de la fiche : estimation avec son intervalle, coût réel, hypothèses personnelles.158 func testListingAnalyses() throws {159 let uid = try XCTUnwrap(ProcessInfo.processInfo.environment["LOUKA_TEST_UID"], "LOUKA_TEST_UID manquant (voir Scripts/build.sh uitest)")160 app.launchArguments += ["-LKOpen", "logement/\(uid)", "-LKAnchor", "analyses"]161 app.launch()162 XCTAssertTrue(app.staticTexts["Loyer estimé"].waitForExistence(timeout: 30), "l'estimation est chargée")163 XCTAssertTrue(app.staticTexts.containing(NSPredicate(format: "label CONTAINS 'annonces comparables sur 10'")).firstMatch.waitForExistence(timeout: 10),164 "l'intervalle est expliqué en toutes lettres")165 snap("estimation")166 // coût réel : la fiche est rouverte à cette section167 app.terminate()168 app.launchArguments = ["-LKInMemory", "YES", "-AppleLanguages", "(fr-CA)", "-LKOpen", "logement/\(uid)", "-LKAnchor", "cout"]169 app.launch()170 let edit = app.buttons["truecost.edit"]171 XCTAssertTrue(edit.waitForExistence(timeout: 30), "le coût réel propose de saisir ses propres montants")172 sleep(4) // l'ancre de départ a fini de défiler173 var tries = 0174 while !edit.isHittable, tries < 6 { app.swipeUp(velocity: .slow); tries += 1 }175 XCTAssertTrue(edit.isHittable)176 snap("cout-reel")177 edit.tap()178 XCTAssertTrue(app.navigationBars["Mes hypothèses"].waitForExistence(timeout: 8))179 let field = app.textFields["Internet"]180 XCTAssertTrue(field.waitForExistence(timeout: 5))181 field.tap(); field.typeText("65")182 app.buttons["Appliquer"].tap()183 XCTAssertTrue(app.descendants(matching: .any).matching(NSPredicate(format: "label CONTAINS 'Saisi par vous'")).firstMatch.waitForExistence(timeout: 20),184 "le montant saisi est repris par le calcul du serveur et étiqueté comme saisi")185 snap("cout-reel-saisi")186 }187188 /// Marché d'un lieu, puis villes et quartiers, puis le portrait d'un lieu.189 func testMarketAndNeighborhoods() {190 app.launchArguments += ["-LKTab", "market"]191 app.launch()192 XCTAssertTrue(app.staticTexts["loyer médian"].waitForExistence(timeout: 25))193 XCTAssertTrue(app.buttons["market.place"].exists)194 snap("marche")195 app.terminate()196 app.launchArguments += ["-LKRoute", "quartiers"]197 app.launch()198 let montreal = app.buttons.containing(NSPredicate(format: "label BEGINSWITH 'Montréal,'")).firstMatch199 XCTAssertTrue(montreal.waitForExistence(timeout: 25), "le classement des villes est chargé")200 snap("villes")201 montreal.tap()202 XCTAssertTrue(app.buttons["neighborhood.explore"].waitForExistence(timeout: 25), "le portrait de Montréal est chargé")203 XCTAssertTrue(app.staticTexts["loyer affiché médian"].exists)204 snap("portrait")205 }206207 /// Comparateur : deux logements, coût réel aux mêmes hypothèses, rapport PDF proposé.208 func testCompare() throws {209 let uid = try XCTUnwrap(ProcessInfo.processInfo.environment["LOUKA_TEST_UID"])210 let uid2 = try XCTUnwrap(ProcessInfo.processInfo.environment["LOUKA_TEST_UID2"])211 app.launchArguments += ["-LKTab", "favorites", "-LKRoute", "compare", "-LKSeed", "\(uid),\(uid2)"]212 app.launch()213 XCTAssertTrue(app.staticTexts["Coût réel"].waitForExistence(timeout: 30))214 XCTAssertTrue(app.staticTexts["Loyer estimé"].exists)215 XCTAssertTrue(app.buttons["compare.menu"].exists)216 snap("comparateur")217 }218219 func testListingFavoriteRoundTrip() throws {220 let uid = try XCTUnwrap(ProcessInfo.processInfo.environment["LOUKA_TEST_UID"], "LOUKA_TEST_UID manquant (voir Scripts/build.sh uitest)")221 app.launchArguments += ["-LKOpen", "logement/\(uid)"]222 app.launch()223 let open = app.buttons["listing.open"]224 XCTAssertTrue(open.waitForExistence(timeout: 25), "la fiche affiche le bouton Voir l'annonce")225 snap("fiche")226 let fav = app.buttons["listing.favorite"]227 XCTAssertTrue(fav.waitForExistence(timeout: 5))228 XCTAssertEqual(fav.label, "Ajouter aux favoris")229 fav.tap()230 XCTAssertEqual(fav.label, "Retirer des favoris")231 app.swipeUp()232 app.swipeUp()233 snap("fiche-analyses")234 app.navigationBars.buttons.firstMatch.tap()235 tab("Favoris").tap()236 XCTAssertTrue(app.staticTexts["1 favori"].waitForExistence(timeout: 10))237 snap("favoris")238 }239240 func testManagersDirectory() {241 app.launchArguments += ["-LKTab", "managers"]242 app.launch()243 XCTAssertTrue(app.staticTexts.containing(NSPredicate(format: "label MATCHES '[0-9 ]+ gestionnaires?'")).firstMatch.waitForExistence(timeout: 25))244 snap("gestionnaires")245 snap("annuaire")246 }247248 /// Ouvre un logement en touchant une carte de l'accueil : la porte joue (niveau signature, première249 /// ouverture de la session) et la fiche apparaît.250 func testDoorOpensListingFromCard() {251 app.launch()252 let card = app.buttons.matching(identifier: "listing.card").firstMatch253 XCTAssertTrue(card.waitForExistence(timeout: 25), "une carte d'annonce est affichée sur l'accueil")254 sleep(2) // la photo de la carte finit de se charger (vidéo de vérification)255 card.tap()256 XCTAssertTrue(app.buttons["listing.open"].waitForExistence(timeout: 15), "la fiche s'ouvre après la porte")257 snap("porte-fiche")258 }259260 /// Un toucher pendant l'animation l'interrompt : la fiche est là tout de suite, l'app reste utilisable.261 func testDoorInterruptedByTap() {262 app.launch()263 let card = app.buttons.matching(identifier: "listing.card").firstMatch264 XCTAssertTrue(card.waitForExistence(timeout: 25))265 sleep(2)266 let center = app.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.5))267 card.tap()268 center.tap() // pendant l'animation : interruption269 XCTAssertTrue(app.buttons["listing.open"].waitForExistence(timeout: 15), "la fiche s'ouvre malgré l'interruption")270 // l'app n'est pas restée bloquée sous le calque : le retour fonctionne271 app.navigationBars.buttons.firstMatch.tap()272 XCTAssertTrue(app.buttons["discover.explore"].waitForExistence(timeout: 10))273 }274}275