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

Realtor.com is its own lead source: its leads get their own opener, their own row in the response record, and a sample lead #57

Merged opened this

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

Merged

mason/speed-to-lead:mason/55-realtor-com-is-its-own-lead-source-its-l → main 3 commits fork

  • Merged. mason/55-realtor-com-is-its-own-lead-source-its-l was merged into main as 77ce7d2.

Review

Sign in to review this change.
14 files changed +187 −19
README.md +2 −2
@@ -325,7 +325,7 @@ signed in can read it. The license number is required, because every
325325 message shows it. Drafts you have not sent take the new profile at once;
326326 messages already sent keep the signature they went out with.
327327
328 Under **How your first reply opens**, an admin can write the opening line for each source (Zillow, website, open house, referral), up to 160 characters on one line; leave one empty to keep the built-in wording. **Preview** shows the first reply to a sample lead in your words without saving; new first replies use them, drafts already on the desk keep theirs, and an opener too long to leave a text under its limit falls back to the built-in line for that text.
328 Under **How your first reply opens**, an admin can write the opening line for each source (Zillow, Realtor.com, website, open house, referral), up to 160 characters on one line; leave one empty to keep the built-in wording. **Preview** shows the first reply to a sample lead in your words without saving; new first replies use them, drafts already on the desk keep theirs, and an opener too long to leave a text under its limit falls back to the built-in line for that text.
329329
330330 Until you save one, the app uses these environment variables (forge
331331 Settings → App → Environment) or, failing those, a sample agent, Jordan
@@ -372,7 +372,7 @@ curl -X POST https://<app>/leads/1/state -H 'content-type: application/json' -d
372372 curl -X POST https://<app>/tick # the day turns: follow-ups come due
373373 ```
374374
375 `source` is `zillow`, `website`, `open_house` or `referral`. Names,
375 `source` is `zillow`, `realtor_com`, `website`, `open_house` or `referral`. Names,
376376 emails, phones and messages are plain text: anything carrying control
377377 characters is turned away. `POST /tick` is safe to call as often as you
378378 like, but only as someone the forge has signed in — an unsigned scheduled
contract/openapi.json +17
@@ -98,6 +98,7 @@
9898 "source": {
9999 "enum": [
100100 "zillow",
101 "realtor_com",
101102 "website",
102103 "open_house",
103104 "referral"
@@ -251,6 +252,7 @@
251252 "source": {
252253 "enum": [
253254 "zillow",
255 "realtor_com",
254256 "website",
255257 "open_house",
256258 "referral"
@@ -509,6 +511,7 @@
509511 "source": {
510512 "enum": [
511513 "zillow",
514 "realtor_com",
512515 "website",
513516 "open_house",
514517 "referral"
@@ -1446,6 +1449,10 @@
14461449 "type": "string",
14471450 "maxLength": 160
14481451 },
1452 "realtor_com": {
1453 "type": "string",
1454 "maxLength": 160
1455 },
14491456 "website": {
14501457 "type": "string",
14511458 "maxLength": 160
@@ -1535,6 +1542,10 @@
15351542 "type": "string",
15361543 "maxLength": 160
15371544 },
1545 "realtor_com": {
1546 "type": "string",
1547 "maxLength": 160
1548 },
15381549 "website": {
15391550 "type": "string",
15401551 "maxLength": 160
@@ -1610,6 +1621,10 @@
16101621 "type": "string",
16111622 "maxLength": 160
16121623 },
1624 "realtor_com": {
1625 "type": "string",
1626 "maxLength": 160
1627 },
16131628 "website": {
16141629 "type": "string",
16151630 "maxLength": 160
@@ -1879,6 +1894,7 @@
18791894 "source": {
18801895 "enum": [
18811896 "zillow",
1897 "realtor_com",
18821898 "website",
18831899 "open_house",
18841900 "referral"
@@ -2221,6 +2237,7 @@
22212237 "source": {
22222238 "enum": [
22232239 "zillow",
2240 "realtor_com",
22242241 "website",
22252242 "open_house",
22262243 "referral"
src/actions.test.ts +1 −1
@@ -242,7 +242,7 @@ test("the sample desk: twelve leads, some red, some mid-cadence; only an admin r
242242 .map((l) => T0.getTime() - Date.parse(l.created_at));
243243 expect(waited.filter((ms) => ms >= 3_600_000).length).toBeGreaterThanOrEqual(3);
244244 expect(waited.filter((ms) => ms < 300_000).length).toBeGreaterThanOrEqual(2);
245 expect(new Set(desk.map((l) => l.source)).size).toBe(4);
245 expect(new Set(desk.map((l) => l.source)).size).toBe(5);
246246 expect(desk.some((l) => l.consent) && desk.some((l) => !l.consent)).toBe(true);
247247 expect(desk.filter((l) => l.ready !== null && l.ready.day > 0).length).toBeGreaterThanOrEqual(2);
248248 expect(desk.some((l) => l.state === "qualified")).toBe(true);
src/actions.ts +2 −2
@@ -214,7 +214,7 @@ export function sourceOf(value: unknown): Source | undefined {
214214 const key = String(value ?? "")
215215 .trim()
216216 .toLowerCase()
217 .replace(/[\s-]+/g, "_")
217 .replace(/[\s.-]+/g, "_")
218218 .replace(/_form$/, "");
219219 return (SOURCES as readonly string[]).includes(key)
220220 ? (key as Source)
@@ -276,7 +276,7 @@ export function readNewLead(input: Record<string, unknown>): Result<NewLead> {
276276 if (source === undefined)
277277 return fail(
278278 "invalid",
279 "The source is one of zillow, website, open_house or referral.",
279 "The source is one of zillow, realtor_com, website, open_house or referral.",
280280 );
281281 if (message.length === 0 || message.length > 2000)
282282 return fail("invalid", "What they asked is 1 to 2000 characters.");
src/db.test.ts +31 −2
@@ -1,4 +1,5 @@
11 import { expect, test } from "bun:test";
2 import { Database } from "bun:sqlite";
23 import { mkdtempSync } from "node:fs";
34 import { tmpdir } from "node:os";
45 import { join } from "node:path";
@@ -38,10 +39,38 @@ test("a database that ran the note columns before the openers still gets the ope
3839 const db = openDb(dir);
3940 // As a preview left it: the openers column never added, the version past the notes.
4041 db.exec("ALTER TABLE profile DROP COLUMN openers");
41 db.exec("DELETE FROM schema_version WHERE version > " + (migrations.length - 2));
42 const openers = migrations.findIndex((m) => m.includes("ADD COLUMN openers"));
43 db.exec("DELETE FROM schema_version WHERE version > " + openers);
4244 expect(() => migrate(db)).not.toThrow();
4345 expect(db.query("SELECT openers FROM profile").all()).toBeDefined();
4446 // And the reverse: a column already there is not added again.
45 db.exec("DELETE FROM schema_version WHERE version > " + (migrations.length - 3));
47 db.exec("DELETE FROM schema_version WHERE version > " + openers);
4648 expect(() => migrate(db)).not.toThrow();
4749 });
50
51 test("a database made before Realtor.com was a source keeps its leads, their messages and ids, and takes the new source", () => {
52 const db = new Database(":memory:");
53 const at = migrations.findIndex((m) => m.includes("CREATE TABLE lead_new") && m.includes("'realtor_com'"));
54 expect(at).toBeGreaterThan(0);
55 // The schema as it stood before: every migration ahead of the rebuild.
56 db.exec("CREATE TABLE schema_version (version INTEGER PRIMARY KEY, applied_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')))");
57 migrations.slice(0, at).forEach((sql, i) => {
58 try {
59 db.exec(sql);
60 } catch (e) {
61 if (!/duplicate column/.test(String(e))) throw e; // a column an earlier rebuild already carries
62 }
63 db.query("INSERT INTO schema_version (version) VALUES (?1)").run(i + 1);
64 });
65 db.exec("INSERT INTO lead (id, name, email, source, message, consent) VALUES (7, 'Old Lead', '[email protected]', 'zillow', 'Is it open?', 1)");
66 db.exec("INSERT INTO message (lead_id, day, channel, body, signature, status, due_at) VALUES (7, 0, 'email', 'Hello', 'J', 'draft', '2026-01-01T00:00:00Z')");
67 expect(() => db.exec("INSERT INTO lead (name, email, source, message, consent) VALUES ('X', '[email protected]', 'realtor_com', 'hi', 1)")).toThrow();
68
69 migrate(db);
70
71 expect(db.query("SELECT id, name, source FROM lead").all()).toEqual([{ id: 7, name: "Old Lead", source: "zillow" }]);
72 expect(db.query("SELECT count(*) AS n FROM message WHERE lead_id = 7").get()).toEqual({ n: 1 });
73 db.exec("INSERT INTO lead (name, email, source, message, consent) VALUES ('New', '[email protected]', 'realtor_com', 'hi', 1)");
74 expect(() => db.exec("INSERT INTO lead (name, email, source, message, consent) VALUES ('Y', '[email protected]', 'trulia', 'hi', 1)")).toThrow();
75 expect(check(db).integrity).toBe("ok");
76 });
src/db.ts +27
@@ -227,6 +227,33 @@ export const migrations: string[] = [
227227 // A follow-up the agent skipped by hand, so `reopen` leaves it skipped.
228228 // Existing skipped rows were skipped by a close or a call: 0.
229229 `ALTER TABLE message ADD COLUMN skipped_by_hand INTEGER NOT NULL DEFAULT 0 CHECK (skipped_by_hand IN (0, 1))`,
230 // Realtor.com is a source of its own. SQLite cannot widen a CHECK in place:
231 // the lead table is rebuilt with its rows (ids kept; `migrate` has foreign
232 // keys off, so nothing cascades). Safe to run again.
233 `DROP TABLE IF EXISTS lead_new`,
234 `CREATE TABLE lead_new (
235 id INTEGER PRIMARY KEY,
236 name TEXT NOT NULL CHECK (length(name) BETWEEN 1 AND 120),
237 email TEXT NOT NULL CHECK (length(email) <= 254),
238 phone TEXT NOT NULL DEFAULT '',
239 source TEXT NOT NULL CHECK (source IN ('zillow', 'realtor_com', 'website', 'open_house', 'referral')),
240 message TEXT NOT NULL CHECK (length(message) BETWEEN 1 AND 2000),
241 consent INTEGER NOT NULL CHECK (consent IN (0, 1)),
242 state TEXT NOT NULL DEFAULT 'new' CHECK (state IN ('new', 'contacted', 'qualified', 'lost')),
243 created_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')),
244 replied_at TEXT,
245 updated_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')),
246 opted_out_at TEXT,
247 note TEXT NOT NULL DEFAULT '',
248 note_updated_at TEXT
249 )`,
250 `INSERT INTO lead_new (id, name, email, phone, source, message, consent, state, created_at, replied_at, updated_at, opted_out_at, note, note_updated_at)
251 SELECT id, name, email, phone, source, message, consent, state, created_at, replied_at, updated_at, opted_out_at, note, note_updated_at FROM lead`,
252 `DROP TABLE lead`,
253 `PRAGMA legacy_alter_table = ON;
254 ALTER TABLE lead_new RENAME TO lead;
255 PRAGMA legacy_alter_table = OFF`,
256 `CREATE INDEX IF NOT EXISTS lead_created ON lead (created_at)`,
230257 ];
231258
232259 /** An `ALTER TABLE … ADD COLUMN` whose column the table already has: nothing to do. */
src/drafts.ts +4 −1
@@ -10,16 +10,18 @@
1010 import type { Agent } from "./env.ts";
1111
1212 export type Channel = "text" | "email";
13 export type Source = "zillow" | "website" | "open_house" | "referral";
13 export type Source = "zillow" | "realtor_com" | "website" | "open_house" | "referral";
1414
1515 export const SOURCES: readonly Source[] = [
1616 "zillow",
17 "realtor_com",
1718 "website",
1819 "open_house",
1920 "referral",
2021 ];
2122 export const SOURCE_LABEL: Readonly<Record<Source, string>> = {
2223 zillow: "Zillow",
24 realtor_com: "Realtor.com",
2325 website: "Website form",
2426 open_house: "Open house",
2527 referral: "Referral",
@@ -92,6 +94,7 @@ export const firstName = (name: string): string =>
9294 /** The opening line of a first reply for each source, until the agent words it themselves. */
9395 export const BUILT_IN_OPENER: Readonly<Record<Source, string>> = {
9496 zillow: "Thanks for reaching out on Zillow",
97 realtor_com: "Thanks for reaching out on Realtor.com",
9598 website: "Thanks for your note through my website",
9699 open_house: "It was great to have you at the open house",
97100 referral: "Thank you for reaching out — referrals mean the world to me",
src/intake.test.ts +1 −1
@@ -17,7 +17,7 @@ test("a Realtor.com notification reads its wording and a question over two lines
1717 name: "Tomas Okafor",
1818 email: "[email protected]",
1919 phone: "425-555-0178",
20 source: "website",
20 source: "realtor_com",
2121 message: "We are relocating in June.\nDoes the house on Sample Ave allow dogs?",
2222 });
2323 });
src/intake.ts +9 −4
@@ -85,12 +85,17 @@ const sourceOf = (lines: readonly string[], named: string | undefined): Source |
8585 .filter((l, i) => i < 8 || /^(from|sender|reply-to|subject|via)\s*:/i.test(l))
8686 .join("\n")
8787 .toLowerCase();
88 const said = named?.toLowerCase().replace(/[\s-]+/g, "_").replace(/_form$/, "");
89 if (said === "zillow" || said === "open_house" || said === "referral" || said === "website")
88 const said = named?.toLowerCase().replace(/[\s.-]+/g, "_").replace(/_form$/, "");
89 if (
90 said === "zillow" ||
91 said === "realtor_com" ||
92 said === "open_house" ||
93 said === "referral" ||
94 said === "website"
95 )
9096 return said;
9197 if (head.includes("zillow")) return "zillow";
92 // The desk has no Realtor.com source: it is a website the lead came in through.
93 if (head.includes("realtor.com")) return "website";
98 if (head.includes("realtor.com")) return "realtor_com";
9499 if (/website|web form|contact form|form submission|new inquiry from your/.test(head))
95100 return "website";
96101 return undefined;
src/mcp.ts +1 −1
@@ -313,7 +313,7 @@ export const tools: readonly Tool[] = [
313313 openers: {
314314 type: "object",
315315 description:
316 "How a first reply opens, by source (zillow, website, open_house, referral): one line of at most 160 characters. A source left out keeps its wording; an empty one goes back to the built-in line. Drafts already on the desk are not rewritten.",
316 "How a first reply opens, by source (zillow, realtor_com, website, open_house, referral): one line of at most 160 characters. A source left out keeps its wording; an empty one goes back to the built-in line. Drafts already on the desk are not rewritten.",
317317 properties: Object.fromEntries(
318318 SOURCES.map((s) => [s, { type: "string", maxLength: OPENER_MAX }]),
319319 ),
src/pages/desk.ts +1
@@ -213,6 +213,7 @@ const addForm = (prefill?: Partial<NewLead>): string => `<details class="card ad
213213 const SOURCE_OPTIONS = [
214214 ["website", "Website form"],
215215 ["zillow", "Zillow"],
216 ["realtor_com", "Realtor.com"],
216217 ["open_house", "Open house"],
217218 ["referral", "Referral"],
218219 ] as const;
src/realtor.test.ts added +84
@@ -0,0 +1,84 @@
1 /** Realtor.com as a source of its own: every place a source is named or counted. */
2 import { expect, test } from "bun:test";
3 import { mkdtempSync } from "node:fs";
4 import { tmpdir } from "node:os";
5 import { join } from "node:path";
6 import { addLead, listLeads, readNewLead, saveProfile, sourceOf, type Result } from "./actions.ts";
7 import { openDb } from "./db.ts";
8 import { BUILT_IN_OPENER, draft, SOURCE_LABEL } from "./drafts.ts";
9 import { agent } from "./env.ts";
10 import { leadsCsv } from "./export.ts";
11 import { readLeadEmail } from "./intake.ts";
12 import { insertLead, responseRecord } from "./leads.ts";
13 import { deskPage } from "./pages/desk.ts";
14 import { INQUIRIES } from "./sample.ts";
15 import type { Who } from "./who.ts";
16
17 const fresh = () => openDb(mkdtempSync(join(tmpdir(), "app-realtor-")));
18 const alice: Who = { role: "user", id: "u1", name: "alice" };
19 const root: Who = { role: "admin", id: "u0", name: "root" };
20 const must = <T>(r: Result<T>): T => {
21 if (!r.ok) throw new Error(`${r.error}: ${r.message}`);
22 return r.value;
23 };
24 const input = (source: string) => ({
25 name: "Dana Whitfield",
26 email: "[email protected]",
27 phone: "",
28 source,
29 message: "Is 21 Mercer St still available?",
30 consent: false,
31 });
32
33 test("a Realtor.com lead has its own row in the response record and its own value in the CSV", () => {
34 const db = fresh();
35 const now = Date.now();
36 insertLead(db, { ...input("realtor_com"), source: "realtor_com" }, new Date(now - 60_000).toISOString(), agent);
37 insertLead(db, { ...input("website"), source: "website", email: "[email protected]" }, new Date(now - 60_000).toISOString(), agent);
38 const record = responseRecord(db, now);
39 expect(record.by_source.map((r) => r.source).sort()).toEqual(["realtor_com", "website"]);
40 expect(record.by_source.find((r) => r.source === "realtor_com")!.count).toBe(1);
41 const listed = must(listLeads(db, alice));
42 const rows = leadsCsv(listed.leads, new Map()).split("\n");
43 expect(rows.filter((r) => r.includes(",realtor_com,")).length).toBe(1);
44 expect(deskPage({ who: alice, agent, leads: listed.leads, record: listed.record, mayAdd: true, mayReset: false })).toContain("Realtor.com · 1 lead");
45 });
46
47 test("a Realtor.com first reply opens in its own words, or the agent's", () => {
48 const lead = { ...input("realtor_com"), source: "realtor_com" as const };
49 expect(draft(lead, 0, agent)).toContain("Thanks for reaching out on Realtor.com");
50 expect(draft(lead, 0, { ...agent, openers: { ...BUILT_IN_OPENER, realtor_com: "Glad Realtor.com brought you to me" } })).toContain("Glad Realtor.com brought you to me");
51 const db = fresh();
52 must(saveProfile(db, root, { name: "Sam Realtor", brokerage: "Sam & Co", license: "WA 99887", phone: "(555) 010-0000", email: "[email protected]", openers: { realtor_com: "Hello from my Realtor.com page" } }));
53 const added = must(addLead(db, alice, input("realtor_com")));
54 expect(added.messages[0]!.body).toContain("Hello from my Realtor.com page");
55 });
56
57 test("the boundary takes Realtor.com however it is written, names it in the refusal, and refuses others", () => {
58 for (const said of ["realtor_com", "Realtor.com", "realtor.com", "Realtor-com"]) {
59 expect(sourceOf(said)).toBe("realtor_com");
60 expect(must(readNewLead(input(said))).source).toBe("realtor_com");
61 }
62 expect(sourceOf("trulia")).toBeUndefined();
63 const refused = readNewLead(input("trulia"));
64 expect(refused.ok).toBe(false);
65 if (!refused.ok) expect(refused.message).toContain("realtor_com");
66 expect(SOURCE_LABEL.realtor_com).toBe("Realtor.com");
67 });
68
69 test("the log-a-lead form offers Realtor.com", () => {
70 const listed = must(listLeads(fresh(), alice));
71 const page = deskPage({ who: alice, agent, leads: listed.leads, record: listed.record, mayAdd: true, mayReset: false });
72 expect(page).toContain('value="realtor_com"');
73 });
74
75 test("the sample inquiries include a Realtor.com one", () => {
76 expect(INQUIRIES.some((i) => i.source === "realtor_com")).toBe(true);
77 });
78
79 test("a source named in the email as Realtor.com is read, whatever the email's wording", () => {
80 for (const said of ["Realtor.com", "realtor_com"]) {
81 const read = readLeadEmail(`Name: Pat Doe\nEmail: [email protected]\nSource: ${said}\nMessage: Is it open?`);
82 expect(read.source).toBe("realtor_com");
83 }
84 });
src/sample.ts +2 −1
@@ -69,7 +69,7 @@ export const SAMPLES: readonly Sample[] = [
6969 person("Lena Novak", "open_house", false, "Signed in at the open house on Birch St. Could you send me the disclosures and HOA details?", { ago: 26 * H }),
7070 person("Marcus Lee", "zillow", true, "Can I tour 92 Harbor View Dr this week? Available most evenings after 6.", { ago: 2 * D + 3 * H, answeredIn: 48 * S, touched: [1], note: "Works nights: call after 6. Cash buyer, relocating from Austin; wants a short closing." }),
7171 person("Rosa Alvarez", "referral", false, "My cousin Elena recommended you. We need a bigger place before the baby comes in March.", { ago: 4 * D + 2 * H, answeredIn: 3 * M + 20 * S, touched: [1] }),
72 person("Ethan Brooks", "website", true, "What would my 2-bed condo on Seaview Ave sell for? Considering upsizing next year.", { ago: 8 * D + 5 * H, answeredIn: 2 * M + 5 * S, touched: [1, 3] }),
72 person("Ethan Brooks", "realtor_com", true, "What would my 2-bed condo on Seaview Ave sell for? Considering upsizing next year.", { ago: 8 * D + 5 * H, answeredIn: 2 * M + 5 * S, touched: [1, 3] }),
7373 person("Grace Kim", "zillow", false, "Is the price on 7 Larkspur Ct negotiable? We're pre-approved and ready to move.", { ago: 15 * D, answeredIn: 1 * M + 30 * S, touched: [1, 3, 7], closed: "qualified" }),
7474 person("Hannah Wright", "open_house", false, "Thanks for the tour of the Maple Ave home. Still deciding whether we want to stay in the city.", { ago: 31 * D, answeredIn: 4 * M + 15 * S, touched: [1, 3, 7, 14] }),
7575 ];
@@ -139,6 +139,7 @@ const inquiry = (
139139
140140 export const INQUIRIES: readonly NewLead[] = [
141141 inquiry("Nadia Farouk", "(206) 555-0201", "zillow", true, "Is 55 Cedar Way still on the market? We could see it tomorrow evening."),
142 inquiry("Hugo Lindqvist", "(206) 555-0208", "realtor_com", true, "Found 9 Ridge Rd on Realtor.com. Is the seller open to offers before the weekend?"),
142143 inquiry("Oliver Grant", "(206) 555-0202", "website", false, "Thinking of selling our duplex on Pine St this summer. Could you tell us what it might fetch?"),
143144 inquiry("Sofia Marin", "(206) 555-0203", "open_house", true, "We toured the Willow Ct open house today and loved it. What would an offer need to look like?"),
144145 inquiry("Kenji Watanabe", "(206) 555-0204", "referral", false, "Our neighbour Priya recommended you. We're relocating for work in September and need a 4-bedroom."),
src/terminal.test.ts +5 −4
@@ -101,7 +101,7 @@ test("n logs a lead by hand, field by field, and opens it with its reply drafted
101101 const db = fresh();
102102 const t = terminal(db, alice);
103103 t.key("n");
104 for (const field of ["Zoe Park", "[email protected]", "", "3", "Saw the yard sign on Elm. Can we tour?", "n"]) {
104 for (const field of ["Zoe Park", "[email protected]", "", "4", "Saw the yard sign on Elm. Can we tour?", "n"]) {
105105 type(t, field);
106106 t.key("\r");
107107 }
@@ -246,7 +246,7 @@ test("an admin edits the profile one field at a time; it is saved, audited and r
246246 next(agent.phone, "(555) 010-0000");
247247 next(agent.email, "[email protected]");
248248 next(agent.timeZone, "America/Chicago");
249 for (let i = 0; i < 4; i++) t.key("\r"); // the openers stay built-in
249 for (let i = 0; i < 5; i++) t.key("\r"); // the openers stay built-in
250250 expect(read(t)).toContain("Saved.");
251251 expect(db.query<{ time_zone: string }, []>("SELECT time_zone FROM profile").get()?.time_zone).toBe("America/Chicago");
252252 expect(read(t)).toContain("WA 99887");
@@ -274,10 +274,11 @@ test("the profile shows each source's opening; an admin words them in the termin
274274 expect(read(t)).toContain("Opening for Zillow");
275275 const current = (db.query("SELECT openers FROM profile").get() as { openers: string } | null)?.openers;
276276 expect(current).toBeUndefined();
277 for (let i = 0; i < 3; i++) t.key("\r"); // Zillow, website and the next stay
277 for (let i = 0; i < 3; i++) t.key("\r"); // Zillow, Realtor.com and website stay
278278 clear(t, "x".repeat(300));
279279 type(t, "Hi from the open house!");
280280 t.key("\r");
281 t.key("\r"); // Referral stays; the last one saves
281282 expect(read(t)).toContain("Saved.");
282283 expect(read(t)).toContain("Hi from the open house!");
283284 const saved = db.query<{ openers: string }, []>("SELECT openers FROM profile").get();
@@ -293,7 +294,7 @@ test("a blank license typed in the terminal is refused and nothing is saved", ()
293294 for (const current of [agent.name, agent.brokerage]) t.key("\r"), void current;
294295 clear(t, agent.license);
295296 t.key("\r");
296 for (let i = 0; i < 7; i++) t.key("\r");
297 for (let i = 0; i < 8; i++) t.key("\r");
297298 expect(read(t)).toContain("license number is required");
298299 expect(db.query("SELECT * FROM profile").all()).toHaveLength(0);
299300 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs