From e1f23b35d0bda30b56ff3ebbd9e5a1b318c0b1da Mon Sep 17 00:00:00 2001 From: rcourtman <8825017+rcourtman@users.noreply.github.com> Date: Thu, 24 Sep 2026 11:30:28 +0100 Subject: [PATCH] Wait for the coalesced report in the agent registration journey The agent registration journey posts a second host report about a second after the first and read /api/state at once. Report-driven store refreshes now fold into one trailing refresh per 2-second window, so the update is published within the window rather than before the report response returns, and the journey read the first report's 42.5% CPU instead of 75% (Core E2E "Agent registration lifecycle"). Poll /api/state for up to 10 seconds until the update appears, then check the remaining fields as before. --- .../04-agent-install-registration.spec.ts | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/tests/integration/tests/journeys/04-agent-install-registration.spec.ts b/tests/integration/tests/journeys/04-agent-install-registration.spec.ts index 832aa57399..ad45a17c76 100644 --- a/tests/integration/tests/journeys/04-agent-install-registration.spec.ts +++ b/tests/integration/tests/journeys/04-agent-install-registration.spec.ts @@ -291,10 +291,25 @@ test.describe("Journey: Agent Install → Registration → Host Visible", () => }); expect(updateRes.ok()).toBeTruthy(); - const stateRes2 = await apiRequest(page, "/api/state"); - expect(stateRes2.ok()).toBeTruthy(); - const state2 = (await stateRes2.json()) as Record; - const host2 = findRegisteredAgentResource(state2); + // Reports within one refresh window are published together by a + // trailing store refresh (agent-lifecycle contract, #2199), so the + // update is visible within the window rather than at once. + let host2: StateResource | undefined; + await expect + .poll( + async () => { + const stateRes2 = await apiRequest(page, "/api/state"); + expect(stateRes2.ok()).toBeTruthy(); + const state2 = (await stateRes2.json()) as Record; + host2 = findRegisteredAgentResource(state2); + return readNumber(asRecord(host2?.cpu)?.current) ?? 0; + }, + { + message: "CPU usage should reflect updated report (75%)", + timeout: 10_000, + }, + ) + .toBeGreaterThanOrEqual(70); expect(host2, "Host should still exist after second report").toBeTruthy(); const lastSeen2 = readNumber(host2!.lastSeen);