Archived
The music feature is retired: delete the Media tab, MediaAPI, MediaPlayerController, PinnedMediaResourceLoader, MediaPanelView, the media_state control publish, media scope handling in VoiceSession, the volume setting, and all media tests. App is now Talk + Activity tabs. Backend media API in hope-voice-api is untouched (still serves the web UI).
91 lines
4.4 KiB
Swift
91 lines
4.4 KiB
Swift
import XCTest
|
||
|
||
/// Real UI interactions with isolated preferences. These cover the client,
|
||
/// including offline recovery; they do not claim to verify the live backend.
|
||
final class VoiceUITests: XCTestCase {
|
||
private var app: XCUIApplication!
|
||
|
||
override func setUpWithError() throws {
|
||
continueAfterFailure = false
|
||
app = XCUIApplication()
|
||
app.launchArguments = ["--ui-testing", "--reset-ui-testing"]
|
||
}
|
||
|
||
func testWelcomeNavigationAndOfflineRecovery() {
|
||
app.launch()
|
||
XCTAssertTrue(app.buttons["Let’s talk"].waitForExistence(timeout: 10))
|
||
XCTAssertTrue(app.staticTexts["Your microphone turns on when you connect."].exists)
|
||
app.buttons["Type"].tap()
|
||
XCTAssertTrue(app.buttons["Start chatting"].exists)
|
||
XCTAssertTrue(app.staticTexts["Your microphone stays off."].exists)
|
||
app.buttons["Start chatting"].tap()
|
||
XCTAssertTrue(app.buttons["Try again"].waitForExistence(timeout: 20))
|
||
XCTAssertTrue(app.staticTexts["Couldn’t connect to Hope"].exists)
|
||
app.buttons["Check connection settings"].tap()
|
||
XCTAssertTrue(app.textFields["Server URL"].waitForExistence(timeout: 5))
|
||
capture("Offline recovery")
|
||
}
|
||
|
||
func testVoiceSelectionPersistsAndURLValidation() {
|
||
app.launch()
|
||
app.buttons["Settings"].tap()
|
||
app.buttons.matching(NSPredicate(format: "label CONTAINS 'Speaking voice'")).firstMatch.tap()
|
||
let voice = app.buttons.matching(NSPredicate(format: "label CONTAINS 'Jenny'")).firstMatch
|
||
XCTAssertTrue(voice.waitForExistence(timeout: 5))
|
||
voice.tap()
|
||
XCTAssertTrue(app.buttons.matching(NSPredicate(format: "label CONTAINS 'Speaking voice' AND label CONTAINS 'Jenny'")).firstMatch.exists)
|
||
let server = app.textFields["Server URL"]
|
||
server.tap()
|
||
let old = server.value as? String ?? ""
|
||
server.typeText(String(repeating: XCUIKeyboardKey.delete.rawValue, count: old.count) + "http://example.com")
|
||
app.buttons["Save server address"].tap()
|
||
XCTAssertTrue(app.staticTexts.matching(NSPredicate(format: "label CONTAINS 'must use https'")).firstMatch.waitForExistence(timeout: 5))
|
||
app.terminate()
|
||
app.launchArguments = ["--ui-testing"]
|
||
app.launch()
|
||
app.buttons["Settings"].tap()
|
||
XCTAssertTrue(app.buttons.matching(NSPredicate(format: "label CONTAINS 'Speaking voice' AND label CONTAINS 'Jenny'")).firstMatch.waitForExistence(timeout: 5))
|
||
XCTAssertEqual(app.textFields["Server URL"].value as? String, "https://127.0.0.1:1")
|
||
}
|
||
|
||
func testTranscriptClearConfirmationAndActivityDetails() {
|
||
app.launchArguments.append("--ui-fixtures")
|
||
app.launch()
|
||
XCTAssertTrue(app.staticTexts["Help me plan a quiet weekend."].waitForExistence(timeout: 10))
|
||
app.buttons["Conversation options"].tap()
|
||
app.buttons["Clear conversation"].tap()
|
||
app.buttons["Cancel"].tap()
|
||
XCTAssertTrue(app.staticTexts["Help me plan a quiet weekend."].exists)
|
||
app.buttons["Conversation options"].tap()
|
||
app.buttons["Clear conversation"].tap()
|
||
app.buttons["Clear conversation"].tap()
|
||
XCTAssertTrue(app.buttons["Let’s talk"].exists)
|
||
XCTAssertFalse(app.staticTexts["Help me plan a quiet weekend."].exists)
|
||
app.tabBars.buttons["Activity"].tap()
|
||
XCTAssertTrue(app.staticTexts["Needs attention"].waitForExistence(timeout: 5))
|
||
XCTAssertTrue(app.staticTexts["Search backend timed out after 30s"].exists)
|
||
app.buttons["1 progress updates"].tap()
|
||
XCTAssertTrue(app.staticTexts["Fetching benchmark articles…"].exists)
|
||
capture("Activity details")
|
||
}
|
||
|
||
func testLargeTypeNavigation() {
|
||
app.launchArguments += ["-UIPreferredContentSizeCategoryName", "UICTContentSizeCategoryAccessibilityXXXL"]
|
||
app.launch()
|
||
XCTAssertTrue(app.buttons["Let’s talk"].waitForExistence(timeout: 10))
|
||
XCTAssertTrue(app.buttons["Let’s talk"].isHittable)
|
||
app.tabBars.buttons["Activity"].tap()
|
||
XCTAssertTrue(app.staticTexts["A little help, in the background"].waitForExistence(timeout: 5))
|
||
app.buttons["Settings"].tap()
|
||
XCTAssertTrue(app.navigationBars["Settings"].exists)
|
||
capture("Accessibility text size")
|
||
}
|
||
|
||
private func capture(_ name: String) {
|
||
let attachment = XCTAttachment(screenshot: app.screenshot())
|
||
attachment.name = name
|
||
attachment.lifetime = .keepAlways
|
||
add(attachment)
|
||
}
|
||
}
|