Send messages with Ctrl+Enter
Ctrl+Enter (Cmd+Enter on a Mac) submits the buyer's and the owner's message boxes through the normal form, so the usual checks apply. Plain Enter still adds a line. The empty box hints at the shortcut. Not added to the publish description or the address-release note, where it could submit by accident. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -62,6 +62,26 @@ test("a first message is encrypted, mined and sent; the conversation opens", asy
|
||||
}
|
||||
});
|
||||
|
||||
test("Ctrl+Enter sends the first message like the button does", async () => {
|
||||
const before = gw.posted.length;
|
||||
const p = openPage(gw.url, detail);
|
||||
try {
|
||||
await p.waitFor(() => p.document.querySelector("textarea") !== null, "the contact form");
|
||||
const area = p.document.querySelector("textarea")!;
|
||||
const press = (init: KeyboardEventInit) => area.dispatchEvent(new p.window.KeyboardEvent("keydown", { key: "Enter", bubbles: true, cancelable: true, ...init }));
|
||||
area.value = "Per Tastatur gesendet";
|
||||
assert.equal(press({}), true, "a plain Enter only adds a line");
|
||||
await new Promise((r) => setTimeout(r, 50));
|
||||
assert.equal(gw.posted.length, before);
|
||||
press({ ctrlKey: true });
|
||||
await p.waitFor(() => p.window.location.hash.startsWith("#/c/"), "the conversation view");
|
||||
assert.equal(gw.posted.length, before + 1);
|
||||
assert.equal(openAsOwner(JSON.parse(gw.posted[before]!) as Envelope, owner).text, "Per Tastatur gesendet");
|
||||
} finally {
|
||||
p.close();
|
||||
}
|
||||
});
|
||||
|
||||
test("links are refused in a first message, and nothing is sent", async () => {
|
||||
const before = gw.posted.length;
|
||||
const p = openPage(gw.url, detail);
|
||||
|
||||
@@ -190,6 +190,36 @@ test("a reply is sent as text and the box is cleared", async () => {
|
||||
assert.equal(posts().length, 1);
|
||||
});
|
||||
|
||||
test("Ctrl+Enter sends a reply; plain Enter only adds a line", async () => {
|
||||
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");
|
||||
const area = q<HTMLTextAreaElement>(".pane-thread textarea")!;
|
||||
const press = (init: KeyboardEventInit) => area.dispatchEvent(new page!.window.KeyboardEvent("keydown", { key: "Enter", bubbles: true, cancelable: true, ...init }));
|
||||
|
||||
area.value = "Hallo";
|
||||
assert.equal(press({}), true, "a plain Enter is left alone, so it adds a line");
|
||||
assert.equal(press({ shiftKey: true }), true);
|
||||
await new Promise((r) => setTimeout(r, 50));
|
||||
assert.equal(posts().length, 0, "nothing sent without Ctrl");
|
||||
assert.match(area.placeholder, /Ctrl\+Enter/);
|
||||
|
||||
assert.equal(press({ ctrlKey: true }), false, "Ctrl+Enter is handled");
|
||||
await page!.waitFor(() => posts().length === 1, "the reply");
|
||||
assert.deepEqual(JSON.parse(posts()[0]!.body), { type: "text", text: "Hallo" });
|
||||
await page!.waitFor(() => area.value === "", "the box to clear");
|
||||
|
||||
area.value = "Von einem Mac";
|
||||
press({ metaKey: true });
|
||||
await page!.waitFor(() => posts().length === 2, "Cmd+Enter works too");
|
||||
|
||||
area.value = "";
|
||||
press({ ctrlKey: true });
|
||||
await new Promise((r) => setTimeout(r, 50));
|
||||
assert.equal(posts().length, 2, "an empty box sends nothing");
|
||||
});
|
||||
|
||||
test("releasing the address: prefilled sheet, signed grant request, closes", async () => {
|
||||
open(`#/login/${TOKEN}`);
|
||||
await page!.waitFor(() => qa(".pane-listings .ocard").length === 2, "the listings");
|
||||
|
||||
Reference in New Issue
Block a user