Files
hapi/ios/HapiTests/LiveActivityRoutingTests.swift
T
b81c6be39b feat(ios): add lock-screen Live Activities for running sessions
Hub:
- add encrypted Live Activity token registry, registration API, and
  update/end pushes over direct APNs
- enable only for HAPI_IOS_PUSH=apns; relay reports remote:false
- keep content-state encrypted with the per-install push key and a
  domain-separated AAD

iOS:
- add ActivityKit coordinator, HapiWidgets extension, lock-screen and
  Dynamic Island UI, encrypted content-state, deep links, and settings toggle
- cap concurrent activities and reconcile across hub switches

Docs/tests:
- native contract, privacy, READMEs, localization catalogs
- cross-language cipher fixture and hub/iOS unit tests

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

Co-Authored-By: HAPI <noreply@hapi.run>
Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-11-06 19:18:09 +08:00

42 lines
1.4 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")
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")
}
}