fix(checkups): show a marked-done check-up as done before the refetch

The "Mark done" button re-enables as soon as the satisfy call settles,
while the row kept reading as due until the list refetch landed, so a
second tap stored a second satisfied entry; skip and snooze behaved the
same. The row each of the three calls answers with is now written into
the cached list on success, so the row moves to its next due date at
once, and the refetch follows as before.
This commit is contained in:
Marc-André Bombeck committed 2026-11-11 22:56:32 +01:00
1 parent 46906916d8
commit d79060e26b
2 files changed
+47 -4

No files matched your search

@@ -1,7 +1,11 @@
import { describe, it, expect, vi } from "vitest";
import { QueryClient, QueryObserver } from "@tanstack/react-query";
import { invalidateReminderReads } from "@/hooks/use-measurement-reminders";
import {
invalidateReminderReads,
putReminderRow,
type MeasurementReminder,
} from "@/hooks/use-measurement-reminders";
import { queryKeys } from "@/lib/query-keys";
/**
@@ -71,3 +75,23 @@ describe("invalidateReminderReads — the Vorsorge daily-rail freshness contract
client.clear();
});
});
describe("putReminderRow", () => {
it("shows the answered row at once, so it no longer reads as due", () => {
const client = new QueryClient();
const due = {
id: "r1",
nextDueAt: "2026-11-11T08:00:00.000Z",
} as MeasurementReminder;
const other = { id: "r2" } as MeasurementReminder;
client.setQueryData(queryKeys.measurementReminders(), [due, other]);
const done = { ...due, nextDueAt: "2027-11-11T08:00:00.000Z" };
putReminderRow(client, done);
expect(client.getQueryData(queryKeys.measurementReminders())).toEqual([
done,
other,
]);
});
});