Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
puppeteer: Check compose form contents in a new distinct function.
evykassirer56c9b4f8c1c8
diff --git a/frontend_tests/puppeteer_lib/common.ts b/frontend_tests/puppeteer_lib/common.tsindex e83eec43ba4..44685b72ec1 100644--- a/frontend_tests/puppeteer_lib/common.ts+++ b/frontend_tests/puppeteer_lib/common.ts@@ -186,6 +186,20 @@ export async function check_form_contents(}}+export async function check_compose_state(+ page: Page,+ params: Record<string, string>,+): Promise<void> {+ const form_params: Record<string, string> = {content: params.content};+ if (params.stream) {+ form_params.stream_message_recipient_stream = params.stream;+ }+ if (params.topic) {+ form_params.stream_message_recipient_topic = params.topic;+ }+ await check_form_contents(page, "form#send_message_form", form_params);+}+export function has_class_x(class_name: string): string {return `contains(concat(" ", @class, " "), " ${class_name} ")`;}diff --git a/frontend_tests/puppeteer_tests/compose.ts b/frontend_tests/puppeteer_tests/compose.tsindex 00e6a6d3b53..0e777755801 100644--- a/frontend_tests/puppeteer_tests/compose.ts+++ b/frontend_tests/puppeteer_tests/compose.ts@@ -5,9 +5,9 @@ import type {Page} from "puppeteer";import * as common from "../puppeteer_lib/common";async function check_compose_form_empty(page: Page): Promise<void> {- await common.check_form_contents(page, "#send_message_form", {- stream_message_recipient_stream: "",- stream_message_recipient_topic: "",+ await common.check_compose_state(page, {+ stream: "",+ topic: "",content: "",});}@@ -57,9 +57,9 @@ async function test_reply_by_click_prepopulates_stream_topic_names(page: Page):assert.ok(stream_message !== null);// we chose only the last element make sure we don't click on any duplicates.await stream_message.click();- await common.check_form_contents(page, "#send_message_form", {- stream_message_recipient_stream: "Verona",- stream_message_recipient_topic: "Reply test",+ await common.check_compose_state(page, {+ stream: "Verona",+ topic: "Reply test",content: "",});await close_compose_box(page);@@ -86,9 +86,9 @@ async function test_reply_with_r_shortcut(page: Page): Promise<void> {// Now we go up and open compose box with r key.await page.keyboard.press("KeyK");await page.keyboard.press("KeyR");- await common.check_form_contents(page, "#send_message_form", {- stream_message_recipient_stream: "Verona",- stream_message_recipient_topic: "Reply test",+ await common.check_compose_state(page, {+ stream: "Verona",+ topic: "Reply test",content: "",});}diff --git a/frontend_tests/puppeteer_tests/drafts.ts b/frontend_tests/puppeteer_tests/drafts.tsindex 6c7fb21d8e8..df5859e64c3 100644--- a/frontend_tests/puppeteer_tests/drafts.ts+++ b/frontend_tests/puppeteer_tests/drafts.ts@@ -116,9 +116,9 @@ async function test_restore_message_draft_via_draft_overlay(page: Page): Promiseawait wait_for_drafts_to_disappear(page);await page.waitForSelector("#stream-message", {visible: true});await page.waitForSelector("#preview_message_area", {hidden: true});- await common.check_form_contents(page, "form#send_message_form", {- stream_message_recipient_stream: "Denmark",- stream_message_recipient_topic: "tests",+ await common.check_compose_state(page, {+ stream: "Denmark",+ topic: "tests",content: "Test stream message.",});assert.strictEqual(@@ -170,7 +170,7 @@ async function test_restore_private_message_draft_via_draft_overlay(page: Page):await page.click(".message_row.private-message .restore-draft");await wait_for_drafts_to_disappear(page);await page.waitForSelector("#private-message", {visible: true});- await common.check_form_contents(page, "form#send_message_form", {+ await common.check_compose_state(page, {content: "Test private message.",});const cordelia_internal_email = await common.get_internal_email_from_name(page, "cordelia");