2021-02-20 05:52:06 +01:00
|
|
|
import type {Page} from "puppeteer";
|
2020-08-16 12:28:10 +02:00
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
import common from "../puppeteer_lib/common";
|
2020-08-16 12:28:10 +02:00
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
async function click_delete_and_return_last_msg_id(page: Page): Promise<string | undefined> {
|
2020-08-16 12:28:10 +02:00
|
|
|
return await page.evaluate(() => {
|
|
|
|
const msg = $("#zhome .message_row").last();
|
2021-06-12 03:07:47 +02:00
|
|
|
msg.find(".message_control_button.actions_hover").trigger("click");
|
2020-08-16 12:28:10 +02:00
|
|
|
$(".delete_message").trigger("click");
|
|
|
|
return msg.attr("id");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
async function delete_message_test(page: Page): Promise<void> {
|
2020-08-16 12:28:10 +02:00
|
|
|
await common.log_in(page);
|
2020-09-20 10:14:24 +02:00
|
|
|
await page.click(".top_left_all_messages");
|
|
|
|
await page.waitForSelector("#zhome .message_row", {visible: true});
|
2020-08-16 12:28:10 +02:00
|
|
|
const messages_quantitiy = await page.evaluate(() => $("#zhome .message_row").length);
|
|
|
|
const last_message_id = await click_delete_and_return_last_msg_id(page);
|
|
|
|
|
2021-07-05 12:41:37 +02:00
|
|
|
await page.waitForSelector("#dialog_widget_modal", {visible: true});
|
|
|
|
await page.click(".dialog_submit_button");
|
|
|
|
await page.waitForSelector(".dialog_submit_button .loader", {
|
2020-08-16 12:28:10 +02:00
|
|
|
visible: true,
|
|
|
|
});
|
2021-07-05 12:41:37 +02:00
|
|
|
await page.waitForSelector(".dialog_submit_button span", {hidden: true});
|
2020-08-16 12:28:10 +02:00
|
|
|
|
|
|
|
await page.waitForFunction(
|
2021-02-20 05:52:06 +01:00
|
|
|
(expected_length: number) => $("#zhome .message_row").length === expected_length,
|
2020-08-16 12:28:10 +02:00
|
|
|
{},
|
|
|
|
messages_quantitiy - 1,
|
|
|
|
);
|
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
await page.waitForSelector(`#${CSS.escape(last_message_id!)}`, {hidden: true});
|
2021-07-05 12:41:37 +02:00
|
|
|
await page.waitForSelector(".dialog_submit_button .loader", {
|
2020-08-16 12:28:10 +02:00
|
|
|
hidden: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
common.run_test(delete_message_test);
|