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(() => {
|
2022-01-25 11:36:19 +01:00
|
|
|
const $msg = $("#zhome .message_row").last();
|
|
|
|
$msg.find(".message_control_button.actions_hover").trigger("click");
|
2020-08-16 12:28:10 +02:00
|
|
|
$(".delete_message").trigger("click");
|
2022-01-25 11:36:19 +01:00
|
|
|
return $msg.attr("id");
|
2020-08-16 12:28:10 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
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-04 08:47:08 +02:00
|
|
|
await common.wait_for_micromodal_to_open(page);
|
|
|
|
await page.evaluate(() => {
|
|
|
|
(document.querySelector(".dialog_submit_button") as HTMLButtonElement)?.click();
|
|
|
|
});
|
|
|
|
await common.wait_for_micromodal_to_close(page);
|
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});
|
2020-08-16 12:28:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
common.run_test(delete_message_test);
|