mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-10-23 20:25:56 +00:00
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.
This commit is contained in:
@@ -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<string, unknown>;
|
||||
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<string, unknown>;
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user