Public: anyone can read this; the crew can change it.
An inspection or walkthrough held at the deal's own address says "at the property" on This week, instead of repeating the address #212
mason/deal-clock:mason/210-an-inspection-or-walkthrough-held-at-the → main 1 commit fork
2 files
changed +23
−5
src/week.appointment.test.ts +18 −1
| @@ -6,7 +6,8 @@ import { join } from "node:path"; | ||
| 6 | 6 | import { addDays, DEFAULT_ZONE, today } from "./dates.ts"; |
| 7 | 7 | import { openDb } from "./db.ts"; |
| 8 | 8 | import { createDeal, listDeals, setAppointment } from "./deals.ts"; |
| 9 | import { thisWeek } from "./week.ts"; | |
| 9 | import { appointmentLine } from "./appointment.ts"; | |
| 10 | import { appointmentNote, thisWeek } from "./week.ts"; | |
| 10 | 11 | import { weekPage } from "./pages/week.ts"; |
| 11 | 12 | import { forgetRationing } from "./security.ts"; |
| 12 | 13 | import { serve } from "./server.ts"; |
| @@ -71,3 +72,19 @@ test("a day's timed dates come first, earliest first, then the untimed in today' | ||
| 71 | 72 | const html = render(); |
| 72 | 73 | expect(html.indexOf("9:00 am")).toBeLessThan(html.indexOf("3:30 pm")); |
| 73 | 74 | }); |
| 75 | ||
| 76 | test("a place equal to the deal's address (trimmed, any case) reads \"at the property\"; another place is kept; the deal page keeps the address", async () => { | |
| 77 | const deal = open(); | |
| 78 | const walk = dateOf(deal, "walkthrough"); | |
| 79 | for (const place of [deal.address, ` ${deal.address.toUpperCase()} `]) { | |
| 80 | setAppointment(db, alice, { id: walk.id, time: "08:15", place }); | |
| 81 | const html = await page(); | |
| 82 | expect(html).toContain("8:15 am · at the property"); | |
| 83 | expect(appointmentNote({ kind: "walkthrough", time: "08:15", place }, deal.address)).toBe("8:15 am · at the property"); | |
| 84 | } | |
| 85 | setAppointment(db, alice, { id: walk.id, time: "08:15", place: "Lakeside Title" }); | |
| 86 | expect(await page()).toContain("8:15 am · Lakeside Title"); | |
| 87 | expect(appointmentNote({ kind: "walkthrough", time: "08:15", place: "Lakeside Title" }, deal.address)).toBe("8:15 am · Lakeside Title"); | |
| 88 | // the shared line, used by the timeline, calendar and drafts, still carries the full address | |
| 89 | expect(appointmentLine({ kind: "walkthrough", time: "08:15", place: deal.address })).toBe(`8:15 am · ${deal.address}`); | |
| 90 | }); |
src/week.ts +5 −4
| @@ -42,7 +42,7 @@ export function closingNote(deal: WeekDeal<unknown>, d: { kind?: string }): stri | ||
| 42 | 42 | /** The time and place after a row's label: the closing's, or an inspection's or walkthrough's; "" when there is none. */ |
| 43 | 43 | export function whereNote(deal: WeekDeal<unknown>, d: { kind: string; time?: string | null; place?: string | null }): string { |
| 44 | 44 | const where = closingNote(deal, d); |
| 45 | return where === "" ? appointmentNote(d) : where; | |
| 45 | return where === "" ? appointmentNote(d, deal.address) : where; | |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | export function thisWeek<D extends { due: string; done_at: string | null; waived_at: string | null }, Deal extends WeekDeal<D>>( |
| @@ -64,9 +64,10 @@ export function thisWeek<D extends { due: string; done_at: string | null; waived | ||
| 64 | 64 | ); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | /** "10:00 am · 12 Elm St" for an inspection or walkthrough row with a time or place; "" for any other row. */ | |
| 68 | export function appointmentNote(d: { kind: string; time?: string | null; place?: string | null }): string { | |
| 69 | return appointmentLine({ kind: d.kind, time: d.time ?? null, place: d.place ?? null }); | |
| 67 | /** "10:00 am · 12 Elm St" for an inspection or walkthrough row with a time or place; "" for any other row. A place equal to the deal's address (trimmed, any case) reads "at the property". */ | |
| 68 | export function appointmentNote(d: { kind: string; time?: string | null; place?: string | null }, address?: string): string { | |
| 69 | const same = address !== undefined && d.place != null && d.place.trim() !== "" && d.place.trim().toLowerCase() === address.trim().toLowerCase(); | |
| 70 | return appointmentLine({ kind: d.kind, time: d.time ?? null, place: same ? "at the property" : (d.place ?? null) }); | |
| 70 | 71 | } |
| 71 | 72 | |
| 72 | 73 | /** Who owes a date: the deal's party in that role by name, if it has one, and the role either way. */ |
new above
offline