Skip to content
TypeScript

test(server): pin clock in saved-usage window test (#28603)

Theo Browne1280ccd0d2a8
diff --git a/apps/server/src/usage/UsageService.test.ts b/apps/server/src/usage/UsageService.test.ts
index 07a78dc6d50..fbb1aaf8726 100644
--- a/apps/server/src/usage/UsageService.test.ts
+++ b/apps/server/src/usage/UsageService.test.ts
@@ -2640,6 +2640,8 @@ describe("UsageService", () => {
it.live("reports saved usage of a removed directory only for windows it reaches", () =>
Effect.gen(function* () {
const { transcript, settings, home } = yield* setup;
+ // Saved usage is pruned after the retention window, so pin "now" near the write.
+ yield* TestClock.setTime(Date.parse("2026-08-15T00:00:00Z"));
yield* Effect.promise(async () => {
await NodeFSP.writeFile(transcript, claudeLine(1, 5));
const lastWrite = Date.parse("2026-08-01T10:00:00Z") / 1000;
@@ -2665,7 +2667,7 @@ describe("UsageService", () => {
assert.deepStrictEqual(later.buckets, []);
assert.strictEqual(later.sources[0]?.status, "missing");
assert.strictEqual(later.sources[0]?.scannedFiles, 0);
- }).pipe(Effect.scoped),
+ }).pipe(Effect.scoped, Effect.provide(TestClock.layer())),
);
it.live("does not share an in-flight scan after custom prices change", () =>