// Auteur : Simon-Pierre Boucher — contact@spboucher.ai // Test de fumée bout en bout : recherche d'adresse réelle → estimation complète // contre l'API de production. Capture des écrans dans /tmp/vp-ui-*.png. import XCTest final class SmokeTests: XCTestCase { private func snap(_ app: XCUIApplication, _ name: String) { let png = XCUIScreen.main.screenshot().pngRepresentation try? png.write(to: URL(fileURLWithPath: "/tmp/vp-ui-\(name).png")) } func testSearchToEstimate() throws { let app = XCUIApplication() app.launch() // 1. Recherche let field = app.textFields.firstMatch XCTAssertTrue(field.waitForExistence(timeout: 10), "champ de recherche absent") field.tap() field.typeText("10005 rue verville") // 2. Premier résultat (FTS5 côté serveur) let result = app.buttons.containing( NSPredicate(format: "label CONTAINS[c] 'VERVILLE'") ).firstMatch XCTAssertTrue(result.waitForExistence(timeout: 20), "aucun résultat de recherche") snap(app, "1-recherche") result.tap() // 3. Estimation complète (comparables + modèle) let kicker = app.staticTexts["VALEUR MARCHANDE ESTIMÉE"] XCTAssertTrue(kicker.waitForExistence(timeout: 45), "l'estimation n'est pas apparue") snap(app, "2-estimation") // 4. Défiler vers les comparables et déplier les ajustements app.swipeUp(velocity: .fast) app.swipeUp(velocity: .fast) snap(app, "3-details") let toggle = app.buttons.containing( NSPredicate(format: "label CONTAINS[c] 'ajustements'") ).firstMatch if toggle.waitForExistence(timeout: 5) { toggle.tap() snap(app, "4-comparable") } } func testMapNearby() throws { let app = XCUIApplication() app.launch() app.tabBars.buttons["Carte"].tap() // la puce affiche « N propriétés · touchez un point » une fois chargé let chip = app.staticTexts.containing( NSPredicate(format: "label CONTAINS 'touchez'") ).firstMatch XCTAssertTrue(chip.waitForExistence(timeout: 20), "puce de compteur absente") let loaded = NSPredicate(format: "label CONTAINS 'touchez' AND NOT label BEGINSWITH '0 '") expectation(for: loaded, evaluatedWith: chip) waitForExpectations(timeout: 30) snap(app, "6-carte") // toucher un point (identifiant d'accessibilité) → fiche → estimation complète let dot = app.buttons.matching(identifier: "vp-dot").firstMatch XCTAssertTrue(dot.waitForExistence(timeout: 10), "aucun point sur la carte") dot.tap() let cta = app.buttons["Estimer en détail →"] XCTAssertTrue(cta.waitForExistence(timeout: 8), "fiche de sélection absente") snap(app, "7-carte-fiche") cta.tap() let kicker = app.staticTexts["VALEUR MARCHANDE ESTIMÉE"] XCTAssertTrue(kicker.waitForExistence(timeout: 45), "estimation depuis la carte absente") snap(app, "8-carte-estimation") } func testManualEstimate() throws { let app = XCUIApplication() app.launch() app.tabBars.buttons["Manuelle"].tap() let field = app.textFields.firstMatch XCTAssertTrue(field.waitForExistence(timeout: 10)) field.tap() field.typeText("Lévis") app.scrollViews.buttons["Plex"].firstMatch.tap() app.swipeUp() // replie le clavier pour dégager le bouton app.scrollViews.buttons["Estimer"].firstMatch.tap() let kicker = app.staticTexts["VALEUR MARCHANDE ESTIMÉE"] XCTAssertTrue(kicker.waitForExistence(timeout: 45), "l'estimation manuelle n'est pas apparue") snap(app, "5-manuelle") } }