test(api): fix the bulk-route fixture and stub the write ceiling where the limiter is mocked

This commit is contained in:
Marc-André Bombeck committed 2026-10-20 15:36:13 +02:00
1 parent 44f3181998
commit c292c4a39e
2 files changed
+12 -6

No files matched your search

@@ -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 () => {
+6 -6
View File
@@ -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);