Files
openclaw/apps/macos/Tests/OpenClawIPCTests/MacNodePresenceReporterTests.swift
Peter Steinberger 55254c3a0b feat(nodes): route alerts to the active computer (#105083)
* feat(nodes): route alerts by active computer

* fix(ci): allowlist node presence mobile coverage

* test(prompts): refresh node presence snapshots

* fix(macos): await presence reporter actor hop

* fix(macos): type presence test delivery state

* docs(nodes): add active presence guide

* docs(nodes): format presence troubleshooting
2026-07-12 10:05:50 +01:00

46 lines
1.4 KiB
Swift

import Testing
@testable import OpenClaw
@MainActor
struct MacNodePresenceReporterTests {
@Test func `first activity sample sends immediately`() {
#expect(MacNodePresenceReporter._testShouldSend(
idleSeconds: 0,
nowMs: 100_000,
lastSentAtMs: nil,
lastSentActiveAtMs: nil))
}
@Test func `continuous activity is throttled and then refreshed`() {
#expect(!MacNodePresenceReporter._testShouldSend(
idleSeconds: 0,
nowMs: 110_000,
lastSentAtMs: 100_000,
lastSentActiveAtMs: 100_000))
#expect(MacNodePresenceReporter._testShouldSend(
idleSeconds: 0,
nowMs: 115_000,
lastSentAtMs: 100_000,
lastSentActiveAtMs: 100_000))
}
@Test func `idle presence gets a sparse keepalive`() {
#expect(!MacNodePresenceReporter._testShouldSend(
idleSeconds: 100,
nowMs: 200_000,
lastSentAtMs: 100_000,
lastSentActiveAtMs: 100_000))
#expect(!MacNodePresenceReporter._testShouldSend(
idleSeconds: 2_592_000,
nowMs: 115_000,
lastSentAtMs: 100_000,
lastSentActiveAtMs: 100_000,
saturated: true))
#expect(MacNodePresenceReporter._testShouldSend(
idleSeconds: 180,
nowMs: 280_000,
lastSentAtMs: 100_000,
lastSentActiveAtMs: 100_000))
}
}