e2e-tests: Fix ensure_enter_does_not_send.

A variable in the Node.js context cannot be mutated by a function
evaluated in the browser context.  The boolean was also incorrectly
inverted, and a click to open the dialog containing
`enter_sends_choice` was missing.

Co-authored-by: Aman Agrawal <amanagr@zulip.com>
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2023-04-19 16:01:42 -07:00 committed by Anders Kaseorg
parent ae7a21834e
commit ca6b0d8c5a
1 changed files with 6 additions and 6 deletions

View File

@ -290,14 +290,14 @@ export function set_realm_url(new_realm_url: string): void {
} }
export async function ensure_enter_does_not_send(page: Page): Promise<void> { export async function ensure_enter_does_not_send(page: Page): Promise<void> {
let enter_sends = false; // NOTE: Caller should ensure that the compose box is already open.
await page.$eval(".enter_sends_false", (el) => { const enter_sends = await page.$eval(
if ((el as HTMLElement).style.display !== "none") { ".enter_sends_true",
enter_sends = true; (el) => (el as HTMLElement).style.display !== "none",
} );
});
if (enter_sends) { if (enter_sends) {
await page.click(".open_enter_sends_dialog");
const enter_sends_false_selector = ".enter_sends_choice input[value='false']"; const enter_sends_false_selector = ".enter_sends_choice input[value='false']";
await page.waitForSelector(enter_sends_false_selector); await page.waitForSelector(enter_sends_false_selector);
await page.click(enter_sends_false_selector); await page.click(enter_sends_false_selector);