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();
|
|
|
|
msg.find(".info").trigger("click");
|
|
|
|
$(".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-05-09 11:19:58 +02:00
|
|
|
await page.waitForSelector("#confirm_dialog_modal", {visible: true});
|
|
|
|
await page.click(".confirm_dialog_yes_button");
|
|
|
|
await page.waitForSelector("#confirm_dialog_spinner .loading_indicator_spinner", {
|
2020-08-16 12:28:10 +02:00
|
|
|
visible: true,
|
|
|
|
});
|
2021-05-09 11:19:58 +02:00
|
|
|
await page.waitForSelector(".confirm_dialog_yes_button", {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-05-09 11:19:58 +02:00
|
|
|
await page.waitForSelector("#confirm_dialog_spinner .loading_indicator_spinner", {
|
2020-08-16 12:28:10 +02:00
|
|
|
hidden: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
common.run_test(delete_message_test);
|