feat(ws): consume gateway change events (issue #784) (#837)

* feat(ws): consume gateway change events (cron/sessions/platforms/pairing) for targeted refresh (issue #784)

* test(chat): complete catch-all request stub — kill frozen-collector capture race (slash-focus flake, 4645a2b CI)

---------

Co-authored-by: M57 <hy4ri@users.noreply.github.com>
This commit is contained in:
M57andM57 authored and GitHub committed 2026-08-07 13:48:17 +03:00
1 parent 7d60057156
commit f34bfa7cf8
15 files changed
+320 -4

No files matched your search

@@ -99,6 +99,36 @@ class EventParserTest {
assertEquals(mapOf("session_id" to "session-1"), gatewayReady.data)
}
@Test
fun testParseChangeEvents_returnsChangeEvent() {
// Issue #784: gateway broadcasts change events (pet.changed excluded —
// mobile has no pet feature). All four must map to ChangeEvent with the
// type preserved and the payload attached.
val cases =
mapOf(
"cron.changed" to mapOf("a" to "1"),
"sessions.changed" to mapOf("b" to "2"),
"platforms.changed" to mapOf("c" to "3"),
"pairing.changed" to mapOf("d" to "4"),
)
cases.forEach { (type, payload) ->
val response =
createJsonRpcResponse(
jsonrpc = "2.0",
id = null,
result = null,
error = null,
method = "event",
params = mapOf("type" to type, "payload" to payload),
)
val event = EventParser.parse(response)
assertTrue("expected ChangeEvent for $type, got $event", event is WsEvent.ChangeEvent)
val changeEvent = event as WsEvent.ChangeEvent
assertEquals(type, changeEvent.type)
assertEquals(payload, changeEvent.data)
}
}
@Test
fun testParseMessageToken_returnsMessageTokenEvent() {
val response =