mirror of
https://github.com/zulip/zulip.git
synced 2025-11-16 20:02:15 +00:00
Also added a waitFor for the modal to disappear and removed waitFor for the spinner to hide which would obviously be hidden with modal and it also doesn't add much value.
39 lines
1.4 KiB
TypeScript
39 lines
1.4 KiB
TypeScript
import type {Page} from "puppeteer";
|
|
|
|
import common from "../puppeteer_lib/common";
|
|
|
|
async function click_delete_and_return_last_msg_id(page: Page): Promise<string | undefined> {
|
|
return await page.evaluate(() => {
|
|
const msg = $("#zhome .message_row").last();
|
|
msg.find(".message_control_button.actions_hover").trigger("click");
|
|
$(".delete_message").trigger("click");
|
|
return msg.attr("id");
|
|
});
|
|
}
|
|
|
|
async function delete_message_test(page: Page): Promise<void> {
|
|
await common.log_in(page);
|
|
await page.click(".top_left_all_messages");
|
|
await page.waitForSelector("#zhome .message_row", {visible: true});
|
|
const messages_quantitiy = await page.evaluate(() => $("#zhome .message_row").length);
|
|
const last_message_id = await click_delete_and_return_last_msg_id(page);
|
|
|
|
await page.waitForSelector("#dialog_widget_modal", {visible: true});
|
|
await page.click(".dialog_submit_button");
|
|
|
|
const confirm_span = ".dialog_submit_button span";
|
|
await page.waitForSelector(confirm_span, {hidden: true});
|
|
|
|
await page.waitForSelector("#dialog_widget_modal", {hidden: true});
|
|
|
|
await page.waitForFunction(
|
|
(expected_length: number) => $("#zhome .message_row").length === expected_length,
|
|
{},
|
|
messages_quantitiy - 1,
|
|
);
|
|
|
|
await page.waitForSelector(`#${CSS.escape(last_message_id!)}`, {hidden: true});
|
|
}
|
|
|
|
common.run_test(delete_message_test);
|