Repository Public
1// Author: Simon-Pierre Boucher — contact@spboucher.ai2// File: Tests/UITests/SPNotesUITests.swift3// Description: XCUITest journeys on the real application in local mode (no account, throw-away data): create a note with the keyboard, format it, find it, open the palette, trash it.4//5// These tests send real key events to the Mac: run them when nobody else is typing (Scripts/build.sh ui-test).6import XCTest78final class SPNotesUITests: XCTestCase {9 private var app: XCUIApplication!1011 override func setUp() {12 continueAfterFailure = false13 app = XCUIApplication()14 app.launchArguments = ["-SPNotesUITest", "-SPNotesInMemory", "-ApplePersistenceIgnoreState", "YES"]15 app.launch()16 }1718 func testWriteFormatSearchAndTrashANote() {19 app.typeKey("n", modifierFlags: .command)20 let title = app.textFields["title-field"]; XCTAssertTrue(title.waitForExistence(timeout: 5))21 title.typeText("Liste de courses\n")22 // the title's Return moves the focus to the native editor23 app.typeText("- pain\nlait\n\nPenser au ")24 app.typeKey("b", modifierFlags: .command); app.typeText("levain"); app.typeKey("b", modifierFlags: .command); app.typeText(".")25 let state = app.staticTexts["save-state"]26 XCTAssertTrue(state.waitForExistence(timeout: 5))27 let saved = NSPredicate(format: "label CONTAINS[c] 'Enregistrée'"); expectation(for: saved, evaluatedWith: state); waitForExpectations(timeout: 5)28 // global search in the list29 app.typeKey("f", modifierFlags: [.command, .option]); app.typeText("levain")30 XCTAssertTrue(app.staticTexts["Liste de courses"].waitForExistence(timeout: 3))31 app.typeKey(.escape, modifierFlags: [])32 // command palette33 app.typeKey("p", modifierFlags: [.command, .shift])34 XCTAssertTrue(app.textFields["palette-field"].waitForExistence(timeout: 3)); app.typeKey(.escape, modifierFlags: [])35 // trash36 app.typeKey(.delete, modifierFlags: .command)37 XCTAssertTrue(app.staticTexts["toast"].waitForExistence(timeout: 3) || app.staticTexts["Aucune note ici"].waitForExistence(timeout: 3))38 }3940 func testTheAccountSheetExplainsLocalModeAndOffersPasskeySignIn() {41 app.buttons["sync-status"].firstMatch.click()42 XCTAssertTrue(app.buttons["sign-in"].waitForExistence(timeout: 4))43 XCTAssertTrue(app.staticTexts["Synchroniser avec MacLustr"].exists)44 }45}46