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:
@@ -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