2021-02-20 05:52:06 +01:00
|
|
|
import {strict as assert} from "assert";
|
2020-08-09 14:02:38 +02:00
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
import type {Page} from "puppeteer";
|
2020-08-09 14:02:38 +02:00
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
import common from "../puppeteer_lib/common";
|
2020-08-09 14:02:38 +02:00
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
async function test_mention(page: Page): Promise<void> {
|
2020-08-09 14:02:38 +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-09 14:02:38 +02:00
|
|
|
await page.keyboard.press("KeyC");
|
|
|
|
await page.waitForSelector("#compose", {visible: true});
|
|
|
|
|
|
|
|
await common.fill_form(page, 'form[action^="/json/messages"]', {
|
|
|
|
stream_message_recipient_stream: "Verona",
|
|
|
|
stream_message_recipient_topic: "Test mention all",
|
|
|
|
});
|
2021-03-13 03:39:22 +01:00
|
|
|
await common.select_item_via_typeahead(page, "#compose-textarea", "@**all", "all");
|
2020-08-09 14:02:38 +02:00
|
|
|
await common.ensure_enter_does_not_send(page);
|
|
|
|
|
|
|
|
console.log("Checking for all everyone warning");
|
2021-03-01 23:33:52 +01:00
|
|
|
const stream_size = await page.evaluate(() =>
|
|
|
|
zulip_test.get_subscriber_count(zulip_test.get_sub("Verona").stream_id),
|
|
|
|
);
|
2020-08-09 14:02:38 +02:00
|
|
|
const threshold = await page.evaluate(() => {
|
2021-03-01 23:33:52 +01:00
|
|
|
zulip_test.set_wildcard_mention_large_stream_threshold(5);
|
|
|
|
return zulip_test.wildcard_mention_large_stream_threshold;
|
2020-08-09 14:02:38 +02:00
|
|
|
});
|
|
|
|
assert(stream_size > threshold);
|
|
|
|
await page.click("#compose-send-button");
|
|
|
|
|
2021-03-12 23:13:45 +01:00
|
|
|
await page.waitForXPath(
|
|
|
|
'//*[@class="compose-all-everyone-msg" and contains(text(), "Are you sure you want to mention all")]',
|
2020-08-09 14:02:38 +02:00
|
|
|
);
|
|
|
|
await page.click(".compose-all-everyone-confirm");
|
|
|
|
await page.waitForSelector(".compose-all-everyone-msg", {hidden: true});
|
|
|
|
await page.waitForSelector("#compose-send-status", {hidden: true});
|
|
|
|
|
|
|
|
await common.check_messages_sent(page, "zhome", [["Verona > Test mention all", ["@all"]]]);
|
|
|
|
}
|
|
|
|
|
|
|
|
common.run_test(test_mention);
|