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);
|
2023-10-11 19:08:42 +02:00
|
|
|
await page.click("#left-sidebar-navigation-list .top_left_all_messages");
|
2020-09-20 10:14:24 +02:00
|
|
|
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});
|
|
|
|
|
2023-05-07 14:45:04 +02:00
|
|
|
await common.select_stream_in_compose_via_dropdown(page, "Verona");
|
2023-03-20 04:22:58 +01:00
|
|
|
await common.select_item_via_typeahead(
|
|
|
|
page,
|
|
|
|
"#stream_message_recipient_topic",
|
|
|
|
"Test mention all",
|
|
|
|
"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});
|
2023-05-15 21:58:45 +02:00
|
|
|
await page.click("#compose_banners .wildcard_warning .main-view-banner-action-button");
|
2022-08-20 21:07:32 +02:00
|
|
|
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);
|