From 0b72225921d320e33c4c478bf6474170d92c77d4 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Thu, 1 Oct 2026 11:27:43 +0800 Subject: [PATCH] test(platform): pin the clock in the former-owner usage test The test placed the former owner's interval five to two days before now and expected it inside the current billing period, so it failed during the first two days of every UTC month. It now runs at a fixed mid-month time. Co-Authored-By: Claude Opus 5.5 (1M context) --- .../packages/api/test/integration/operator-tenants.test.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/platform/packages/api/test/integration/operator-tenants.test.ts b/platform/packages/api/test/integration/operator-tenants.test.ts index 2c02f96a4..2978fe287 100644 --- a/platform/packages/api/test/integration/operator-tenants.test.ts +++ b/platform/packages/api/test/integration/operator-tenants.test.ts @@ -79,6 +79,7 @@ beforeEach(async () => { token = await createOperatorToken(env.db, admin); }); afterEach(() => { + vi.useRealTimers(); vi.restoreAllMocks(); vi.unstubAllGlobals(); }); @@ -192,6 +193,10 @@ describe('operator tenant reads', () => { const formerOwner = await createTestUser(env.db, 'operator-usage-former'); const currentOwner = await createTestUser(env.db, 'operator-usage-current'); const project = await createTestProject(env.db, currentOwner.id, 'operator-usage-project'); + // Both ownership intervals must fall inside the billing period anchored on + // the 1st, so pin the clock mid-month instead of relying on today's date. + vi.useFakeTimers({ toFake: ['Date'] }); + vi.setSystemTime(new Date('2026-07-15T12:00:00.000Z')); const ownedFrom = new Date(Date.now() - 5 * 24 * 60 * 60 * 1_000); const transferredAt = new Date(Date.now() - 2 * 24 * 60 * 60 * 1_000); transferredAt.setMilliseconds(500);