mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-09 04:50:59 +00:00
test(measurements): pin the null-trigger stamp on a batch that declares none
This commit is contained in:
1 parent
7e4b9d9be9
commit
d222aa2354
2 files changed
+14
-2
No files matched your search
@@ -153,7 +153,12 @@ describe("POST /api/measurements/batch — PR detection enqueue (v1.4.25 W16c)",
|
||||
expect(prisma.user.update).toHaveBeenCalledTimes(1);
|
||||
expect(prisma.user.update).toHaveBeenCalledWith({
|
||||
where: { id: "user-1" },
|
||||
data: { healthKitLastSyncedAt: expect.any(Date) },
|
||||
// This batch declares no trigger, so the trigger field is nulled and the
|
||||
// background timestamp is not written — see the sync-trigger suite.
|
||||
data: {
|
||||
healthKitLastSyncedAt: expect.any(Date),
|
||||
healthKitLastSyncTrigger: null,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -64,10 +64,14 @@ const TRIGGER_KEYS: Record<SyncTrigger, string> = {
|
||||
function DeliveryDiagnostic({
|
||||
status,
|
||||
t,
|
||||
now,
|
||||
}: {
|
||||
status: HealthKitStatus;
|
||||
t: (key: string, params?: Record<string, string | number>) => string;
|
||||
/** Injectable reference instant, mirroring the pill's own prop. */
|
||||
now?: Date;
|
||||
}) {
|
||||
const reference = now ?? new Date();
|
||||
const trigger = status.lastSyncTrigger ?? null;
|
||||
const triggerLabel = t(
|
||||
trigger
|
||||
@@ -96,7 +100,10 @@ function DeliveryDiagnostic({
|
||||
<dd data-testid="apple-health-last-background">
|
||||
{backgroundAt
|
||||
? formatRelative(
|
||||
Math.max(0, Date.now() - new Date(backgroundAt).getTime()),
|
||||
Math.max(
|
||||
0,
|
||||
reference.getTime() - new Date(backgroundAt).getTime(),
|
||||
),
|
||||
t,
|
||||
)
|
||||
: t("settings.appleHealth.delivery.backgroundNever")}
|
||||
|
||||
Reference in new issue
Block a user