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
|
|
|
|
2023-02-22 23:04:11 +01:00
|
|
|
import * as common from "./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
|
|
|
});
|
2021-06-10 08:32:54 +02:00
|
|
|
assert.ok(stream_size > threshold);
|
2020-08-09 14:02:38 +02:00
|
|
|
await page.click("#compose-send-button");
|
|
|
|
|
2022-08-20 21:07:32 +02:00
|
|
|
await page.waitForSelector("#compose_banners .wildcard_warning", {visible: true});
|
|
|
|
await page.click("#compose_banners .wildcard_warning .compose_banner_action_button");
|
|
|
|
await page.waitForSelector(".wildcard_warning", {hidden: true});
|
2020-08-09 14:02:38 +02:00
|
|
|
|
|
|
|
await common.check_messages_sent(page, "zhome", [["Verona > Test mention all", ["@all"]]]);
|
|
|
|
}
|
|
|
|
|
|
|
|
common.run_test(test_mention);
|