Files
zulip/frontend_tests/puppeteer_tests/delete-message.ts
Riken Shah f6998d6fee puppeteer_tests: Remove sequential numbers from test files.
The only downside of this is that it makes it harder to control the
order of these tests; which isn't that important.  And the structure
of naming each with its test order fundamentally requires renaming
files when adding/deleting tests, so if we want to control the default
test order, we'd be better off doing that by just hardcoding a list in
the test runner code.
2021-04-01 07:46:13 -07:00

41 lines
1.5 KiB
TypeScript

import type {Page} from "puppeteer";
import common from "../puppeteer_lib/common";
async function click_delete_and_return_last_msg_id(page: Page): Promise<string | undefined> {
return await page.evaluate(() => {
const msg = $("#zhome .message_row").last();
msg.find(".info").trigger("click");
$(".delete_message").trigger("click");
return msg.attr("id");
});
}
async function delete_message_test(page: Page): Promise<void> {
await common.log_in(page);
await page.click(".top_left_all_messages");
await page.waitForSelector("#zhome .message_row", {visible: true});
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(
(expected_length: number) => $("#zhome .message_row").length === expected_length,
{},
messages_quantitiy - 1,
);
await page.waitForSelector(`#${CSS.escape(last_message_id!)}`, {hidden: true});
await page.waitForSelector("#do_delete_message_spinner .loading_indicator_spinner", {
hidden: true,
});
}
common.run_test(delete_message_test);