Files
hapi/ios/HapiTests/LiveActivityRoutingTests.swift
d0b0fde6cb feat(ios): jump notifications and session rows to the pending request
Complete the pending-request center's entry points:

- Push payloads already carry the request id for permission and input
  pushes; the notification tap now passes it through AppModel into the
  home screen instead of only the session id.
- Opening a session row whose summary still has pending requests lands on
  the first wait (async questions first, since they live in the collapsible
  bottom panel; approvals scroll to their tool row).
- ChatModel queues the jump until the detail's request dictionary arrives,
  so a cold notification start does not drop the target and a blocking
  target waits for the transcript to settle before scrolling.
- A focus token lets the split detail re-fire for the session that is
  already open.

Routing and pending-target presentation tests cover the new request id.

via [HAPI](https://hapi.run)

Co-Authored-By: HAPI <noreply@hapi.run>
Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-12-01 06:47:01 +08:00

43 lines
1.5 KiB
Swift

import HapiClient
import HapiProtocol
import XCTest
@testable import Hapi
/// Live Activity tap-through uses the same notification-target path as a push
/// tap; the hub hint is only honored when it is already paired.
@MainActor
final class LiveActivityRoutingTests: XCTestCase {
private func makeModel() -> (AppModel, UserDefaults, String) {
let suiteName = "LiveActivityRoutingTests-\(UUID().uuidString)"
let defaults = UserDefaults(suiteName: suiteName)!
let model = AppModel(
registry: HubRegistry(defaults: defaults),
credentialStore: InMemoryCredentialStore()
)
return (model, defaults, suiteName)
}
func testSessionLinkSetsPendingOpenSessionId() {
let (model, defaults, suiteName) = makeModel()
defer { defaults.removePersistentDomain(forName: suiteName) }
model.handleSessionLink(SessionLink(
sessionId: "sess-1",
hubUrl: "https://hub.example.com"
))
XCTAssertEqual(model.pendingOpenSessionId, "sess-1")
XCTAssertNil(model.pendingOpenRequestId)
XCTAssertEqual(model.state, .unpaired)
}
func testUnpairedHubHintFallsBackToTheActiveHub() {
let (model, defaults, suiteName) = makeModel()
defer { defaults.removePersistentDomain(forName: suiteName) }
model.handleSessionLink(SessionLink(sessionId: "sess-2", hubUrl: nil))
XCTAssertEqual(model.pendingOpenSessionId, "sess-2")
}
}