Public: anyone can read this; the crew can change it.

The clock's marker for a listing agreement that expires before closing says so in its own words, not "falls on or after closing" #204

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

mason/deal-clock:mason/202-the-clock-s-marker-for-a-listing-agreeme → main 4 commits fork 2 threads · 2 unresolved

  • Merged. mason/202-the-clock-s-marker-for-a-listing-agreeme was merged into main as 3bd16dd.

Review

Sign in to review this change.
4 files changed +21 −3
src/order.page.test.ts +3
@@ -29,6 +29,9 @@ test("on a fresh boot only 9 Orchard Row is flagged, for its listing expiring be
2929 expect(deal.conflicts.map((c) => c.label)).toEqual(deal.address === "9 Orchard Row" ? ["Listing agreement expires"] : []);
3030 const page = await (await fetch(`${base}/`, { headers: alice })).text();
3131 expect(page).toContain("1 out of order");
32 const label = page.match(/aria-label="(Listing agreement expires[^"]*)"/)![1]!;
33 expect(label).toContain("closing falls after the listing agreement expires");
34 expect(label).not.toContain("falls on or after closing");
3235 });
3336
3437 test("moving Alder Lane's financing past closing succeeds and shows the flag everywhere", async () => {
src/order.test.ts +11 −1
@@ -1,5 +1,6 @@
11 import { expect, test } from "bun:test";
2 import { conflictLine, conflicts } from "./order.ts";
2 import { conflictLine, conflictShort, conflicts } from "./order.ts";
3 import { LISTING_EXPIRES } from "./deadlines.ts";
34
45 const d = (id: number, kind: string, due: string, done_at: string | null = null) => ({
56 id,
@@ -33,3 +34,12 @@ test("the line says it in words", () => {
3334 expect(conflictLine(c)).toBe("Financing (Nov 24) now falls after closing (Nov 20): move one or the other.");
3435 expect(conflictLine({ ...c, due: "2026-11-20" })).toContain("now falls on closing");
3536 });
37
38 test("the marker's short words: the listing's own, or on or after closing", () => {
39 const listing = { deadline_id: 1, label: LISTING_EXPIRES, due: "2026-11-30", closing: "2026-12-03" };
40 expect(conflictShort(listing)).toBe("closing falls after the listing agreement expires");
41 expect(conflictShort({ ...listing, due: "2026-12-03" })).toBe("closing falls on the day the listing agreement expires");
42 const late = { deadline_id: 2, label: "Financing", due: "2026-11-24", closing: "2026-11-20" };
43 expect(conflictShort(late)).toBe("falls on or after closing");
44 expect(conflictShort({ ...late, due: "2026-11-20" })).toBe("falls on or after closing");
45 });
src/order.ts +4
@@ -41,3 +41,7 @@ export const conflictLine = (c: Conflict): string =>
4141 c.label === LISTING_EXPIRES
4242 ? `Closing (${short(c.closing)}) falls ${c.due === c.closing ? "on the day" : "after"} the listing agreement expires (${short(c.due)}): extend the listing or move closing.`
4343 : `${c.label} (${short(c.due)}) now falls ${c.due === c.closing ? "on" : "after"} closing (${short(c.closing)}): move one or the other.`;
44
45 /** The conflict in a few words, for a marker's spoken label: "closing falls after the listing agreement expires"; otherwise "falls on or after closing". */
46 export const conflictShort = (c: Conflict): string =>
47 c.label === LISTING_EXPIRES ? `closing falls ${c.due === c.closing ? "on the day" : "after"} the listing agreement expires` : "falls on or after closing";

The on-the-day branch and the non-listing branch are not covered by any test. Add unit tests for both.

src/pages/clock.ts +3 −2
@@ -12,6 +12,7 @@ import { escape } from "../http.ts";
1212 import { agent as defaults } from "../env.ts";
1313 import { todaysDrafts, unsent, type Agent } from "../reminders.ts";
1414 import type { Who } from "../who.ts";
15 import { conflictShort } from "../order.ts";
1516 import { clashLine, clashesLine } from "../overlap.ts";
1617 import { byDay, thisWeek, whereNote } from "../week.ts";
1718 import { layout } from "./layout.ts";
@@ -66,8 +67,8 @@ function drawLane(deal: DealView, start: string, on: string): string {
6667 const d = deal.deadlines[i]!;
6768 const u = urgencyOf(d, on);
6869 const tag = d.kind === "custom" ? d.label.split(" ")[0]! : KIND[d.kind].tag;
69 const flagged = deal.conflicts.some((c) => c.deadline_id === d.id);
70 return `<a class="marker" data-u="${u}"${flagged ? " data-conflict" : ""} ${opens(deal, d)} style="left:${at(x)};top:calc(${row} * 3rem)" aria-label="${escape(`${d.label}, ${spoken(d.due)} — ${URGENCY_LABEL[u]}${flagged ? " — falls on or after closing" : ""}`)}"><span class="dot"></span>${escape(tag)}</a>`;
70 const flagged = deal.conflicts.find((c) => c.deadline_id === d.id);
71 return `<a class="marker" data-u="${u}"${flagged !== undefined ? " data-conflict" : ""} ${opens(deal, d)} style="left:${at(x)};top:calc(${row} * 3rem)" aria-label="${escape(`${d.label}, ${spoken(d.due)} — ${URGENCY_LABEL[u]}${flagged ? ` — ${conflictShort(flagged)}` : ""}`)}"><span class="dot"></span>${escape(tag)}</a>`;
7172 })
7273 .join("");
7374 return `<li class="lane">

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs