Repository Public
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// PROJECT METADATA7// -----------------------------------------------------------------------------8// Project : Valo-Plex iOS9// File : ValoPlexUITests/ParcoursTests.swift10// Description : parcours d'interface dans le simulateur, contre l'API de11// production : recherche, fiche, favori, retour, onglets,12// saisie dans le calculateur.13// Module : ValoPlexUITests14// Repository : https://git.spboucher.ai/valo-plex-ios15// Project Website : https://www.valo-plex.com16// Created : 2026-12-0117// Last Modified : 2026-12-0118//19// =============================================================================20// AUTHOR & PROFESSIONAL AFFILIATION21// =============================================================================22//23// Author : Simon-Pierre Boucher24// Position : Professor of Finance25// Institution : Université du Québec en Outaouais (UQO)26// Department : Département des sciences administratives27// Organization : SP Boucher28//29// Website : https://spboucher.ai30// Git : https://git.spboucher.ai31//32// =============================================================================33// OFFICIAL CONTACT DIRECTORY34// =============================================================================35//36// General : info@spboucher.ai37// Professional : contact@spboucher.ai38// Direct : simon@spboucher.ai39// Research : research@spboucher.ai40// Development : dev@spboucher.ai41// Support : support@spboucher.ai42// Security/Admin : admin@spboucher.ai43// Notifications : notifications@spboucher.ai44//45// Preferred Contact: support@spboucher.ai46//47// =============================================================================48// COPYRIGHT & INTELLECTUAL PROPERTY49// =============================================================================50//51// Copyright (c) 202652// Simon-Pierre Boucher53//54// All rights reserved where applicable.55//56// This file is governed by the applicable project license,57// copyright notices, institutional agreements and relevant law.58//59// Unless expressly authorized by the applicable license or60// rights holder, copying, redistribution, sublicensing,61// publication and commercial exploitation are not permitted.62//63// Existing third-party rights and notices remain unaffected.64//65// =============================================================================66// CONFIDENTIALITY & SECURITY67// =============================================================================68//69// Classification : Public70// Distribution : Public repository; use is governed by the project license71// Security Contact : admin@spboucher.ai72//73// Access to this source does not independently grant permission74// to redistribute or disclose confidential materials.75//76// Do not embed credentials, private keys, access tokens,77// certificates or confidential personal information.78//79// =============================================================================80// LICENSE & MAINTENANCE81// =============================================================================82//83// License : None specified (no license file in this repository)84// Maintainer : Simon-Pierre Boucher85// Technical Contact: dev@spboucher.ai86//87// =============================================================================88// END OF SP BOUCHER SOURCE HEADER89// =============================================================================9091import XCTest9293final class ParcoursTests: XCTestCase {94 override func setUp() { continueAfterFailure = false }9596 /// Capture gardée dans le résultat du test, même en cas de succès (relue ensuite à l'œil).97 @MainActor98 private func garder(_ app: XCUIApplication, _ nom: String) {99 let a = XCTAttachment(screenshot: app.screenshot())100 a.name = nom101 a.lifetime = .keepAlways102 add(a)103 }104105 /// Premier élément dont le libellé contient le texte (les montants portent des espaces insécables).106 @MainActor107 private func contient(_ app: XCUIApplication, _ texte: String) -> XCUIElement {108 app.descendants(matching: .any).matching(NSPredicate(format: "label CONTAINS %@", texte)).firstMatch109 }110111 @MainActor112 func testRechercheFicheFavoriOnglets() {113 let app = XCUIApplication()114 app.launch()115116 let champ = app.textFields["recherche"]117 XCTAssertTrue(champ.waitForExistence(timeout: 15))118 champ.tap()119 champ.typeText("2335 wellington")120 let resultat = app.buttons.containing(NSPredicate(format: "label CONTAINS[c] 'rue Wellington'")).firstMatch121 XCTAssertTrue(resultat.waitForExistence(timeout: 15), "aucun résultat de recherche")122 resultat.tap()123124 XCTAssertTrue(app.staticTexts["fiche-valeur"].waitForExistence(timeout: 15), "la valeur de la fiche n'apparaît pas")125 XCTAssertTrue(app.staticTexts["fiche-adresse"].label.contains("Wellington"))126 let favori = app.buttons["favori"]127 if favori.label == "Retirer des favoris" { favori.tap() } // reste d'un passage interrompu128 XCTAssertEqual(favori.label, "Ajouter aux favoris")129 favori.tap()130 XCTAssertEqual(favori.label, "Retirer des favoris")131 garder(app, "etape-1")132133 app.buttons["Retour"].tap()134 XCTAssertTrue(champ.waitForExistence(timeout: 5))135 app.buttons["effacer"].tap()136 XCTAssertTrue(app.staticTexts["Vos immeubles."].waitForExistence(timeout: 5), "le favori n'apparaît pas à l'accueil")137 XCTAssertTrue(app.staticTexts["Reprendre où vous étiez."].exists, "l'immeuble consulté n'apparaît pas à l'accueil")138139 // le défilement referme le clavier, la barre d'onglets revient140 app.swipeUp()141 XCTAssertTrue(app.buttons["onglet-annonces"].waitForExistence(timeout: 5), "la barre d'onglets ne revient pas après le défilement")142143 // onglets144 app.buttons["onglet-annonces"].tap()145 XCTAssertTrue(app.staticTexts["Chaque prix demandé, face à la valeur."].waitForExistence(timeout: 10))146 app.buttons["onglet-marche"].tap()147 XCTAssertTrue(app.staticTexts["Le marché des plex, mesuré sur les ventes."].waitForExistence(timeout: 10))148 app.buttons["onglet-methode"].tap()149 XCTAssertTrue(app.staticTexts["Le calcul, montré en entier."].waitForExistence(timeout: 10))150151 // calculateur : une saisie relance le calcul et le clavier se referme par « Terminé »152 app.buttons["onglet-calcul"].tap()153 let prix = app.textFields["champ-prix"]154 XCTAssertTrue(prix.waitForExistence(timeout: 10))155 XCTAssertTrue(contient(app, "283\u{00A0}333\u{00A0}$").waitForExistence(timeout: 15), "le pro forma de départ n'est pas calculé")156 prix.tap()157 prix.typeText("7") // où que tombe le curseur, le prix change158 XCTAssertNotEqual(prix.value as? String, "850000", "la saisie n'est pas arrivée dans le champ")159 let ancien = contient(app, "283\u{00A0}333\u{00A0}$")160 let parti = expectation(for: NSPredicate(format: "exists == false"), evaluatedWith: ancien)161 wait(for: [parti], timeout: 15)162 let termine = app.buttons["clavier-termine"]163 XCTAssertTrue(termine.waitForExistence(timeout: 5), "bouton « Terminé » absent du clavier")164 termine.tap()165 XCTAssertTrue(app.buttons["onglet-calcul"].waitForExistence(timeout: 5), "la barre d'onglets ne revient pas après le clavier")166 garder(app, "etape-2")167168 // retirer le favori pour laisser le simulateur propre169 app.buttons["onglet-recherche"].tap()170 app.buttons.containing(NSPredicate(format: "label CONTAINS[c] 'rue Wellington'")).firstMatch.tap()171 XCTAssertTrue(favori.waitForExistence(timeout: 15))172 favori.tap()173 XCTAssertEqual(favori.label, "Ajouter aux favoris")174 }175176 /// Carte : au niveau de la rue, les plex arrivent un à un ; toucher le bâtiment au centre ouvre sa feuille,177 /// qui mène à la fiche. Bascule plan / 3D.178 @MainActor179 func testCarteBatimentFeuilleFiche() {180 let app = XCUIApplication()181 app.launchArguments = ["-VXTab", "carte", "-VXCarte", "45.475312,-73.561071,18", "-VXOuverture", "non"]182 app.launch()183 let etat = app.staticTexts.containing(NSPredicate(format: "label CONTAINS 'Touchez un bâtiment'")).firstMatch184 XCTAssertTrue(etat.waitForExistence(timeout: 30), "les immeubles de la vue n'arrivent pas")185 let carte = app.descendants(matching: .any)["carte-gl"]186 XCTAssertTrue(carte.exists)187 sleep(4) // les tuiles finissent d'arriver, les bâtiments prennent leur couleur188 garder(app, "etape-3")189 let feuille = app.buttons["carte-ouvrir"]190 // des bâtiments colorés occupent la moitié haute de la vue : on en touche un191 // (coordonnées de la fenêtre : la carte expose ses propres éléments d'accessibilité, qui changent)192 for decalage in [CGVector(dx: 0.5, dy: 0.52), CGVector(dx: 0.55, dy: 0.46), CGVector(dx: 0.3, dy: 0.5), CGVector(dx: 0.8, dy: 0.38), CGVector(dx: 0.2, dy: 0.6), CGVector(dx: 0.6, dy: 0.3)] {193 app.coordinate(withNormalizedOffset: decalage).tap()194 if feuille.waitForExistence(timeout: 3) { break }195 }196 XCTAssertTrue(feuille.exists, "toucher le bâtiment au centre n'ouvre aucune feuille")197 garder(app, "etape-4")198 app.buttons["carte-plan"].tap()199 sleep(2)200 garder(app, "etape-5")201 XCTAssertTrue(feuille.exists)202 feuille.tap()203 XCTAssertTrue(app.staticTexts["fiche-adresse"].waitForExistence(timeout: 15), "la feuille ne mène pas à la fiche")204 }205}206