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);
|
|
|
|
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("#delete_message_modal", {visible: true});
|
|
|
|
await page.click("#do_delete_message_button");
|
|
|
|
await page.waitForSelector("#do_delete_message_spinner .loading_indicator_spinner", {
|
|
|
|
visible: true,
|
|
|
|
});
|
|
|
|
await page.waitForSelector("#do_delete_message_button", {hidden: true});
|
|
|
|
|
|
|
|
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
|
|
|
await page.waitForSelector("#do_delete_message_spinner .loading_indicator_spinner", {
|
|
|
|
hidden: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
common.run_test(delete_message_test);
|