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_tests: Remove buggy assert_selector_doesnt_exist helper.

Anders Kaseorg72142273c0a2
diff --git a/frontend_tests/puppeteer_lib/common.js b/frontend_tests/puppeteer_lib/common.js
index d09bde6ee3f..cdf6f8829f6 100644
--- a/frontend_tests/puppeteer_lib/common.js
+++ b/frontend_tests/puppeteer_lib/common.js
@@ -92,10 +92,6 @@ class CommonUtils {
});
}
- async assert_selector_doesnt_exist(page, selector) {
- await page.waitForFunction((selector) => $(selector === null), {}, selector);
- }
-
/**
* 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.js b/frontend_tests/puppeteer_tests/02-message-basics.js
index 789b9ba0bda..3e391cf4106 100644
--- a/frontend_tests/puppeteer_tests/02-message-basics.js
+++ b/frontend_tests/puppeteer_tests/02-message-basics.js
@@ -351,16 +351,14 @@ async function test_users_search(page) {
async function assert_selected(page, name) {
await page.waitForSelector(
`#user_presences li.highlighted_user [data-name="${CSS.escape(name)}"]`,
- {
- visible: true,
- },
+ {visible: true},
);
}
async function assert_not_selected(page, name) {
- await common.assert_selector_doesnt_exist(
- page,
+ await page.waitForSelector(
`#user_presences li.highlighted_user [data-name="${CSS.escape(name)}"]`,
+ {hidden: true},
);
}
diff --git a/frontend_tests/puppeteer_tests/12-drafts.js b/frontend_tests/puppeteer_tests/12-drafts.js
index 389d4d74571..f634f27cf7a 100644
--- a/frontend_tests/puppeteer_tests/12-drafts.js
+++ b/frontend_tests/puppeteer_tests/12-drafts.js
@@ -188,7 +188,7 @@ async function test_delete_draft(page) {
await page.click("#drafts_table .message_row.private-message .delete-draft");
const drafts_count = await get_drafts_count(page);
assert.strictEqual(drafts_count, 1, "Draft not deleted.");
- await common.assert_selector_doesnt_exist(page, "#drafts_table .message_row.private-message");
+ await page.waitForSelector("#drafts_table .message_row.private-message", {hidden: true});
await page.click(`${drafts_overlay} .exit`);
await wait_for_drafts_to_dissapear(page);
await page.click("body");
@@ -242,7 +242,7 @@ async function test_delete_draft_on_sending(page) {
await wait_for_drafts_to_appear(page);
const drafts_count = await get_drafts_count(page);
assert.strictEqual(drafts_count, 1, "Draft wasn't cleared on sending.");
- await common.assert_selector_doesnt_exist(page, "#drafts_table .message_row.private-message");
+ await page.waitForSelector("#drafts_table .message_row.private-message", {hidden: true});
}
async function drafts_test(page) {
diff --git a/frontend_tests/puppeteer_tests/13-delete-message.js b/frontend_tests/puppeteer_tests/13-delete-message.js
index dec0e7baa35..799d5e2bb3a 100644
--- a/frontend_tests/puppeteer_tests/13-delete-message.js
+++ b/frontend_tests/puppeteer_tests/13-delete-message.js
@@ -29,7 +29,7 @@ async function delete_message_test(page) {
messages_quantitiy - 1,
);
- await common.assert_selector_doesnt_exist(page, last_message_id);
+ await page.waitForSelector(last_message_id, {hidden: true});
await page.waitForSelector("#do_delete_message_spinner .loading_indicator_spinner", {
hidden: true,
});
diff --git a/frontend_tests/puppeteer_tests/16-settings.js b/frontend_tests/puppeteer_tests/16-settings.js
index f0406c7f6ba..acffd323f62 100644
--- a/frontend_tests/puppeteer_tests/16-settings.js
+++ b/frontend_tests/puppeteer_tests/16-settings.js
@@ -219,7 +219,7 @@ async function test_duplicate_alert_words_cannot_be_added(page, duplicate_word)
async function delete_alert_word(page, word) {
const delete_btn_selector = `.remove-alert-word[data-word="${CSS.escape(word)}"]`;
await page.click(delete_btn_selector);
- await common.assert_selector_doesnt_exist(page, delete_btn_selector);
+ await page.waitForSelector(delete_btn_selector, {hidden: true});
}
async function test_alert_word_deletion(page, word) {