mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 12:32:43 +00:00
test(api): fix the bulk-route fixture and stub the write ceiling where the limiter is mocked
This commit is contained in:
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 () => {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user