payday tests

This commit is contained in:
JCEEE
2026-09-20 16:40:09 +01:00
parent 3a6ba556e6
commit 6d05721629
6 changed files with 82 additions and 24 deletions
@@ -540,9 +540,14 @@
(r.status === 'unclaimed' || r.status === 'requested')
)
);
// Payday-gated bonus rewards unlock on their settleDate (stamped server-side).
// Payday-gated bonus rewards unlock on their settleDate at the fam's payday
// time (stamped server-side) — not midnight on the day.
function paydayLocked(r: any) {
return r.claimable === 'payday' && r.settleDate && todayChild < r.settleDate;
if (r.claimable !== 'payday' || !r.settleDate) return false;
const settle = (r.settleDate as string).slice(0, 10);
if (todayChild < settle) return true;
if (todayChild > settle) return false;
return nowMs < new Date(wallClockToUtc(settle, paydayTime, famTz)).getTime();
}
let weekBonusTallies = $derived.by(() => {
const map = new Map<string, number>();
@@ -883,6 +888,12 @@
famStore.applyRecord('completions', optimistic, 'delete');
}
} catch (e) {
// A stale assigned ID (parent re-saved chores while this tab was
// open in the background) leaves the chore untogglable — refresh
// the store so the UI self-heals instead of staying stuck.
try {
await famStore.init(famId);
} catch {}
if (wasCompleted) {
famStore.applyRecord(
'completions',