fix(goal): never drop an unreadable goal by accident, and let the count be retyped
Review found three ordinary actions that deleted a goal this build could not read: "It repeats daily", pressing an already-pressed Off, and "not daily" without saying so. Only "not daily" clears a goal now, and its warning keys off what is stored, not what parses. The count field was bound straight to the goal, so emptying it snapped the old number back and typing appended to it. It now keeps a draft. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d5ffad38c5
commit
064cea25fd
8 files changed
+177
-44
No files matched your search
+14
-1
@@ -1,7 +1,7 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { buildExportData, parseImportData } from "../src/client/state/export.ts";
|
||||
import { restorePrefsValue } from "../src/client/state/usePrefs.ts";
|
||||
import { applyPatch, goalPatch, mergeProgress } from "../src/client/state/useProgress.ts";
|
||||
import { applyPatch, dailyPatch, goalPatch, mergeProgress } from "../src/client/state/useProgress.ts";
|
||||
import type { ProgressMap } from "../src/client/state/useProgress.ts";
|
||||
|
||||
/**
|
||||
@@ -221,3 +221,16 @@ describe("goals on progress", () => {
|
||||
expect(parseImportData(old)!.progress).toEqual({ e: { status: "done", at: at("10") } });
|
||||
});
|
||||
});
|
||||
|
||||
describe("a goal this build cannot read is never cleared by accident", () => {
|
||||
// Final review: "It repeats daily" wiped a newer-shaped goal it could not
|
||||
// see. Only saying the event is *not* daily clears a goal.
|
||||
test("answering 'it repeats daily' leaves the goal alone", () => {
|
||||
expect(dailyPatch(true, false)).toStrictEqual({ daily: true });
|
||||
expect(dailyPatch(undefined, false)).toStrictEqual({ daily: undefined });
|
||||
});
|
||||
|
||||
test("answering 'not daily' clears it in the same write", () => {
|
||||
expect(dailyPatch(false, true)).toStrictEqual({ daily: false, goal: undefined });
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user