Cotton code
38 lines · 1.8 KB · SwiftRaw
// Dictation says why before the phone is asked (store pass, 24 Nov 2026; voice lines control.*): with the// microphone not yet asked, Speak it opens a card saying what the microphone is for, with Continue and Not now; Not// now closes it and asks the phone nothing.import XCTestfinal class DaysVoiceAskTests: XCTestCase {    override func setUp() {        continueAfterFailure = false        XCUIDevice.shared.orientation = .portrait    }    @MainActor func testSpeakItSaysWhyFirstAndNotNowAsksNothing() {        let app = DaysUI.launch()        // The microphone as on a fresh install: not yet asked.        app.resetAuthorizationStatus(for: .microphone)        app.launch()        DaysUI.days(app)        DaysUI.button(app, "Add").tap()        let mic = app.buttons["Speak it"]        XCTAssertTrue(mic.waitForExistence(timeout: 10), "Speak it stands in the adding bar")        mic.tap()        let go = app.buttons["voice-ask-go"], notNow = app.buttons["voice-ask-not-now"]        XCTAssertTrue(go.waitForExistence(timeout: 10), "the card says why, with Continue")        XCTAssertEqual(go.label, "Continue")        XCTAssertEqual(notNow.label, "Not now")        let why = app.staticTexts.matching(NSPredicate(format: "label CONTAINS %@", "only while you dictate")).firstMatch        XCTAssertTrue(why.exists, "what the microphone is for")        let shot = XCTAttachment(screenshot: XCUIScreen.main.screenshot())        shot.name = "voice-ask-why"        shot.lifetime = .keepAlways        add(shot)        notNow.tap()        XCTAssertTrue(go.waitForNonExistence(timeout: 5), "Not now closes it")        let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")        XCTAssertFalse(springboard.alerts.firstMatch.waitForExistence(timeout: 2), "and the phone was asked nothing")    }}