From 9eb05fc0dd0961166ad84c54fc4100d522ebd565 Mon Sep 17 00:00:00 2001 From: kami Date: Thu, 2 Jul 2026 12:33:52 +0400 Subject: [PATCH] test: align events-limit test with tail semantics The /events limit test still asserted the oldest event (seq 1) after 18cbd34 deliberately switched the no-fromSeq path to return the tail (so a pending approval at the tail stays visible to a headless operator). Expect the tail (seq 3) and add a post-filter tail assertion (seq 2) so the test actually verifies truncate-after-filter. --- .../correx/apps/server/routes/EventInspectRoutesTest.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/server/src/test/kotlin/com/correx/apps/server/routes/EventInspectRoutesTest.kt b/apps/server/src/test/kotlin/com/correx/apps/server/routes/EventInspectRoutesTest.kt index 16291ab5..57e3aebd 100644 --- a/apps/server/src/test/kotlin/com/correx/apps/server/routes/EventInspectRoutesTest.kt +++ b/apps/server/src/test/kotlin/com/correx/apps/server/routes/EventInspectRoutesTest.kt @@ -268,7 +268,10 @@ class EventInspectRoutesTest { assertEquals(HttpStatusCode.OK, response.status) val array = testJson.parseToJsonElement(response.bodyAsText()) as JsonArray assertEquals(1, array.size) - assertEquals(1L, (array[0] as JsonObject)["sequence"]!!.jsonPrimitive.content.toLong()) + // Tail semantics: limit with no fromSeq returns the most recent events, so seq 3 (the + // last seeded event), not the oldest. A pending approval lives at the tail — this is the + // behaviour a headless operator needs. + assertEquals(3L, (array[0] as JsonObject)["sequence"]!!.jsonPrimitive.content.toLong()) val filtered = client.get("/sessions/s1/events?type=WorkspaceStateObserved&limit=1") val filteredArray = testJson.parseToJsonElement(filtered.bodyAsText()) as JsonArray @@ -277,6 +280,9 @@ class EventInspectRoutesTest { "WorkspaceStateObserved", (filteredArray[0] as JsonObject)["type"]!!.jsonPrimitive.content, ) + // Truncation is applied AFTER filtering: the tail of the two WorkspaceStateObserved + // events is seq 2, not the InitialIntent at seq 3. + assertEquals(2L, (filteredArray[0] as JsonObject)["sequence"]!!.jsonPrimitive.content.toLong()) } }