From 5b5dfc78aae2cc22d134b59877093f137bf67d5f Mon Sep 17 00:00:00 2001 From: Vishnu Ravi Date: Mon, 1 Jul 2024 11:30:16 -0400 Subject: [PATCH] Fix UI tests on iPadOS --- Tests/UITests/TestApp/TestApp.swift | 4 ++-- .../TestAppUITests/TestAppUITests.swift | 19 ++++++++----------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/Tests/UITests/TestApp/TestApp.swift b/Tests/UITests/TestApp/TestApp.swift index 3bb97d5..87ce9f5 100644 --- a/Tests/UITests/TestApp/TestApp.swift +++ b/Tests/UITests/TestApp/TestApp.swift @@ -17,10 +17,10 @@ struct UITestsApp: App { var body: some Scene { WindowGroup { - NavigationView { + NavigationStack { MenuView() } - .spezi(appDelegate) + .spezi(appDelegate) } } } diff --git a/Tests/UITests/TestAppUITests/TestAppUITests.swift b/Tests/UITests/TestAppUITests/TestAppUITests.swift index bc331be..e69bc41 100644 --- a/Tests/UITests/TestAppUITests/TestAppUITests.swift +++ b/Tests/UITests/TestAppUITests/TestAppUITests.swift @@ -21,31 +21,28 @@ class TestAppUITests: XCTestCase { app.launch() XCTAssertTrue(app.staticTexts["Spezi Speech Tests"].waitForExistence(timeout: 1)) - - #if os(iOS) - try app.testSynthesisWithVoiceSelection() - #endif } -} - -extension XCUIApplication { + func testSynthesisWithVoiceSelection() throws { - let voiceSelectionTestViewButton = staticTexts["Speech Voice Selection Test View"] + let app = XCUIApplication() + app.launch() + + let voiceSelectionTestViewButton = app.staticTexts["Speech Voice Selection Test View"] XCTAssertTrue(voiceSelectionTestViewButton.waitForExistence(timeout: 1)) voiceSelectionTestViewButton.tap() - let picker = pickers["voicePicker"] + let picker = app.pickers["voicePicker"] let optionToSelect = picker.pickerWheels.element(boundBy: 0) optionToSelect.adjust(toPickerWheelValue: "Kathy") - let textField = textFields["Enter text to be spoken"] + let textField = app.textFields["Enter text to be spoken"] XCTAssertTrue(textField.waitForExistence(timeout: 1)) textField.tap() textField.typeText("Hello, this is a test of the Spezi Speech module.") - let speakButton = buttons["Speak"] + let speakButton = app.buttons["Speak"] XCTAssertTrue(speakButton.waitForExistence(timeout: 1)) speakButton.tap()