fix(forms): don't ask for an end date the form is hiding

With "Comes back after a wait" and "I don't know when it ends" both
chosen, the end field is hidden, yet the still-needed line asked for "an
end date". It now names the way out: an end date, or another repeat.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lucas WintherandClaude Opus 5.5 committed 2026-10-14 03:18:22 +02:00
1 parent efd6eff084
commit b219c98c1b
2 files changed
+25 -2

No files matched your search

+5 -1
View File
@@ -455,7 +455,11 @@ export function eventStillNeeded(s: {
const needs: string[] = [];
if (s.title.trim() === "") needs.push("a name");
if (s.startDate === "") needs.push("a start date");
if ((s.datedWindow && s.endKnown && s.endDate === "") || s.delayNeedsEnd) {
if (s.delayNeedsEnd && !s.endKnown) {
// The end field is hidden behind "I don't know when it ends", so a bare
// "an end date" would ask for something not on screen.
needs.push("an end date (a wait counts from it) or another repeat");
} else if ((s.datedWindow && s.endKnown && s.endDate === "") || s.delayNeedsEnd) {
needs.push("an end date");
}
if (s.needsCycle) needs.push("a cycle length");
+20 -1
View File
@@ -259,7 +259,7 @@ describe("what an event still needs", () => {
expect(eventStillNeeded({ ...base, endDate: "", endKnown: false })).toEqual([]);
expect(eventStillNeeded({ ...base, endDate: "", datedWindow: false })).toEqual([]);
expect(eventStillNeeded({ ...base, endKnown: false, delayNeedsEnd: true })).toEqual([
"an end date",
"an end date (a wait counts from it) or another repeat",
]);
expect(eventStillNeeded({ ...base, needsCycle: true })).toEqual(["a cycle length"]);
});
@@ -338,3 +338,22 @@ describe("review fixes: Save never sits disabled without a reason", () => {
expect(filled.needs).toEqual([]);
});
});
describe("follow-up: a wait with the end set to unknown", () => {
test("names the way out instead of asking for a field it hides", () => {
const v: EventFormValues = {
...blankEvent,
title: "x",
cadence: "custom",
repeatMode: "delay",
endKnown: false,
startDate: "2026-10-01",
endDate: "",
};
expect(eventFormState(v, null).needs).toEqual([
"an end date (a wait counts from it) or another repeat",
]);
// With the end field on screen, the plain words are enough.
expect(eventFormState({ ...v, endKnown: true }, null).needs).toEqual(["an end date"]);
});
});