SPB Git

Repository Public

AdminUITests.swift 27.0 KB 505 lines swift

1// =============================================================================2//                  SP BOUCHER | SOFTWARE & RESEARCH3//             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// PROJECT METADATA7// -----------------------------------------------------------------------------8// Project          : Immo-Ka Admin iOS9// File             : ImmoKaAdminUITests/AdminUITests.swift10// Description      : parcours de l'outil contre la préproduction, avec un jeton11//                    de session d'essai (`-IKAdminToken`, Debug seulement) :12//                    tableau de bord → approuver une demande (permis,13//                    téléphones, rappel de l'OACIQ) → en refuser une autre avec14//                    motif → rattacher une demande hors annuaire → traiter un15//                    signalement → lire un courriel (remis non lu s'il l'était,16//                    rien n'est envoyé) → journal → déconnexion. Les demandes,17//                    l'acheteur et le signalement d'essai sont créés par l'API18//                    avant le test et les comptes sont supprimés après. Aussi :19//                    annuaire, fiche et registre de l'OACIQ dans Safari, écran20//                    de connexion et activation, verrouillage.21// Module           : ImmoKaAdminUITests22// Repository       : https://git.spboucher.ai/immo-ka-admin-ios23// Project Website  : https://www.immo-ka.com24// Created          : 2026-11-3025// Last Modified    : 2026-12-0126//27// =============================================================================28// AUTHOR & PROFESSIONAL AFFILIATION29// =============================================================================30//31// Author           : Simon-Pierre Boucher32// Position         : Professor of Finance33// Institution      : Université du Québec en Outaouais (UQO)34// Department       : Département des sciences administratives35// Organization     : SP Boucher36//37// Website          : https://spboucher.ai38// Git              : https://git.spboucher.ai39//40// =============================================================================41// OFFICIAL CONTACT DIRECTORY42// =============================================================================43//44// General          : info@spboucher.ai45// Professional     : contact@spboucher.ai46// Direct           : simon@spboucher.ai47// Research         : research@spboucher.ai48// Development      : dev@spboucher.ai49// Support          : support@spboucher.ai50// Security/Admin   : admin@spboucher.ai51// Notifications    : notifications@spboucher.ai52//53// Preferred Contact: support@spboucher.ai54//55// =============================================================================56// COPYRIGHT & INTELLECTUAL PROPERTY57// =============================================================================58//59// Copyright (c) 202660// Simon-Pierre Boucher61//62// All rights reserved where applicable.63//64// This file is governed by the applicable project license,65// copyright notices, institutional agreements and relevant law.66//67// Unless expressly authorized by the applicable license or68// rights holder, copying, redistribution, sublicensing,69// publication and commercial exploitation are not permitted.70//71// Existing third-party rights and notices remain unaffected.72//73// =============================================================================74// CONFIDENTIALITY & SECURITY75// =============================================================================76//77// Classification   : Public78// Distribution     : Public repository; use is governed by the project license79// Security Contact : admin@spboucher.ai80//81// Access to this source does not independently grant permission82// to redistribute or disclose confidential materials.83//84// Do not embed credentials, private keys, access tokens,85// certificates or confidential personal information.86//87// =============================================================================88// LICENSE & MAINTENANCE89// =============================================================================90//91// License          : None specified (no license file in this repository)92// Maintainer       : Simon-Pierre Boucher93// Technical Contact: dev@spboucher.ai94//95// =============================================================================96// END OF SP BOUCHER SOURCE HEADER97// =============================================================================9899import XCTest100101final class AdminUITests: XCTestCase {102    private var app: XCUIApplication!103    private let env = ProcessInfo.processInfo.environment104    private var base: String { env["IMMOKA_ADMIN_BASE"] ?? "" }105    private var token: String { env["IMMOKA_ADMIN_TOKEN"] ?? "" }106    private var dark: Bool { env["IMMOKA_APPEARANCE"] == "dark" }107    /// Comptes d'essai à supprimer en fin de test (courriel, mot de passe).108    private var disposable: [(String, String)] = []109110    override func setUp() {111        continueAfterFailure = false112        app = XCUIApplication()113        app.launchArguments = ["-AppleLanguages", "(fr-CA)", "-appearance", dark ? "dark" : "light"]114    }115116    override func tearDown() {117        for (email, password) in disposable {118            let r = call("POST", "/compte/connexion", body: ["email": email, "password": password])119            if let t = (r.json["session"] as? [String: Any])?["token"] as? String { call("POST", "/compte/suppression", token: t, body: ["password": password]) }120        }121        disposable = []122    }123124    private func signedInArguments() throws -> [String] {125        try XCTSkipIf(base.isEmpty || token.isEmpty, "jeton de session d'essai absent : Scripts/session-essai.sh")126        return ["-IKBaseURL", base, "-IKAdminToken", token]127    }128129    private func snap(_ name: String) {130        let a = XCTAttachment(screenshot: XCUIScreen.main.screenshot())131        a.name = "admin-" + name + (dark ? "-sombre" : "")132        a.lifetime = .keepAlways133        add(a)134    }135136    // MARK: Préproduction, par l'API (données d'essai)137138    @discardableResult139    private func call(_ method: String, _ path: String, token: String? = nil, client: String = "ios", body: [String: Any]? = nil) -> (status: Int, json: [String: Any]) {140        var req = URLRequest(url: URL(string: base + "/api/v3" + path)!)141        req.httpMethod = method142        req.setValue(client, forHTTPHeaderField: "X-ImmoKa-Client")143        req.setValue("application/json", forHTTPHeaderField: "Content-Type")144        if let token { req.setValue("Bearer \(token)", forHTTPHeaderField: "Authorization") }145        if method != "GET" { req.httpBody = try? JSONSerialization.data(withJSONObject: body ?? [:]) }146        let done = expectation(description: path)147        var out: (Int, [String: Any]) = (0, [:])148        URLSession.shared.dataTask(with: req) { data, resp, _ in149            out = ((resp as? HTTPURLResponse)?.statusCode ?? 0, (data.flatMap { try? JSONSerialization.jsonObject(with: $0) } as? [String: Any]) ?? [:])150            done.fulfill()151        }.resume()152        wait(for: [done], timeout: 25)153        return out154    }155156    /// Crée un compte vérifié (code 424242) et rend son jeton.157    private func account(_ body: [String: Any]) throws -> String {158        let email = body["email"] as! String, password = body["password"] as! String159        XCTAssertEqual(call("POST", "/compte/inscription", body: body).status, 202, "inscription d'essai")160        let r = call("POST", "/compte/verification", body: ["email": email, "code": "424242"])161        disposable.append((email, password))162        return try XCTUnwrap((r.json["session"] as? [String: Any])?["token"] as? String, "vérification d'essai (\(r.status))")163    }164165    /// Deux courtiers de l'annuaire d'essai : (identifiant, nom).166    private func directory() throws -> [(id: String, name: String)] {167        let items = (call("GET", "/courtiers/recherche?q=lacasse").json["items"] as? [[String: Any]]) ?? []168        let found = items.compactMap { i in (i["broker_id"] as? String).flatMap { id in (i["name"] as? String).map { (id: id, name: $0) } } }169        try XCTSkipIf(found.count < 2, "annuaire d'essai : deux courtiers attendus")170        return found171    }172173    /// Une demande d'accès de courtier en attente. Avec `brokerID`, le courtier s'est désigné dans l'annuaire ;174    /// sinon il a écrit son nom et son agence (demande hors annuaire).175    private func pendingRequest(_ tag: String, name: String, brokerID: String?, company: String = "", phone: String = "") throws -> String {176        let email = "essai-admin-\(tag)@example.org"177        var body: [String: Any] = ["role": "courtier", "name": name, "email": email, "password": "Sapin-Bleu-\(tag)", "permit": "H1234"]178        if let brokerID { body["broker_id"] = brokerID } else { body["company"] = company; body["agency"] = "Agence Essai \(tag)" }179        if !phone.isEmpty { body["phone"] = phone }180        _ = try account(body)181        return email182    }183184    /// Le téléphone que l'annuaire publie pour le courtier d'une demande (lu par l'API d'administration).185    private func publishedPhone(of email: String) -> String {186        let items = (call("GET", "/admin/courtiers?etat=en_attente", token: token, client: "ios-admin").json["items"] as? [[String: Any]]) ?? []187        let mine = items.first { $0["email"] as? String == email }188        return ((mine?["directory"] as? [String: Any])?["phone"] as? String) ?? ""189    }190191    /// Un acheteur écrit à un courtier puis signale la conversation.192    private func report(_ tag: String, brokerID: String) throws -> String {193        let buyer = try account(["email": "ios-admin-\(tag)@example.org", "password": "Sapin-Bleu-\(tag)", "name": "Sam Essai \(tag)"])194        let opened = call("POST", "/messagerie", token: buyer, body: ["broker_id": brokerID, "text": "Message d'essai \(tag) <b>balise</b>"])195        let id = try XCTUnwrap((opened.json["conversation"] as? [String: Any])?["id"] as? String, "conversation d'essai (\(opened.status))")196        let reason = "Essai Immo-Ka Admin \(tag)"197        XCTAssertEqual(call("POST", "/messagerie/\(id)/signalement", token: buyer, body: ["reason": reason]).status, 202)198        return reason199    }200201    private func element(_ id: String) -> XCUIElement { app.descendants(matching: .any).matching(identifier: id).firstMatch }202203    // MARK: Gestes204205    private func tab(_ name: String) {206        let bar = app.tabBars.buttons[name]207        let b = bar.exists ? bar : app.buttons[name].firstMatch208        XCTAssertTrue(b.waitForExistence(timeout: 10), "onglet \(name)")209        b.tap()210    }211212    private func text(containing s: String) -> XCUIElement {213        app.descendants(matching: .any).matching(NSPredicate(format: "label CONTAINS %@", s)).firstMatch214    }215216    private func reveal(_ e: XCUIElement) {217        var tries = 0218        while !(e.exists && e.isHittable), tries < 10 { app.swipeUp(velocity: .slow); tries += 1 }219    }220221    private func back() { app.navigationBars.buttons.firstMatch.tap() }222223    /// Bouton d'une alerte de confirmation.224    private func confirm(_ label: String) {225        let alert = app.alerts.firstMatch226        XCTAssertTrue(alert.waitForExistence(timeout: 8), "une confirmation est demandée")227        alert.buttons[label].firstMatch.tap()228    }229230    // MARK: Parcours231232    func testAdminJourney() throws {233        let args = try signedInArguments()234        let tag = "\(Int(Date().timeIntervalSince1970) % 1_000_000)"235        let dir = try directory()236        let refuseEmail = try pendingRequest(tag + "r", name: "René Refusé \(tag)", brokerID: dir[0].id)237        // la demande à approuver déclare le téléphone que ce courtier publie : les deux numéros concordent238        let published = publishedPhone(of: refuseEmail)239        let approveEmail = try pendingRequest(tag + "a", name: "Alix Approuvée \(tag)", brokerID: dir[0].id, phone: published)240        let outsideEmail = try pendingRequest(tag + "h", name: "Henri Hors-Annuaire \(tag)", brokerID: nil, company: dir[1].name)241        let reason = try report(tag, brokerID: dir[0].id)242243        app.launchArguments += args244        app.launch()245246        // tableau de bord : ce qui demande une action247        let pending = element("dashboard.pending")248        XCTAssertTrue(pending.waitForExistence(timeout: 30), "le tableau de bord s'ouvre avec le jeton d'essai")249        XCTAssertTrue(text(containing: "Bonjour,").exists)250        XCTAssertTrue(pending.label.contains("courtiers"), "le tableau de bord parle de courtiers")251        let n = Int(pending.label.components(separatedBy: " : ").last?.filter(\.isNumber) ?? "") ?? 0252        XCTAssertGreaterThanOrEqual(n, 3, "les trois demandes d'essai sont comptées")253        XCTAssertTrue(element("dashboard.reports").exists)254        snap("01-tableau-de-bord")255        pending.tap()256257        // approuver une demande : permis en évidence, rappel de l'OACIQ, téléphones côte à côte, indices258        let rowA = text(containing: approveEmail)259        XCTAssertTrue(rowA.waitForExistence(timeout: 20), "la demande à approuver est dans la liste « En attente »")260        snap("02-demandes-en-attente")261        rowA.tap()262        let permit = element("broker.permit")263        XCTAssertTrue(permit.waitForExistence(timeout: 10), "le détail montre le permis")264        XCTAssertTrue(permit.label.filter { !$0.isWhitespace }.hasSuffix("H1234"), "le permis déclaré est lu du titre : \(permit.label)")265        XCTAssertTrue(text(containing: "À vérifier dans le registre de l'OACIQ avant d'approuver").exists, "le rappel accompagne le permis")266        XCTAssertTrue(element("permit.oaciq").exists, "le registre de l'OACIQ s'ouvre d'ici")267        snap("03-demande")268        let verdict = element("broker.phone.verdict")269        reveal(verdict)270        XCTAssertTrue(element("broker.phone.declared").exists && element("broker.phone.published").exists, "les deux téléphones sont montrés")271        if published.isEmpty {272            XCTAssertTrue(verdict.label.contains("ne publie aucun numéro"), "verdict écrit : \(verdict.label)")273        } else {274            XCTAssertTrue(verdict.label.contains("identiques"), "verdict écrit : \(verdict.label)")275            let flag = element("broker.flag.telephone_publie")276            reveal(flag)277            XCTAssertTrue(flag.exists && flag.label.contains("Bon signe"), "l'indice « téléphone publié » est expliqué")278        }279        snap("03b-telephones-et-indices")280        let approve = app.buttons["broker.action.approuver"]281        reveal(approve)282        approve.tap()283        XCTAssertTrue(app.buttons["decision.confirm"].waitForExistence(timeout: 8), "toute décision est confirmée")284        XCTAssertTrue(text(containing: "Permis déclaré : H1234. À vérifier dans le registre de l'OACIQ avant d'approuver.").waitForExistence(timeout: 5), "le rappel revient dans la confirmation de l'approbation")285        XCTAssertTrue(text(containing: "prévenue par courriel").exists)286        snap("04-approuver")287        app.buttons["decision.confirm"].tap()288        XCTAssertTrue(text(containing: "Demande approuvée").waitForExistence(timeout: 20))289        XCTAssertTrue(app.buttons["broker.action.suspendre"].waitForExistence(timeout: 15), "la demande est approuvée : on peut maintenant suspendre")290        back()291292        // refuser l'autre : le motif est obligatoire293        let rowR = text(containing: refuseEmail)294        XCTAssertTrue(rowR.waitForExistence(timeout: 20))295        XCTAssertFalse(text(containing: approveEmail).exists, "la demande approuvée a quitté la liste « En attente »")296        rowR.tap()297        let verdictR = element("broker.phone.verdict")298        reveal(verdictR)299        if !published.isEmpty { XCTAssertTrue(verdictR.label.contains("Aucun numéro déclaré"), "sans téléphone déclaré, le verdict le dit : \(verdictR.label)") }300        let refuse = app.buttons["broker.action.refuser"]301        reveal(refuse)302        refuse.tap()303        let confirmRefuse = app.buttons["decision.confirm"]304        XCTAssertTrue(confirmRefuse.waitForExistence(timeout: 8))305        XCTAssertFalse(confirmRefuse.isEnabled, "pas de refus sans motif")306        XCTAssertFalse(element("permit.reminder").exists, "le rappel du permis ne concerne que l'approbation")307        let field = app.textViews["decision.reason"].exists ? app.textViews["decision.reason"] : app.textFields["decision.reason"]308        field.tap()309        field.typeText("Essai \(tag) : permis introuvable au registre.")310        snap("05-refuser-avec-motif")311        XCTAssertTrue(confirmRefuse.isEnabled)312        confirmRefuse.tap()313        XCTAssertTrue(text(containing: "Demande refusée").waitForExistence(timeout: 20))314        app.swipeDown(); app.swipeDown()   // retour en haut de la demande315        XCTAssertTrue(text(containing: "permis introuvable au registre").waitForExistence(timeout: 15), "le motif transmis est affiché sur la demande")316        snap("06-demande-refusee")317        back()318319        // rattacher une demande hors annuaire : pas d'approbation avant, recherche dans l'annuaire, confirmation320        let rowH = text(containing: outsideEmail)321        XCTAssertTrue(rowH.waitForExistence(timeout: 20))322        XCTAssertTrue(rowH.label.contains("Hors annuaire"), "la liste signale la demande hors annuaire")323        rowH.tap()324        let verdictH = element("broker.phone.verdict")325        reveal(verdictH)326        XCTAssertTrue(verdictH.label.contains("hors annuaire"), "verdict écrit : \(verdictH.label)")327        let attach = app.buttons["broker.attach"]328        reveal(attach)329        XCTAssertTrue(element("broker.unattached").exists)330        snap("06b-hors-annuaire")331        let approveH = app.buttons["broker.action.approuver"]332        reveal(approveH)333        XCTAssertFalse(approveH.isEnabled, "pas d'approbation sans rattachement")334        if !attach.isHittable { app.swipeDown(velocity: .slow) }335        attach.tap()336        let candidate = app.buttons.matching(identifier: "directory.row").matching(NSPredicate(format: "label CONTAINS %@", dir[1].name)).firstMatch337        XCTAssertTrue(candidate.waitForExistence(timeout: 20), "la recherche, amorcée par le nom déclaré, propose le courtier de l'annuaire")338        XCTAssertTrue(candidate.label.contains("propriété"), "chaque courtier proposé montre son agence et ses propriétés")339        snap("06c-rattacher")340        candidate.tap()341        XCTAssertTrue(app.alerts.firstMatch.waitForExistence(timeout: 8))342        snap("06d-rattacher-confirmation")343        confirm("Rattacher")344        XCTAssertTrue(text(containing: "Demande rattachée à").waitForExistence(timeout: 20))345        app.swipeDown(); app.swipeDown()346        let ficheH = app.buttons["broker.fiche"]347        reveal(ficheH)348        XCTAssertTrue(ficheH.exists && !element("broker.unattached").exists, "la demande est rattachée à l'annuaire")349        reveal(approveH)350        XCTAssertTrue(approveH.isEnabled, "une fois rattachée, la demande peut être approuvée")351        snap("06e-demande-rattachee")352        back()353354        // signalement : motif, messages en texte brut, classer355        tab("Signalements")356        let reportRow = text(containing: reason)357        XCTAssertTrue(reportRow.waitForExistence(timeout: 25), "le signalement d'essai est dans la liste des signalements ouverts")358        snap("07-signalements")359        reportRow.tap()360        XCTAssertTrue(text(containing: "Message d'essai \(tag) <b>balise</b>").waitForExistence(timeout: 15), "le message signalé s'affiche tel quel, balises comprises")361        XCTAssertTrue(text(containing: "l'acheteur").exists)362        snap("08-signalement")363        let dismissReport = app.buttons["report.dismiss"]364        reveal(dismissReport)365        dismissReport.tap()366        confirm("Classer")367        XCTAssertTrue(text(containing: "Signalement classé").waitForExistence(timeout: 20))368        XCTAssertFalse(text(containing: reason).waitForExistence(timeout: 4), "le signalement classé a quitté la liste des ouverts")369370        // courrier : lire un message ; s'il était non lu, il est remis non lu371        tab("Courrier")372        let row = element("mail.row")373        if !row.waitForExistence(timeout: 15) {374            // la première boîte est vide : on passe à l'autre375            element("mail.box").tap()376            let other = app.buttons["support@immo-ka.com"]377            XCTAssertTrue(other.waitForExistence(timeout: 8), "le choix de la boîte s'ouvre")378            other.tap()379        }380        XCTAssertTrue(row.waitForExistence(timeout: 30), "la boîte de réception se charge")381        let wasUnread = row.label.hasPrefix("Non lu.")382        snap("09-courrier")383        row.tap()384        XCTAssertTrue(app.descendants(matching: .any).matching(identifier: "mail.subject").firstMatch.waitForExistence(timeout: 20), "le message s'ouvre")385        XCTAssertTrue(app.buttons["mail.reply"].waitForExistence(timeout: 5))386        sleep(2)387        snap("10-message")388        if wasUnread {389            app.buttons["mail.unread"].tap()390            XCTAssertTrue(text(containing: "Marqué comme non lu").waitForExistence(timeout: 15), "le message ouvert est remis non lu")391        }392        app.buttons["mail.reply"].tap()393        XCTAssertTrue(app.buttons["compose.send"].waitForExistence(timeout: 8))394        let subject = app.textFields["compose.subject"]395        XCTAssertTrue((subject.value as? String ?? "").hasPrefix("Re:") || (subject.value as? String ?? "").lowercased().hasPrefix("re"), "la réponse reprend le sujet avec « Re: »")396        snap("11-reponse")397        app.buttons["compose.cancel"].tap()398        back()399400        // journal : les décisions y sont consignées. Sur iPad en portrait, l'écran du courrier (deux boutons à401        // droite) replie le dernier onglet derrière un chevron : on repasse par l'accueil, où les cinq tiennent.402        tab("Accueil")403        tab("Compte")404        let journal = app.buttons["account.journal"]405        reveal(journal)406        snap("12-compte")407        journal.tap()408        XCTAssertTrue(text(containing: "Demande approuvée").waitForExistence(timeout: 20), "l'approbation est au journal")409        XCTAssertTrue(text(containing: "Demande refusée").exists && text(containing: "Rattachement modifié").exists && text(containing: "Signalement classé").exists)410        snap("13-journal")411        back()412413        // déconnexion : retour à l'écran de connexion414        let out = app.buttons["account.signOut"]415        reveal(out)416        out.tap()417        confirm("Se déconnecter")418        XCTAssertTrue(app.buttons["login.passkey"].waitForExistence(timeout: 20), "déconnecté : écran de connexion par clé d'accès")419        XCTAssertFalse(app.descendants(matching: .any).matching(identifier: "dashboard").firstMatch.exists)420        snap("14-connexion")421    }422423    /// Courtiers : tous les états, changement de rattachement (recherche), fiche personnalisée, registre de l'OACIQ.424    func testBrokersDirectoryFicheAndRegistry() throws {425        let args = try signedInArguments()426        let tag = "\(Int(Date().timeIntervalSince1970) % 1_000_000)"427        let dir = try directory()428        let email = try pendingRequest(tag + "f", name: "Flavie Fiche \(tag)", brokerID: dir[0].id, phone: "418 555-0199")429        app.launchArguments += args + ["-IKTab", "brokers", "-IKBrokers", "toutes"]430        app.launch()431        let row = text(containing: email)432        XCTAssertTrue(row.waitForExistence(timeout: 30), "la liste de toutes les demandes se charge")433        snap("20-toutes-les-demandes")434        row.tap()435        let verdict = element("broker.phone.verdict")436        reveal(verdict)437        XCTAssertTrue(verdict.label.contains("différents") || verdict.label.contains("ne publie aucun numéro"), "un numéro déclaré qui n'est pas le numéro publié : \(verdict.label)")438        XCTAssertTrue(element("broker.phone.declared").label.contains("418 555-0199"))439        snap("20b-telephones-differents")440        let fiche = app.buttons["broker.fiche"]441        reveal(fiche)442        XCTAssertTrue(fiche.exists)443        let attach = app.buttons["broker.attach"]444        reveal(attach)445        attach.tap()446        XCTAssertTrue(element("directory.row").waitForExistence(timeout: 20), "la recherche dans l'annuaire propose des courtiers")447        snap("21-rattacher")448        app.buttons["Annuler"].firstMatch.tap()449        reveal(fiche)450        fiche.tap()451        XCTAssertTrue(element("fiche.version").waitForExistence(timeout: 20), "la fiche personnalisée s'ouvre")452        sleep(1)453        snap("22-fiche")454        app.swipeUp()455        snap("23-fiche-contenu")456        back()457458        // le registre de l'OACIQ s'ouvre dans Safari, hors de l'app459        app.swipeDown(); app.swipeDown()460        let link = element("permit.oaciq")461        reveal(link)462        link.tap()463        let safari = XCUIApplication(bundleIdentifier: "com.apple.mobilesafari")464        XCTAssertTrue(safari.wait(for: .runningForeground, timeout: 20), "le lien du registre ouvre Safari")465        sleep(4)466        snap("24-registre-oaciq-safari")467        let address = safari.descendants(matching: .any).matching(NSPredicate(format: "identifier == 'TabBarItemTitle' OR identifier == 'URL'")).firstMatch468        if address.waitForExistence(timeout: 8) { XCTAssertTrue((address.value as? String ?? address.label).contains("oaciq"), "Safari est sur le site de l'OACIQ : \(address.value as? String ?? address.label)") }469        app.activate()470        XCTAssertTrue(element("permit.oaciq").waitForExistence(timeout: 15), "de retour dans l'app, la demande est toujours à l'écran")471    }472473    /// Sans session : écran de connexion, activation par adresse (validation locale, rien n'est envoyé).474    func testLoginAndActivationScreens() {475        app.launch()476        XCTAssertTrue(app.buttons["login.passkey"].waitForExistence(timeout: 20))477        XCTAssertTrue(app.staticTexts["Immo-Ka Admin"].exists)478        snap("30-connexion")479        app.buttons["login.activation"].tap()480        let submit = app.buttons["activation.submit"]481        XCTAssertTrue(submit.waitForExistence(timeout: 8))482        XCTAssertFalse(submit.isEnabled, "rien à créer sans adresse")483        let link = app.textViews["activation.link"].exists ? app.textViews["activation.link"] : app.textFields["activation.link"]484        link.tap()485        link.typeText("https://www.immo-ka.com/admin/activation")486        XCTAssertTrue(text(containing: "il y manque le jeton").waitForExistence(timeout: 5), "une adresse sans jeton est refusée avant tout envoi")487        XCTAssertFalse(submit.isEnabled)488        link.typeText("?jeton=essai-0123456789abcdef")489        XCTAssertTrue(submit.isEnabled, "une adresse complète permet de créer la clé")490        snap("31-activation")491    }492493    /// Verrouillage : le contenu est masqué par le voile ; « Se déconnecter » reste possible.494    func testLockVeil() throws {495        app.launchArguments += try signedInArguments() + ["-IKLock", "YES"]496        app.launch()497        XCTAssertTrue(app.buttons["lock.unlock"].waitForExistence(timeout: 30), "l'app verrouillée montre le voile")498        XCTAssertTrue(app.staticTexts["Administration verrouillée"].exists)499        XCTAssertFalse(app.descendants(matching: .any).matching(identifier: "dashboard.pending").firstMatch.isHittable, "le contenu n'est pas utilisable sous le voile")500        snap("40-verrouillage")501        app.buttons["lock.signOut"].tap()502        XCTAssertTrue(app.buttons["login.passkey"].waitForExistence(timeout: 20))503    }504}505
Files main
Menu

Theme