From ca6b0d8c5a154863275be9975c1536145b2577ba Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Wed, 19 Apr 2023 16:01:42 -0700 Subject: [PATCH] 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 Signed-off-by: Anders Kaseorg --- web/e2e-tests/lib/common.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/web/e2e-tests/lib/common.ts b/web/e2e-tests/lib/common.ts index 6fd1fbc161..668223aef1 100644 --- a/web/e2e-tests/lib/common.ts +++ b/web/e2e-tests/lib/common.ts @@ -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 { - let enter_sends = false; - await page.$eval(".enter_sends_false", (el) => { - if ((el as HTMLElement).style.display !== "none") { - enter_sends = true; - } - }); + // NOTE: Caller should ensure that the compose box is already open. + const enter_sends = await page.$eval( + ".enter_sends_true", + (el) => (el as HTMLElement).style.display !== "none", + ); if (enter_sends) { + await page.click(".open_enter_sends_dialog"); const enter_sends_false_selector = ".enter_sends_choice input[value='false']"; await page.waitForSelector(enter_sends_false_selector); await page.click(enter_sends_false_selector);