History

test(mcp): verify usage cursor continuation

Julius Marminge committed 2 months ago

Commit a56058c1 parent 4885b871 file · +10 −2Browse files

Unified · Split

apps/server/src/mcp/EnvironmentUsageMcpService.test.ts+10−2
@@ -141,11 +141,9 @@ it.effect( · 140 unmodified lines
141141 "returns a deterministic bounded page without source fingerprints or raw diagnostics",
142142 () =>
143143 Effect.gen(function* () {
144− const observed = yield* Ref.make<ReadonlyArray<unknown>>([]);
145144 const service = yield* EnvironmentUsageMcpService;
146145 const result = yield* service.read(scope, input);
147146 yield* encodeEnvironmentUsageResult(result);
148− yield* Ref.update(observed, (values) => [...values, result]);
149147
150148 expect(result.bucketTotal).toBe(2);
151149 expect(result.bucketNextCursor).toBe(1);
@@ -195,6 +193,16 @@ it.effect( · 43 unmodified lines
195193 expect(result.costMeaning).toBe("api_equivalent_estimate");
196194 expect(result.paginationConsistency).toBe("live_summary");
197195 expect(result.cacheBehavior).toBe("may_refresh_existing_usage_caches");
196+
197+ const nextCursor = result.bucketNextCursor ?? assert.fail("expected a second bucket page");
198+ const secondPage = yield* service.read(scope, { ...input, bucketCursor: nextCursor });
199+ yield* encodeEnvironmentUsageResult(secondPage);
200+ expect(secondPage).toMatchObject({
201+ bucketCursor: 1,
202+ bucketNextCursor: null,
203+ bucketTotal: 2,
204+ buckets: [{ day: "2026-08-02", provider: "codex", model: { text: "z-model" } }],
205+ });
198206 }).pipe(Effect.provide(serviceLayer(() => Effect.succeed(summary)))),
199207 );
200208