SPB Git

Repository Public

NFTUITests.swift 25.7 KB 480 lines swift

1// =============================================================================2//                  SP BOUCHER | SOFTWARE & RESEARCH3//             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// PROJECT METADATA7// -----------------------------------------------------------------------------8// Project          : SP Wallet9// File             : UITests/NFTUITests.swift10// Description      : Interface tests of the NFT section. `testLive…` drive the11//                    real app against the THROWAWAY local stack (its wallet12//                    owns no NFT): the honest empty gallery, what each network13//                    really reads, a public NFT opened as a READ, the wallet's14//                    own receive addresses, an allow-list change approved by15//                    the software passkey, market actions shown as unavailable.16//                    `testFixture…` use the DEBUG fixture mode17//                    (SPWALLET_NFT_FIXTURES=1, banner « DONNÉES D’ESSAI ») to18//                    look at populated screens and walk the transfer flow to19//                    finality. No test ever touches production.20// Module           : UITests21// Repository       : https://git.spboucher.ai/sp-wallet-ios22// Created          : 2026-11-1823// Last Modified    : 2026-11-1824//25// =============================================================================26// AUTHOR & PROFESSIONAL AFFILIATION27// =============================================================================28//29// Author           : Simon-Pierre Boucher30// Position         : Professor of Finance31// Institution      : Université du Québec en Outaouais (UQO)32// Department       : Département des sciences administratives33// Organization     : SP Boucher34//35// Website          : https://spboucher.ai36// Git              : https://git.spboucher.ai37//38// =============================================================================39// OFFICIAL CONTACT DIRECTORY40// =============================================================================41//42// General          : info@spboucher.ai43// Professional     : contact@spboucher.ai44// Direct           : simon@spboucher.ai45// Research         : research@spboucher.ai46// Development      : dev@spboucher.ai47// Support          : support@spboucher.ai48// Security/Admin   : admin@spboucher.ai49// Notifications    : notifications@spboucher.ai50//51// Preferred Contact: support@spboucher.ai52//53// =============================================================================54// COPYRIGHT & INTELLECTUAL PROPERTY55// =============================================================================56//57// Copyright (c) 202658// Simon-Pierre Boucher59//60// All rights reserved where applicable.61//62// This file is governed by the applicable project license,63// copyright notices, institutional agreements and relevant law.64//65// Unless expressly authorized by the applicable license or66// rights holder, copying, redistribution, sublicensing,67// publication and commercial exploitation are not permitted.68//69// Existing third-party rights and notices remain unaffected.70//71// =============================================================================72// CONFIDENTIALITY & SECURITY73// =============================================================================74//75// Classification   : Public76// Distribution     : Public repository; use is governed by the project license77// Security Contact : admin@spboucher.ai78//79// Access to this source does not independently grant permission80// to redistribute or disclose confidential materials.81//82// Do not embed credentials, private keys, access tokens,83// certificates or confidential personal information.84//85// =============================================================================86// LICENSE & MAINTENANCE87// =============================================================================88//89// License          : None specified (no license file in this repository)90// Maintainer       : Simon-Pierre Boucher91// Technical Contact: dev@spboucher.ai92//93// =============================================================================94// END OF SP BOUCHER SOURCE HEADER95// =============================================================================9697import XCTest9899final class NFTUITests: XCTestCase {100    override func setUpWithError() throws {101        continueAfterFailure = false102        try XCTSkipUnless(Stack.isUp, "throwaway stack not running (../SPWalletCore/Scripts/dev-stack.sh up-fork)")103    }104    override func tearDown() { XCUIDevice.shared.appearance = .light }105106    // MARK: helpers107108    private func el(_ app: XCUIApplication, _ id: String) -> XCUIElement { app.descendants(matching: .any)[id].firstMatch }109110    private func openNFTs(_ app: XCUIApplication) {111        if isPad { go(app, "nfts") } else {112            go(app, "explore")113            let link = el(app, "explore.nfts")114            XCTAssertTrue(link.waitForExistence(timeout: 8), "the NFT entry of Explore")115            link.tap()116        }117        XCTAssertTrue(app.navigationBars["NFT"].waitForExistence(timeout: 10))118    }119120    private func fixtureApp() -> XCUIApplication {121        let app = Stack.app()122        app.launchEnvironment["SPWALLET_NFT_FIXTURES"] = "1"123        return app124    }125126    /** Swipe up until the element is on screen (LazyVStack content exists only near the viewport). */127    @discardableResult private func reach(_ app: XCUIApplication, _ e: XCUIElement, swipes: Int = 14, file: StaticString = #filePath, line: UInt = #line) -> XCUIElement {128        var n = 0129        while !(e.exists && e.isHittable), n < swipes { app.swipeUp(velocity: .slow); n += 1 }130        XCTAssertTrue(e.exists, "element \(e) not found after scrolling", file: file, line: line)131        return e132    }133134    private func menu(_ app: XCUIApplication, _ item: String) {135        let m = app.buttons["nft.menu"]136        XCTAssertTrue(m.waitForExistence(timeout: 8)); m.tap()137        let b = app.buttons[item]138        XCTAssertTrue(b.waitForExistence(timeout: 5), "menu item \(item)"); b.tap()139    }140141    private func field(_ app: XCUIApplication, _ id: String) -> XCUIElement {142        let v = app.textViews[id]143        return v.exists ? v : app.textFields[id]144    }145146    private func waitLabel(_ e: XCUIElement, contains text: String, timeout: TimeInterval) -> Bool {147        let deadline = Date().addingTimeInterval(timeout)148        while Date() < deadline { if e.exists, e.label.contains(text) { return true }; usleep(300_000) }149        return false150    }151152    private func back(_ app: XCUIApplication) { app.navigationBars.buttons.element(boundBy: 0).tap() }153154    // MARK: live stack (the throwaway wallet owns no NFT)155156    func testLiveEmptyGalleryIsHonestAndNetworksSayWhatIsRead() {157        let app = signIn(Stack.app())158        openNFTs(app)159        XCTAssertFalse(el(app, "nft.banner.fixture").exists, "no test data outside the fixture mode")160        // no card, and an empty state that does not claim the wallet owns nothing on unread networks161        let networks = app.buttons["nft.networks"]162        XCTAssertTrue(networks.waitForExistence(timeout: 30), "the capability matrix was served")163        XCTAssertFalse(app.buttons["nft.card"].exists)164        shot("nft-live-01-gallery-empty")165        reach(app, networks).tap()166        XCTAssertTrue(app.navigationBars["Réseaux : ce qui est lu"].waitForExistence(timeout: 5))167        XCTAssertTrue(el(app, "nft.network.ethereum").waitForExistence(timeout: 5) || el(app, "nft.network.solana").exists || el(app, "nft.network.base").exists)168        shot("nft-live-02-networks")169        app.swipeUp(); shot("nft-live-03-networks-2")170    }171172    func testLiveAPublicNFTIsOpenedAsAReadOrRefusedWithItsReason() {173        let app = signIn(Stack.app())174        openNFTs(app)175        XCTAssertTrue(app.buttons["nft.networks"].waitForExistence(timeout: 30))176        menu(app, "Ouvrir ou suivre un NFT")177        let chain = el(app, "nft.lookup.chain")178        XCTAssertTrue(chain.waitForExistence(timeout: 8))179        chain.tap()180        let eth = app.buttons["Ethereum"]181        XCTAssertTrue(eth.waitForExistence(timeout: 5)); eth.tap()182        let address = field(app, "nft.lookup.address")183        XCTAssertTrue(address.waitForExistence(timeout: 5))184        // an invalid identifier is refused before any request185        address.tap(); address.typeText("https://opensea.io/x")186        XCTAssertTrue(el(app, "nft.lookup.problem").waitForExistence(timeout: 3))187        XCTAssertFalse(app.buttons["nft.lookup.open"].isEnabled)188        address.typeText(String(repeating: XCUIKeyboardKey.delete.rawValue, count: 24))189        address.typeText("0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D")190        let token = app.textFields["nft.lookup.tokenId"]191        token.tap(); token.typeText("8520")192        shot("nft-live-04-lookup-form")193        let open = app.buttons["nft.lookup.open"]194        reach(app, open); XCTAssertTrue(open.isEnabled); open.tap()195        // a READ of public chain data: either the item page as the chain says it, or the server's refusal with its code — never a made-up page196        let identity = el(app, "nft.item.identity"), refusal = el(app, "nft.lookup.error")197        let deadline = Date().addingTimeInterval(60)198        while Date() < deadline, !identity.exists, !refusal.exists { usleep(400_000) }199        XCTAssertTrue(identity.exists || refusal.exists, "an item page or an explained refusal")200        shot("nft-live-05-lookup-result")201        if identity.exists {202            XCTAssertTrue(el(app, "nft.item.blocked").exists || el(app, "nft.item.transferable").exists, "the verdict is shown as served")203            XCTAssertFalse(app.buttons["nft.item.send"].exists && app.buttons["nft.item.send"].isEnabled && el(app, "nft.item.blocked").exists)204            app.swipeUp(); shot("nft-live-06-lookup-item-2")205            app.swipeUp(); shot("nft-live-07-lookup-item-3")206        }207    }208209    func testLiveReceiveAddressesAreTheSignersOwn() {210        let app = signIn(Stack.app())211        openNFTs(app)212        XCTAssertTrue(app.buttons["nft.networks"].waitForExistence(timeout: 30))213        menu(app, "Adresses de réception")214        let address = app.staticTexts.matching(identifier: "nft.receive.address").firstMatch215        XCTAssertTrue(address.waitForExistence(timeout: 15))216        if let fork = try? String(contentsOfFile: Stack.dir + "/fork-address", encoding: .utf8) {217            let mine = fork.trimmingCharacters(in: .whitespacesAndNewlines)218            let all = app.staticTexts.matching(identifier: "nft.receive.address").allElementsBoundByIndex.map { $0.label }219            XCTAssertTrue(all.contains(mine) || all.allSatisfy { !$0.hasPrefix("0x") }, "an EVM receive address is the one the signer derived: \(all)")220        }221        shot("nft-live-08-receive")222    }223224    func testLiveAllowListChangeIsReviewedInFullAndApprovedByThePasskey() throws {225        let app = signIn(Stack.app())226        openNFTs(app)227        XCTAssertTrue(app.buttons["nft.networks"].waitForExistence(timeout: 30))228        menu(app, "Protections")229        let mode = el(app, "nft.allow.mode")230        XCTAssertTrue(mode.waitForExistence(timeout: 20), "the signer's allow-list was read")231        shot("nft-live-09-protections")232        let to = "0x" + (0..<20).map { _ in String(format: "%02x", UInt8.random(in: 0...255)) }.joined()233        let address = field(app, "nft.allow.address")234        reach(app, address); address.tap(); address.typeText(to)235        let prepare = app.buttons["nft.allow.prepare"]236        reach(app, prepare)237        try XCTSkipUnless(prepare.isEnabled, "this signer does not support the NFT allow-list")238        prepare.tap()239        let object = el(app, "nft.protection.object")240        XCTAssertTrue(object.waitForExistence(timeout: 20), "the server prepared the change and the app verified its challenge")241        XCTAssertTrue(app.staticTexts.containing(NSPredicate(format: "label CONTAINS[c] %@", to)).firstMatch.exists, "the full address is on the review")242        XCTAssertTrue(el(app, "nft.protection.digest").exists)243        shot("nft-live-10-allow-review")244        let approve = app.buttons["nft.protection.approve"]245        reach(app, approve).tap()246        XCTAssertTrue(el(app, "nft.protections.result").waitForExistence(timeout: 30), "the signer accepted the passkey-approved change")247        XCTAssertTrue(app.staticTexts.containing(NSPredicate(format: "label CONTAINS[c] %@", to)).firstMatch.waitForExistence(timeout: 10), "the list read back from the signer holds the address")248        shot("nft-live-11-allow-added")249    }250251    func testLiveMarketActionsAreListedAsUnavailable() {252        let app = signIn(Stack.app())253        openNFTs(app)254        XCTAssertTrue(app.buttons["nft.networks"].waitForExistence(timeout: 30))255        menu(app, "Marché : sources et estimation")256        XCTAssertTrue(app.navigationBars["Marché NFT"].waitForExistence(timeout: 5))257        let toggle = app.buttons["nft.estimate.toggle"]258        XCTAssertTrue(toggle.waitForExistence(timeout: 20) || el(app, "nft.market.action").exists || el(app, "nft.market.actions.unavailable").exists)259        XCTAssertFalse(app.buttons["Acheter"].exists || app.buttons["Vendre"].exists || app.buttons["Faire une offre"].exists, "no market action is a button")260        shot("nft-live-12-market")261        app.swipeUp(); shot("nft-live-13-market-2")262    }263264    // MARK: fixture mode (populated screens, visibly labelled test data)265266    func testFixtureGalleryAndItemPages() {267        let app = signIn(fixtureApp())268        openNFTs(app)269        XCTAssertTrue(el(app, "nft.banner.fixture").waitForExistence(timeout: 15), "the test-data banner is visible")270        let cards = app.buttons.matching(identifier: "nft.card")271        XCTAssertTrue(cards.firstMatch.waitForExistence(timeout: 15))272        sleep(3) // thumbnails273        shot("nft-fx-01-gallery")274        app.swipeUp(); sleep(1); shot("nft-fx-02-gallery-2")275        app.swipeDown(); app.swipeDown()276        // spam stays hidden until asked for, and is then labelled with the indexer's name277        let spam = app.buttons["nft.spam.toggle"]278        reach(app, spam).tap()279        sleep(1); app.swipeUp(); shot("nft-fx-03-gallery-spam")280        app.swipeDown(); app.swipeDown()281282        // the item page: untrusted text stays text, a javascript: link is not a link283        let ape = cards.containing(NSPredicate(format: "label CONTAINS %@", "Ape #8520")).firstMatch284        reach(app, ape).tap()285        XCTAssertTrue(el(app, "nft.item.name").waitForExistence(timeout: 10))286        XCTAssertTrue(el(app, "nft.banner.fixture").exists)287        sleep(2); shot("nft-fx-04-item-top")288        XCTAssertTrue(reach(app, el(app, "nft.item.transferable")).exists)289        shot("nft-fx-05-item-verdict")290        let identity = reach(app, el(app, "nft.item.identity"))291        XCTAssertTrue(identity.staticTexts.containing(NSPredicate(format: "label CONTAINS %@", "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D")).firstMatch.exists292                      || app.staticTexts.containing(NSPredicate(format: "label CONTAINS %@", "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D")).firstMatch.exists, "the contract is shown in full")293        shot("nft-fx-06-item-identity")294        let description = reach(app, el(app, "nft.item.description"))295        XCTAssertTrue(description.label.contains("<script>alert(1)</script>"), "markup in the creator's text is shown as text: \(description.label)")296        XCTAssertTrue(reach(app, el(app, "nft.link.refused")).exists, "a javascript: URL is never offered as a link")297        shot("nft-fx-07-item-description")298        reach(app, el(app, "nft.market.readonly")); shot("nft-fx-08-item-market")299        // the per-source listings / offers / market events screen (a pushed destination)300        reach(app, el(app, "nft.market.detail")).tap()301        XCTAssertTrue(app.navigationBars["Marché de la pièce"].waitForExistence(timeout: 8))302        sleep(1); shot("nft-fx-08b-market-detail")303        back(app)304        reach(app, el(app, "nft.market.readonly"))305        app.swipeUp(); shot("nft-fx-09-item-market-2")306        app.swipeUp(); shot("nft-fx-10-item-market-3")307        XCTAssertFalse(app.buttons["Acheter"].exists || app.buttons["Vendre"].exists)308        app.swipeUp(); shot("nft-fx-11-item-activity")309        app.swipeUp(); shot("nft-fx-12-item-details")310        app.swipeUp(); app.swipeUp(); shot("nft-fx-13-item-end")311        back(app)312313        // active content is never rendered; a blocked asset says exactly why and offers no send314        for _ in 0..<3 { app.swipeDown() }315        let svg = cards.containing(NSPredicate(format: "label CONTAINS %@", "Glyphe")).firstMatch316        reach(app, svg).tap()317        XCTAssertTrue(el(app, "nft.item.name").waitForExistence(timeout: 10))318        sleep(2); shot("nft-fx-14-item-svg")319        XCTAssertTrue(app.descendants(matching: .any).matching(NSPredicate(format: "label CONTAINS %@", "Contenu actif non affiché")).firstMatch.exists)320        XCTAssertEqual(app.webViews.count, 0, "there is no web view in this app")321        back(app)322        for _ in 0..<3 { app.swipeDown() }323        let lad = cards.containing(NSPredicate(format: "label CONTAINS %@", "Lad")).firstMatch324        reach(app, lad).tap()325        XCTAssertTrue(reach(app, el(app, "nft.item.blocked")).exists)326        XCTAssertTrue(el(app, "nft.item.blockReason").label.contains("VERROUILLÉ"))327        XCTAssertFalse(app.buttons["nft.item.send"].exists)328        shot("nft-fx-15-item-blocked")329    }330331    func testFixtureTransferOfAnERC1155FromTheFormToFinality() {332        let app = signIn(fixtureApp())333        openNFTs(app)334        let cards = app.buttons.matching(identifier: "nft.card")335        let pass = cards.containing(NSPredicate(format: "label CONTAINS %@", "Pass saison 2")).firstMatch336        XCTAssertTrue(pass.waitForExistence(timeout: 15))337        XCTAssertTrue(pass.label.contains("12"), "the quantity held is on the card: \(pass.label)")338        reach(app, pass).tap()339        XCTAssertTrue(el(app, "nft.item.name").waitForExistence(timeout: 10))340        sleep(2); shot("nft-fx-20-pass-top")341        let send = app.buttons["nft.item.send"]342        reach(app, send); XCTAssertTrue(send.isEnabled); send.tap()343344        XCTAssertTrue(el(app, "nft.send.identity").waitForExistence(timeout: 8))345        let prepare = app.buttons["nft.send.prepare"]346        let to = field(app, "nft.send.to")347        reach(app, to)348        // the two sheets of the form open with the app's environment: address book, QR scanner349        app.buttons["Carnet"].tap()350        XCTAssertTrue(app.navigationBars["Carnet d’adresses"].waitForExistence(timeout: 8))351        app.navigationBars["Carnet d’adresses"].buttons["Fermer"].tap()352        app.buttons["nft.send.scan"].tap()353        XCTAssertTrue(app.navigationBars["Lire un code QR"].waitForExistence(timeout: 8))354        let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")355        for label in ["Ne pas autoriser", "Don’t Allow", "Refuser"] where springboard.buttons[label].waitForExistence(timeout: 2) { springboard.buttons[label].tap(); break }356        app.navigationBars["Lire un code QR"].buttons["Fermer"].tap()357        XCTAssertTrue(to.waitForExistence(timeout: 5))358        to.tap()359        // a wrong checksum is flagged at once, before any preparation360        to.typeText("0x5AAeb6053F3E94C9b9A09f33669435E7Ef1BeAeD")361        XCTAssertTrue(el(app, "nft.send.addressError").waitForExistence(timeout: 5))362        to.typeText(String(repeating: XCUIKeyboardKey.delete.rawValue, count: 44))363        let dest = "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC"364        to.typeText(dest)365        let qty = app.textFields["nft.send.quantity"]366        reach(app, qty); qty.tap()367        qty.typeText(XCUIKeyboardKey.delete.rawValue + "13")368        XCTAssertTrue(el(app, "nft.send.quantityProblem").waitForExistence(timeout: 5), "more than held is refused in the form")369        qty.typeText(XCUIKeyboardKey.delete.rawValue + XCUIKeyboardKey.delete.rawValue + "5")370        if app.buttons["nft.send.keyboardDone"].exists { app.buttons["nft.send.keyboardDone"].tap() }371        shot("nft-fx-21-send-form")372        reach(app, prepare); XCTAssertTrue(prepare.isEnabled); prepare.tap()373374        // the review: the verified intent, every identifier in full375        let reviewTo = el(app, "nft.review.to")376        XCTAssertTrue(reviewTo.waitForExistence(timeout: 20), "the transfer was prepared and its challenge verified")377        XCTAssertTrue(reviewTo.label.contains(dest), "full destination: \(reviewTo.label)")378        XCTAssertTrue(el(app, "nft.review.asset").label.contains("0x495f947276749Ce646f68AC8c248420045cb7b5e"))379        XCTAssertTrue(el(app, "nft.review.tokenId").label.contains("42"))380        XCTAssertTrue(el(app, "nft.review.quantity").label.contains("5"))381        shot("nft-fx-22-review-1")382        app.swipeUp(velocity: .slow); shot("nft-fx-23-review-2")383        app.swipeUp(velocity: .slow); shot("nft-fx-24-review-3")384        app.swipeUp(velocity: .slow); shot("nft-fx-25-review-4")385        let approve = app.buttons["nft.send.approve"]386        reach(app, approve)387        XCTAssertFalse(approve.isEnabled, "no approval before the destination was confirmed")388        let ack = app.switches["nft.review.ack"]389        reach(app, ack); ack.switches.firstMatch.exists ? ack.switches.firstMatch.tap() : ack.tap()390        reach(app, approve)391        shot("nft-fx-26-review-ready")392        XCTAssertTrue(approve.isEnabled); approve.tap()393394        let state = el(app, "nft.tracker.state")395        XCTAssertTrue(state.waitForExistence(timeout: 30), "after the passkey the app follows the proposal")396        shot("nft-fx-27-tracking")397        XCTAssertTrue(waitLabel(state, contains: "Confirmée", timeout: 30), "the proposal reaches the chain's finality: \(state.label)")398        shot("nft-fx-28-finalized")399        reach(app, app.buttons["nft.send.done"]).tap()400        // the gallery shows what the server's inventory says now: 7 left401        back(app)402        for _ in 0..<3 { app.swipeDown() }403        let after = cards.containing(NSPredicate(format: "label CONTAINS %@", "Pass saison 2")).firstMatch404        XCTAssertTrue(after.waitForExistence(timeout: 10))405        XCTAssertTrue(waitLabel(after, contains: "× 7", timeout: 15), "the card shows the server's remaining quantity: \(after.label)")406        shot("nft-fx-29-gallery-after")407    }408409    func testFixtureProtectionsNetworksReceiveAndMarket() {410        let app = signIn(fixtureApp())411        openNFTs(app)412        XCTAssertTrue(app.buttons.matching(identifier: "nft.card").firstMatch.waitForExistence(timeout: 15))413        menu(app, "Protections")414        XCTAssertTrue(el(app, "nft.allow.mode").waitForExistence(timeout: 10))415        shot("nft-fx-30-allow")416        app.swipeUp(); shot("nft-fx-31-allow-2")417        app.swipeDown(); app.swipeDown()418        app.buttons["Sorties Bitcoin"].tap()419        XCTAssertTrue(el(app, "nft.utxo.mode").waitForExistence(timeout: 10))420        shot("nft-fx-32-utxo")421        let unlock = app.buttons["nft.utxo.unlock"]422        reach(app, unlock); shot("nft-fx-33-utxo-rows")423        unlock.tap()424        XCTAssertTrue(el(app, "nft.protection.object").waitForExistence(timeout: 10))425        XCTAssertTrue(app.staticTexts.containing(NSPredicate(format: "label CONTAINS %@", "abababababababababababababababababababababababababababababababab:0")).firstMatch.exists, "the outpoint is on the review, in full")426        shot("nft-fx-34-utxo-review")427        reach(app, app.buttons["nft.protection.approve"]).tap()428        XCTAssertTrue(el(app, "nft.protections.result").waitForExistence(timeout: 20))429        shot("nft-fx-35-utxo-result")430        back(app)431432        menu(app, "Réseaux : ce qui est lu")433        XCTAssertTrue(el(app, "nft.network.ethereum").waitForExistence(timeout: 5))434        shot("nft-fx-36-networks"); app.swipeUp(); shot("nft-fx-37-networks-2")435        back(app)436        menu(app, "Adresses de réception")437        XCTAssertTrue(app.staticTexts.matching(identifier: "nft.receive.address").firstMatch.waitForExistence(timeout: 10))438        shot("nft-fx-38-receive")439        app.buttons["Code QR"].firstMatch.tap()440        XCTAssertTrue(app.buttons["Fermer"].waitForExistence(timeout: 5), "the QR sheet opened")441        shot("nft-fx-38b-receive-qr")442        app.buttons["Fermer"].tap()443        app.swipeUp(); app.swipeUp(); shot("nft-fx-39-receive-2")444        back(app)445        // lookup of a known contract, then the pushed item page446        menu(app, "Ouvrir ou suivre un NFT")447        let address = field(app, "nft.lookup.address")448        XCTAssertTrue(address.waitForExistence(timeout: 8))449        address.tap(); address.typeText("0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D")450        let token = app.textFields["nft.lookup.tokenId"]451        token.tap(); token.typeText("8520")452        shot("nft-fx-39b-lookup")453        reach(app, app.buttons["nft.lookup.open"]).tap()454        XCTAssertTrue(el(app, "nft.item.name").waitForExistence(timeout: 10), "the looked-up asset opens as a pushed page")455        back(app); back(app)456        menu(app, "Marché : sources et estimation")457        let toggle = app.buttons["nft.estimate.toggle"]458        XCTAssertTrue(toggle.waitForExistence(timeout: 10))459        shot("nft-fx-40-market")460        XCTAssertFalse(el(app, "nft.estimate.sum").exists, "the estimate is off until the owner turns it on")461        reach(app, toggle).tap()462        XCTAssertTrue(reach(app, el(app, "nft.estimate.sum")).exists)463        shot("nft-fx-41-estimate")464    }465466    func testFixtureDarkMode() {467        XCUIDevice.shared.appearance = .dark468        let app = signIn(fixtureApp())469        openNFTs(app)470        let cards = app.buttons.matching(identifier: "nft.card")471        XCTAssertTrue(cards.firstMatch.waitForExistence(timeout: 15))472        sleep(2); shot("nft-fx-50-dark-gallery")473        cards.containing(NSPredicate(format: "label CONTAINS %@", "Ape #8520")).firstMatch.tap()474        XCTAssertTrue(el(app, "nft.item.name").waitForExistence(timeout: 10))475        sleep(2); shot("nft-fx-51-dark-item")476        app.swipeUp(); shot("nft-fx-52-dark-item-2")477        app.swipeUp(); app.swipeUp(); shot("nft-fx-53-dark-item-3")478    }479}480
Files main
Menu

Theme