Add email to address release and an address hint
The release sheet gets an optional email field, prefilled from the saved address and kept with it. A conversation suggests releasing the address when the buyer's latest message contains words like "address" or "wo genau" (a keyword guess, German and English, only ever a suggestion). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -307,6 +307,45 @@ test("a token that stops working sends the owner back to sign in", async () => {
|
||||
assert.equal(page!.window.sessionStorage.getItem("allmende.owner.token"), null);
|
||||
});
|
||||
|
||||
test("the sheet offers an email, prefilled from the saved address, and sends it", async () => {
|
||||
node.s.address = { address: "Musterweg 7, 22765 Hamburg", phone: "+49 40 1", email: "vermietung@example.org" };
|
||||
open(`#/login/${TOKEN}`);
|
||||
await page!.waitFor(() => qa(".pane-listings .ocard").length === 2, "the listings");
|
||||
page!.window.location.hash = `#/mine/${L1}/${T_NEW}`;
|
||||
await page!.waitFor(() => qa(".pane-thread .msg").length === 1, "the conversation");
|
||||
|
||||
button("Release address")!.click();
|
||||
await page!.waitFor(() => q<HTMLInputElement>('.sheet input[name="email"]')?.value === "vermietung@example.org", "email prefill");
|
||||
submit(q(".sheet form")!);
|
||||
await page!.waitFor(() => posts().length === 1, "the grant");
|
||||
assert.equal(JSON.parse(posts()[0]!.body).email, "vermietung@example.org");
|
||||
|
||||
// Cleared, it is not sent at all.
|
||||
button("Release address")!.click();
|
||||
await page!.waitFor(() => q<HTMLInputElement>('.sheet input[name="email"]')?.value === "vermietung@example.org", "prefill again");
|
||||
q<HTMLInputElement>('.sheet input[name="email"]')!.value = "";
|
||||
submit(q(".sheet form")!);
|
||||
await page!.waitFor(() => posts().length === 2, "the second grant");
|
||||
assert.equal("email" in JSON.parse(posts()[1]!.body), false);
|
||||
});
|
||||
|
||||
test("a buyer asking where the place is gets a suggestion to release the address", async () => {
|
||||
const ask = async (text: string, dir: "in" | "out" = "in", hidden = false) => {
|
||||
node.s.msgs[T_NEW] = [{ hash: "q", dir, hidden, received_at: NOW, type: "text", n: 1, sent_at: NOW - 60, text }];
|
||||
page?.close();
|
||||
open(`#/login/${TOKEN}`);
|
||||
await page!.waitFor(() => qa(".pane-listings .ocard").length === 2, "the listings");
|
||||
page!.window.location.hash = `#/mine/${L1}/${T_NEW}`;
|
||||
await page!.waitFor(() => qa(".pane-thread .msg").length === 1, "the conversation");
|
||||
return q<HTMLElement>(".pane-thread .hint")!.hidden;
|
||||
};
|
||||
assert.equal(await ask("Sehr gerne! Wo genau ist die Wohnung?"), false, "German question");
|
||||
assert.equal(await ask("Could you send me the address please?"), false, "English request");
|
||||
assert.equal(await ask("Ist die Wohnung noch frei?"), true, "an unrelated question");
|
||||
assert.equal(await ask("Wo genau ist die Wohnung?", "out"), true, "only the buyer's words count");
|
||||
assert.equal(await ask("Wie ist die Adresse?", "in", true), true, "a hidden message is never read");
|
||||
});
|
||||
|
||||
test("signing out forgets the token", async () => {
|
||||
open(`#/login/${TOKEN}`);
|
||||
await page!.waitFor(() => qa(".pane-listings .ocard").length === 2, "the listings");
|
||||
|
||||
Reference in New Issue
Block a user