2021-03-27 04:40:48 +01:00
|
|
|
import {strict as assert} from "assert";
|
|
|
|
|
2022-09-12 01:20:51 +02:00
|
|
|
import type {Page} from "puppeteer";
|
2020-08-16 12:28:10 +02:00
|
|
|
|
2023-02-22 23:04:11 +01:00
|
|
|
import * as common from "./lib/common";
|
2020-08-16 12:28:10 +02:00
|
|
|
|
2021-03-27 04:40:48 +01:00
|
|
|
async function click_delete_and_return_last_msg_id(page: Page): Promise<string> {
|
2022-09-12 01:20:51 +02:00
|
|
|
const msg = (await page.$$("#zhome .message_row")).at(-1);
|
|
|
|
assert.ok(msg !== undefined);
|
2021-03-27 04:40:48 +01:00
|
|
|
const id = await (await msg.getProperty("id")).jsonValue();
|
|
|
|
await msg.hover();
|
|
|
|
const info = await page.waitForSelector(
|
|
|
|
`#${CSS.escape(id)} .message_control_button.actions_hover`,
|
|
|
|
{visible: true},
|
|
|
|
);
|
|
|
|
assert.ok(info !== null);
|
|
|
|
await info.click();
|
|
|
|
await page.waitForSelector(".delete_message", {visible: true});
|
|
|
|
await page.click(".delete_message");
|
|
|
|
return 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});
|
2021-03-27 04:40:48 +01:00
|
|
|
const messages_quantity = (await page.$$("#zhome .message_row")).length;
|
2020-08-16 12:28:10 +02:00
|
|
|
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(() => {
|
2023-04-19 23:48:44 +02:00
|
|
|
document.querySelector<HTMLButtonElement>(".dialog_submit_button")?.click();
|
2021-07-04 08:47:08 +02:00
|
|
|
});
|
|
|
|
await common.wait_for_micromodal_to_close(page);
|
2020-08-16 12:28:10 +02:00
|
|
|
|
2021-03-27 04:40:48 +01:00
|
|
|
await page.waitForSelector(`#${CSS.escape(last_message_id)}`, {hidden: true});
|
|
|
|
assert.equal((await page.$$("#zhome .message_row")).length, messages_quantity - 1);
|
2020-08-16 12:28:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
common.run_test(delete_message_test);
|