Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

puppeteer_test: Transform jQuery to puppeteer functions for Firefox.

Riken Shah5e98f80dc3e2
diff --git a/frontend_tests/puppeteer_lib/common.ts b/frontend_tests/puppeteer_lib/common.ts
index d29a5e9dd5b..acf211b83a3 100644
--- a/frontend_tests/puppeteer_lib/common.ts
+++ b/frontend_tests/puppeteer_lib/common.ts
@@ -104,6 +104,14 @@ class CommonUtils {
return await page.evaluate("location.href");
}
+ // This function will clear the existing value of the element and
+ // replace it with the text.
+ async clear_and_type(page: Page, selector: string, text: string): Promise<void> {
+ // Select all text currently in the element.
+ await page.click(selector, {clickCount: 3});
+ await page.type(selector, text);
+ }
+
/**
* This function takes a params object whose fields
* are referenced by name attribute of an input field and
diff --git a/frontend_tests/puppeteer_tests/02-message-basics.ts b/frontend_tests/puppeteer_tests/02-message-basics.ts
index f0039ad3eda..f0090139cfd 100644
--- a/frontend_tests/puppeteer_tests/02-message-basics.ts
+++ b/frontend_tests/puppeteer_tests/02-message-basics.ts
@@ -316,9 +316,7 @@ async function test_stream_search_filters_stream_list(page: Page): Promise<void>
await page.waitForSelector(await get_stream_li(page, "Verona"), {visible: true});
// Enter the search box and test highlighted suggestion
- await page.evaluate(() =>
- $(".stream-list-filter").expectOne().trigger("focus").trigger("click"),
- );
+ await page.click(".stream-list-filter");
await page.waitForSelector("#stream_filters .highlighted_stream", {visible: true});
// First stream in list gets highlihted on clicking search.
@@ -351,9 +349,8 @@ async function test_stream_search_filters_stream_list(page: Page): Promise<void>
await test_search_venice(page);
// Search for brginning of "Verona".
- await page.evaluate(() =>
- $(".stream-list-filter").expectOne().trigger("focus").val("ver").trigger("input"),
- );
+ await page.click("#streams_header .sidebar-title");
+ await page.type(".stream-list-filter", "ver");
await page.waitForSelector(await get_stream_li(page, "Denmark"), {hidden: true});
await page.click(await get_stream_li(page, "Verona"));
await expect_verona_stream(page);
@@ -393,7 +390,7 @@ async function test_users_search(page: Page): Promise<void> {
await assert_in_list(page, "aaron");
// Enter the search box and test selected suggestion navigation
- await page.evaluate(() => $("#user_filter_icon").expectOne().trigger("focus").trigger("click"));
+ await page.click("#user_filter_icon");
await page.waitForSelector("#user_presences .highlighted_user", {visible: true});
await assert_selected(page, "Desdemona");
await assert_not_selected(page, "Cordelia Lear");
diff --git a/frontend_tests/puppeteer_tests/06-edit.ts b/frontend_tests/puppeteer_tests/06-edit.ts
index 6f9fb15a921..5020911b4bf 100644
--- a/frontend_tests/puppeteer_tests/06-edit.ts
+++ b/frontend_tests/puppeteer_tests/06-edit.ts
@@ -14,11 +14,8 @@ async function trigger_edit_last_message(page: Page): Promise<void> {
async function edit_stream_message(page: Page, topic: string, content: string): Promise<void> {
await trigger_edit_last_message(page);
- await page.evaluate(() => $(".message_edit_topic").val(""));
- await page.evaluate(() => $(".message_edit_content").val(""));
-
- await page.type(".message_edit_topic", topic);
- await page.type(".message_edit_content", content);
+ await common.clear_and_type(page, ".message_edit_topic", topic);
+ await common.clear_and_type(page, ".message_edit_content", content);
await page.click(".message_edit_save");
await common.wait_for_fully_processed_message(page, content);
@@ -66,8 +63,7 @@ async function test_edit_private_message(page: Page): Promise<void> {
});
await trigger_edit_last_message(page);
- await page.evaluate(() => $(".message_edit_content").val(""));
- await page.type(".message_edit_content", "test edited pm");
+ await common.clear_and_type(page, ".message_edit_content", "test edited pm");
await page.click(".message_edit_save");
await common.wait_for_fully_processed_message(page, "test edited pm");