Redesign Hope iOS UI, harden playback, and document project handoff
This commit is contained in:
1 parent
40aaf4fea7
commit
24f95639dc
24 files changed
+1470
-594
No files matched your search
@@ -0,0 +1,97 @@
|
||||
import XCTest
|
||||
|
||||
/// Opt-in tests against the actual NAS deployment. No injected replies or media.
|
||||
final class VoiceLiveTests: XCTestCase {
|
||||
private var app: XCUIApplication!
|
||||
private var startedMusic = false
|
||||
|
||||
override func record(_ issue: XCTIssue) {
|
||||
if let app, app.state == .runningForeground {
|
||||
capture("Failure state")
|
||||
let hierarchy = XCTAttachment(string: app.debugDescription)
|
||||
hierarchy.name = "Failure UI hierarchy"
|
||||
hierarchy.lifetime = .keepAlways
|
||||
add(hierarchy)
|
||||
}
|
||||
super.record(issue)
|
||||
}
|
||||
|
||||
override func tearDownWithError() throws {
|
||||
defer { app?.terminate() }
|
||||
guard let app, app.state == .runningForeground else { return }
|
||||
// Stop only playback initiated by this test, including assertion failures.
|
||||
// Do not leave the shared default room playing between test runs.
|
||||
if startedMusic, app.buttons["Stop playback"].exists {
|
||||
app.buttons["Stop playback"].tap()
|
||||
}
|
||||
}
|
||||
|
||||
override func setUpWithError() throws {
|
||||
try XCTSkipUnless(ProcessInfo.processInfo.environment["HOPE_RUN_LIVE_TESTS"] == "1", "Requires the live Hope server")
|
||||
continueAfterFailure = false
|
||||
app = XCUIApplication()
|
||||
startedMusic = false
|
||||
app.launchArguments = ["--ui-testing", "--reset-ui-testing", "--live-testing"]
|
||||
app.launch()
|
||||
}
|
||||
|
||||
func testLiveConversationAndBackgroundTask() {
|
||||
app.buttons["Start chatting"].tap()
|
||||
let composer = app.descendants(matching: .any).matching(identifier: "Message Hope").firstMatch
|
||||
XCTAssertTrue(composer.waitForExistence(timeout: 60), "Agent must join the real LiveKit room")
|
||||
composer.tap()
|
||||
composer.typeText("What is six times seven? Reply in one short sentence.")
|
||||
app.buttons["Send message"].tap()
|
||||
let reply = app.staticTexts.matching(NSPredicate(format: "label CONTAINS[c] 'forty-two' OR label CONTAINS[c] 'forty two' OR label CONTAINS '42'")).firstMatch
|
||||
XCTAssertTrue(reply.waitForExistence(timeout: 60), "Qwen must produce a real response")
|
||||
capture("Live Qwen reply")
|
||||
|
||||
composer.tap()
|
||||
composer.typeText("Compare espresso and filter coffee in a short background task. Use your existing knowledge; no web search needed.")
|
||||
app.buttons["Send message"].tap()
|
||||
app.tabBars.buttons["Activity"].tap()
|
||||
let complete = app.staticTexts["Complete"].firstMatch
|
||||
XCTAssertTrue(complete.waitForExistence(timeout: 90), "Background task must finish and deliver its result")
|
||||
capture("Live background result")
|
||||
app.tabBars.buttons["Talk"].tap()
|
||||
app.buttons["End conversation"].tap()
|
||||
XCTAssertTrue(app.buttons["Start chatting"].waitForExistence(timeout: 20))
|
||||
// A second room must connect cleanly after the first was torn down.
|
||||
app.buttons["Start chatting"].tap()
|
||||
XCTAssertTrue(composer.waitForExistence(timeout: 60))
|
||||
app.buttons["End conversation"].tap()
|
||||
XCTAssertTrue(app.buttons["Start chatting"].waitForExistence(timeout: 20))
|
||||
}
|
||||
|
||||
func testLiveLibraryPlayback() {
|
||||
app.tabBars.buttons["Music"].tap()
|
||||
let play = app.buttons.matching(NSPredicate(format: "label BEGINSWITH 'Play Sheryl Crow'")).firstMatch
|
||||
XCTAssertTrue(play.waitForExistence(timeout: 20), "Existing library must load from NAS")
|
||||
startedMusic = true
|
||||
play.tap()
|
||||
XCTAssertTrue(app.buttons["Pause"].waitForExistence(timeout: 30))
|
||||
// Elapsed media time proves AVPlayer decoded and advanced, beyond a server desired-state label.
|
||||
let position = app.sliders["Playback position"]
|
||||
XCTAssertTrue(position.waitForExistence(timeout: 10))
|
||||
let advanced = NSPredicate { _, _ in
|
||||
let value = position.value as? String ?? "0%"
|
||||
return value != "0%" && value != "0" && !value.isEmpty
|
||||
}
|
||||
expectation(for: advanced, evaluatedWith: position)
|
||||
waitForExpectations(timeout: 35)
|
||||
app.buttons["Pause"].tap()
|
||||
XCTAssertTrue(app.buttons["Play"].waitForExistence(timeout: 10))
|
||||
app.buttons["Seek forward 10 seconds"].tap()
|
||||
capture("Live music playback")
|
||||
app.buttons["Stop playback"].tap()
|
||||
XCTAssertFalse(app.buttons["Pause"].exists)
|
||||
startedMusic = false
|
||||
}
|
||||
|
||||
private func capture(_ name: String) {
|
||||
let attachment = XCTAttachment(screenshot: app.screenshot())
|
||||
attachment.name = name
|
||||
attachment.lifetime = .keepAlways
|
||||
add(attachment)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
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 testMusicSearchAndStationValidation() {
|
||||
app.launch()
|
||||
app.tabBars.buttons["Music"].tap()
|
||||
XCTAssertTrue(app.buttons["Add radio station"].waitForExistence(timeout: 5))
|
||||
XCTAssertTrue(app.staticTexts["Music server unavailable"].waitForExistence(timeout: 10))
|
||||
app.segmentedControls.buttons["Search"].tap()
|
||||
let query = app.textFields["Song, artist, lyrics…"]
|
||||
query.tap()
|
||||
query.typeText("Piano")
|
||||
app.buttons["music.search"].tap()
|
||||
XCTAssertTrue(app.staticTexts.matching(NSPredicate(format: "label CONTAINS 'connect to the server'")).firstMatch.waitForExistence(timeout: 15))
|
||||
app.buttons["Add radio station"].tap()
|
||||
let url = app.textFields["Audio stream URL"]
|
||||
XCTAssertTrue(url.waitForExistence(timeout: 5))
|
||||
url.tap()
|
||||
url.typeText("not-a-url")
|
||||
app.buttons["Add station"].tap()
|
||||
XCTAssertTrue(app.staticTexts["Enter a complete http:// or https:// audio stream address."].exists)
|
||||
app.buttons["Cancel"].tap()
|
||||
XCTAssertTrue(app.buttons["Add radio station"].exists)
|
||||
capture("Music search")
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user