Repository Public
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// Project : SP ID & Card Vault7// File : SPVaultUITests/WalletUITests.swift8// Module : Tests9// Repository : https://git.spboucher.ai/sp-id-card-vault10// Project Website : Not specified11// Created : 2026-12-0212// Last Modified : 2026-12-0213//14// Author : Simon-Pierre Boucher15// Position : Professor of Finance16// Institution : Université du Québec en Outaouais (UQO)17// Organization : SP Boucher18// Website : https://spboucher.ai19// Git : https://git.spboucher.ai20//21// Preferred Contact: contact@spboucher.ai22// Development : dev@spboucher.ai23// Support : support@spboucher.ai24// Security/Admin : admin@spboucher.ai25//26// Copyright (c) 202627// Simon-Pierre Boucher28// All rights reserved where applicable. This file is governed by the29// applicable project license, copyright notices and relevant law.30// Existing third-party rights and notices remain unaffected.31//32// License : None specified (no license file in this repository)33//34// Do not embed credentials, private keys, access tokens,35// certificates or confidential personal information.36//37// =============================================================================38// END OF SP BOUCHER SOURCE HEADER39// =============================================================================4041import XCTest4243/// End-to-end checks of the wallet on the fictitious demo vault44/// (`-uiTesting -seedDemo`: temporary vault, scripted Face ID, eight specimen cards).45@MainActor46final class WalletUITests: XCTestCase {47 override func setUp() {48 continueAfterFailure = false49 }5051 private func launch(_ extra: [String] = []) -> XCUIApplication {52 let app = XCUIApplication()53 app.launchArguments = ["-uiTesting", "-seedDemo"] + extra54 app.launch()55 return app56 }5758 private func openAurora(_ app: XCUIApplication) {59 let card = app.buttons["card.Aurora Infinite"]60 XCTAssertTrue(card.waitForExistence(timeout: 20))61 // In the stacked wallet only the top band of a card is uncovered.62 card.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.1)).tap()63 XCTAssertTrue(app.buttons["detail.close"].waitForExistence(timeout: 10))64 }6566 func testWalletShowsCardsAndFilters() {67 let app = launch()68 XCTAssertTrue(app.buttons["card.Aurora Infinite"].waitForExistence(timeout: 20))69 XCTAssertTrue(app.buttons["card.Driver's Licence"].exists)70 app.buttons["wallet.filter.favorites"].tap()71 XCTAssertTrue(app.buttons["card.Aurora Infinite"].waitForExistence(timeout: 5))72 XCTAssertFalse(app.buttons["card.Passport"].exists)73 app.buttons["wallet.filter.identity"].tap()74 XCTAssertTrue(app.buttons["card.Passport"].waitForExistence(timeout: 5))75 XCTAssertFalse(app.buttons["card.Aurora Infinite"].exists)76 }7778 func testEveryLayoutShowsTheCards() {79 for layout in ["stack", "carousel", "grid", "categories"] {80 let app = launch(["-layout", layout])81 XCTAssertTrue(app.buttons["card.Aurora Infinite"].waitForExistence(timeout: 20), layout)82 app.terminate()83 }84 }8586 func testNumberIsMaskedUntilFaceIDReveal() {87 let app = launch()88 openAurora(app)89 let number = app.staticTexts["detail.number"]90 XCTAssertTrue(number.waitForExistence(timeout: 5))91 XCTAssertEqual(number.label, "Hidden, ending in 4242")92 app.buttons["detail.reveal"].tap()93 let revealed = NSPredicate(format: "label == %@", "4242 4242 4242 4242")94 expectation(for: revealed, evaluatedWith: number)95 waitForExpectations(timeout: 5)96 app.buttons["detail.reveal"].tap() // Hide97 expectation(for: NSPredicate(format: "label == %@", "Hidden, ending in 4242"), evaluatedWith: number)98 waitForExpectations(timeout: 5)99 }100101 func testFlipFullScreenAndFavourite() {102 let app = launch()103 openAurora(app)104 app.buttons["detail.flip"].tap()105 app.buttons["detail.fullscreen"].tap()106 XCTAssertTrue(app.buttons["fullscreen.close"].waitForExistence(timeout: 5))107 XCTAssertTrue(app.buttons["fullscreen.flip"].exists)108 app.buttons["fullscreen.flip"].tap()109 app.buttons["fullscreen.close"].tap()110 let favourite = app.buttons["detail.favorite"]111 XCTAssertTrue(favourite.waitForExistence(timeout: 5))112 XCTAssertEqual(favourite.label, "Remove from favourites")113 favourite.tap()114 XCTAssertEqual(favourite.label, "Add to favourites")115 }116117 func testDeletingACardRemovesItFromTheWallet() {118 let app = launch()119 openAurora(app)120 app.buttons["detail.more"].tap()121 app.buttons["Delete card"].firstMatch.tap()122 let confirm = app.buttons["Delete card"].firstMatch123 XCTAssertTrue(confirm.waitForExistence(timeout: 5))124 confirm.tap()125 XCTAssertTrue(app.buttons["card.Driver's Licence"].waitForExistence(timeout: 10))126 XCTAssertFalse(app.buttons["card.Aurora Infinite"].exists)127 }128129 func testEditorRefusesASecurityCodeField() {130 let app = launch(["-screen", "editor"])131 let add = app.buttons["editor.addField"]132 XCTAssertTrue(add.waitForExistence(timeout: 20))133 while !add.isHittable { app.swipeUp() }134 add.tap()135 let label = app.textFields["Label"].firstMatch136 XCTAssertTrue(label.waitForExistence(timeout: 5))137 label.tap()138 label.typeText("CVV")139 XCTAssertTrue(app.staticTexts["editor.forbidden"].waitForExistence(timeout: 5))140 XCTAssertFalse(app.buttons["editor.save"].isEnabled)141 }142143 /// Leaving the app locks the vault: coming back shows the lock screen, and144 /// the wallet is not reachable until Face ID succeeds again.145 func testBackgroundingLocksTheVault() {146 let app = launch()147 XCTAssertTrue(app.buttons["card.Aurora Infinite"].waitForExistence(timeout: 20))148 XCUIDevice.shared.press(.home)149 sleep(1)150 app.activate()151 XCTAssertTrue(app.buttons["lock.unlock"].waitForExistence(timeout: 10) || app.buttons["card.Aurora Infinite"].waitForExistence(timeout: 10))152 // With the scripted protector the lock screen unlocks on its automatic153 // prompt; what matters is that the detail screen opened earlier is gone.154 XCTAssertFalse(app.buttons["detail.close"].exists)155 }156157 func testPrivacyModeHidesCardFacesInTheWallet() {158 let app = launch(["-privacyMode"])159 XCTAssertTrue(app.buttons["card.Aurora Infinite"].waitForExistence(timeout: 20))160 // The veil shows the last four characters only; the full number is never in the hierarchy.161 XCTAssertFalse(app.staticTexts["4242 4242 4242 4242"].exists)162 }163}164