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.
This commit is contained in:
2026-07-02 12:33:52 +04:00
parent beb1d5c3b9
commit 9eb05fc0dd
@@ -268,7 +268,10 @@ class EventInspectRoutesTest {
assertEquals(HttpStatusCode.OK, response.status) assertEquals(HttpStatusCode.OK, response.status)
val array = testJson.parseToJsonElement(response.bodyAsText()) as JsonArray val array = testJson.parseToJsonElement(response.bodyAsText()) as JsonArray
assertEquals(1, array.size) 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 filtered = client.get("/sessions/s1/events?type=WorkspaceStateObserved&limit=1")
val filteredArray = testJson.parseToJsonElement(filtered.bodyAsText()) as JsonArray val filteredArray = testJson.parseToJsonElement(filtered.bodyAsText()) as JsonArray
@@ -277,6 +280,9 @@ class EventInspectRoutesTest {
"WorkspaceStateObserved", "WorkspaceStateObserved",
(filteredArray[0] as JsonObject)["type"]!!.jsonPrimitive.content, (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())
} }
} }