From c292c4a39eef70081d370cdc8d91b334c0e7580b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Tue, 20 Oct 2026 15:36:13 +0200 Subject: [PATCH] test(api): fix the bulk-route fixture and stub the write ceiling where the limiter is mocked --- tests/integration/insights-provider-chain.test.ts | 6 ++++++ tests/integration/write-meter.test.ts | 12 ++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/integration/insights-provider-chain.test.ts b/tests/integration/insights-provider-chain.test.ts index f85461161..aff86654d 100644 --- a/tests/integration/insights-provider-chain.test.ts +++ b/tests/integration/insights-provider-chain.test.ts @@ -84,6 +84,12 @@ vi.mock("@/lib/rate-limit", () => ({ remaining: 9, resetAt: Date.now() + 3600_000, })), + // The shared write ceiling every authenticated POST is charged against. + checkRecordWriteRateLimit: vi.fn(async () => ({ + allowed: true, + remaining: 299, + resetAt: Date.now() + 60_000, + })), })); beforeEach(async () => { diff --git a/tests/integration/write-meter.test.ts b/tests/integration/write-meter.test.ts index 5b448a8f8..e72265dbf 100644 --- a/tests/integration/write-meter.test.ts +++ b/tests/integration/write-meter.test.ts @@ -164,20 +164,20 @@ describe("the shared write bucket on routes without a limiter of their own", () method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ - measurements: [ + entries: [ { - type: "WEIGHT", + hkIdentifier: "HKQuantityTypeIdentifierBodyMass", value: 72.4, unit: "kg", - measuredAt: new Date(Date.now() - 3_600_000).toISOString(), - source: "APPLE_HEALTH", - externalId: "write-meter-weight-1", + startDate: new Date(Date.now() - 3_600_000).toISOString(), + endDate: new Date(Date.now() - 3_600_000).toISOString(), + externalId: "uuid-write-meter-weight-1", }, ], }), }), ); - expect(res.status).toBeLessThan(300); + expect(res.status, await res.clone().text()).toBeLessThan(300); expect( await getPrismaClient().measurement.count({ where: { userId: USER_ID } }), ).toBe(1);