Files
hapi/ios/HapiTests/WidgetRefreshTests.swift
T
bf67e52ea8 feat(ios,hub): refresh the widget from silent APNs and background tasks
- Hub: add a background APNs transport and a throttled widget-state
  notifier; fan out silent content-available wakes to registered iOS
  devices on widget-visible session changes.
- iOS: handle silent pushes and BGAppRefreshTask by refreshing the active
  hub list and waiting for the App Group snapshot write; enable background
  modes; register APNs tokens even when alert permission is denied.
- Store: repair a drifted fcm_devices schema missing push_key so
  /api/devices/register no longer 500s (this also restores alert push
  registration on the affected database).
- Document the silent-refresh fallback and its best-effort limits.

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

Co-Authored-By: HAPI <noreply@hapi.run>
Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-11-07 05:51:23 +08:00

34 lines
961 B
Swift

import XCTest
@testable import Hapi
@MainActor
final class WidgetRefreshTests: XCTestCase {
func testSilentPushDetection() {
XCTAssertTrue(WidgetRefreshScheduler.isSilentPush([
"aps": ["content-available": 1]
]))
XCTAssertTrue(WidgetRefreshScheduler.isSilentPush([
"aps": ["content-available": true]
]))
XCTAssertFalse(WidgetRefreshScheduler.isSilentPush([
"aps": ["alert": ["title": "HAPI"]]
]))
XCTAssertFalse(WidgetRefreshScheduler.isSilentPush([:]))
}
func testBridgeForwardsTheInstalledRefresh() async {
let bridge = WidgetRefreshBridge()
let missing = await bridge.refresh()
XCTAssertFalse(missing)
var calls = 0
bridge.install {
calls += 1
return true
}
let refreshed = await bridge.refresh()
XCTAssertTrue(refreshed)
XCTAssertEqual(calls, 1)
}
}