spb/vrai-prix-ios Public
App iOS native de Vrai-Prix — estimation immobilière transparente pour le Québec (SwiftUI, MapKit, Swift Charts)
Swift 100%
1// Auteur : Simon-Pierre Boucher — contact@spboucher.ai2// Test de fumée bout en bout : recherche d'adresse réelle → estimation complète3// contre l'API de production. Capture des écrans dans /tmp/vp-ui-*.png.4import XCTest56final class SmokeTests: XCTestCase {78 private func snap(_ app: XCUIApplication, _ name: String) {9 let png = XCUIScreen.main.screenshot().pngRepresentation10 try? png.write(to: URL(fileURLWithPath: "/tmp/vp-ui-\(name).png"))11 }1213 func testSearchToEstimate() throws {14 let app = XCUIApplication()15 app.launch()1617 // 1. Recherche18 let field = app.textFields.firstMatch19 XCTAssertTrue(field.waitForExistence(timeout: 10), "champ de recherche absent")20 field.tap()21 field.typeText("10005 rue verville")2223 // 2. Premier résultat (FTS5 côté serveur)24 let result = app.buttons.containing(25 NSPredicate(format: "label CONTAINS[c] 'VERVILLE'")26 ).firstMatch27 XCTAssertTrue(result.waitForExistence(timeout: 20), "aucun résultat de recherche")28 snap(app, "1-recherche")29 result.tap()3031 // 3. Estimation complète (comparables + modèle)32 let kicker = app.staticTexts["VALEUR MARCHANDE ESTIMÉE"]33 XCTAssertTrue(kicker.waitForExistence(timeout: 45), "l'estimation n'est pas apparue")34 snap(app, "2-estimation")3536 // 4. Défiler vers les comparables et déplier les ajustements37 app.swipeUp(velocity: .fast)38 app.swipeUp(velocity: .fast)39 snap(app, "3-details")40 let toggle = app.buttons.containing(41 NSPredicate(format: "label CONTAINS[c] 'ajustements'")42 ).firstMatch43 if toggle.waitForExistence(timeout: 5) {44 toggle.tap()45 snap(app, "4-comparable")46 }47 }4849 func testMapNearby() throws {50 let app = XCUIApplication()51 app.launch()5253 app.tabBars.buttons["Carte"].tap()5455 // la puce affiche « N propriétés · touchez un point » une fois chargé56 let chip = app.staticTexts.containing(57 NSPredicate(format: "label CONTAINS 'touchez'")58 ).firstMatch59 XCTAssertTrue(chip.waitForExistence(timeout: 20), "puce de compteur absente")60 let loaded = NSPredicate(format: "label CONTAINS 'touchez' AND NOT label BEGINSWITH '0 '")61 expectation(for: loaded, evaluatedWith: chip)62 waitForExpectations(timeout: 30)63 snap(app, "6-carte")6465 // toucher un point (identifiant d'accessibilité) → fiche → estimation complète66 let dot = app.buttons.matching(identifier: "vp-dot").firstMatch67 XCTAssertTrue(dot.waitForExistence(timeout: 10), "aucun point sur la carte")68 dot.tap()69 let cta = app.buttons["Estimer en détail →"]70 XCTAssertTrue(cta.waitForExistence(timeout: 8), "fiche de sélection absente")71 snap(app, "7-carte-fiche")72 cta.tap()73 let kicker = app.staticTexts["VALEUR MARCHANDE ESTIMÉE"]74 XCTAssertTrue(kicker.waitForExistence(timeout: 45), "estimation depuis la carte absente")75 snap(app, "8-carte-estimation")76 }7778 func testManualEstimate() throws {79 let app = XCUIApplication()80 app.launch()8182 app.tabBars.buttons["Manuelle"].tap()83 let field = app.textFields.firstMatch84 XCTAssertTrue(field.waitForExistence(timeout: 10))85 field.tap()86 field.typeText("Lévis")87 app.scrollViews.buttons["Plex"].firstMatch.tap()88 app.swipeUp() // replie le clavier pour dégager le bouton89 app.scrollViews.buttons["Estimer"].firstMatch.tap()9091 let kicker = app.staticTexts["VALEUR MARCHANDE ESTIMÉE"]92 XCTAssertTrue(kicker.waitForExistence(timeout: 45), "l'estimation manuelle n'est pas apparue")93 snap(app, "5-manuelle")94 }95}96