2021-02-20 05:52:06 +01:00
|
|
|
import {strict as assert} from "assert";
|
2020-08-01 03:43:15 +02:00
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
import type {Page} from "puppeteer";
|
2020-08-27 21:09:54 +02:00
|
|
|
|
2023-02-22 23:04:11 +01:00
|
|
|
import * as common from "./lib/common";
|
2020-06-12 17:57:02 +02:00
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
async function get_stream_li(page: Page, stream_name: string): Promise<string> {
|
2020-08-27 21:09:54 +02:00
|
|
|
const stream_id = await common.get_stream_id(page, stream_name);
|
2024-05-04 00:31:56 +02:00
|
|
|
assert(stream_id !== undefined);
|
2021-02-20 05:52:06 +01:00
|
|
|
return `#stream_filters [data-stream-id="${CSS.escape(stream_id.toString())}"]`;
|
2020-08-27 21:09:54 +02:00
|
|
|
}
|
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
async function expect_home(page: Page): Promise<void> {
|
2024-01-17 07:53:40 +01:00
|
|
|
const message_list_id = await common.get_current_msg_list_id(page, true);
|
2024-04-21 05:31:35 +02:00
|
|
|
await page.waitForSelector(`.message-list[data-message-list-id='${message_list_id}']`, {
|
|
|
|
visible: true,
|
|
|
|
});
|
|
|
|
// Assert that there is only one message list.
|
|
|
|
assert.equal((await page.$$(".message-list")).length, 1);
|
|
|
|
assert.strictEqual(await page.title(), "Combined feed - Zulip Dev - Zulip");
|
2024-01-17 07:53:40 +01:00
|
|
|
await common.check_messages_sent(page, message_list_id, [
|
2020-08-27 21:09:54 +02:00
|
|
|
["Verona > test", ["verona test a", "verona test b"]],
|
|
|
|
["Verona > other topic", ["verona other topic c"]],
|
|
|
|
["Denmark > test", ["denmark message"]],
|
2023-04-11 21:04:33 +02:00
|
|
|
[
|
|
|
|
"You and Cordelia, Lear's daughter, King Hamlet",
|
|
|
|
["group direct message a", "group direct message b"],
|
|
|
|
],
|
|
|
|
["You and Cordelia, Lear's daughter", ["direct message c"]],
|
2020-08-27 21:09:54 +02:00
|
|
|
["Verona > test", ["verona test d"]],
|
2023-04-11 21:04:33 +02:00
|
|
|
["You and Cordelia, Lear's daughter, King Hamlet", ["group direct message d"]],
|
|
|
|
["You and Cordelia, Lear's daughter", ["direct message e"]],
|
2020-08-27 21:09:54 +02:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
async function expect_verona_stream(page: Page): Promise<void> {
|
2024-01-17 07:53:40 +01:00
|
|
|
const message_list_id = await common.get_current_msg_list_id(page, true);
|
|
|
|
await page.waitForSelector(`.message-list[data-message-list-id='${message_list_id}']`, {
|
|
|
|
visible: true,
|
|
|
|
});
|
|
|
|
await common.check_messages_sent(page, message_list_id, [
|
2020-08-27 21:09:54 +02:00
|
|
|
["Verona > test", ["verona test a", "verona test b"]],
|
|
|
|
["Verona > other topic", ["verona other topic c"]],
|
|
|
|
["Verona > test", ["verona test d"]],
|
|
|
|
]);
|
2022-10-07 18:14:08 +02:00
|
|
|
assert.strictEqual(await page.title(), "#Verona - Zulip Dev - Zulip");
|
2020-08-27 21:09:54 +02:00
|
|
|
}
|
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
async function expect_verona_stream_test_topic(page: Page): Promise<void> {
|
2024-01-17 07:53:40 +01:00
|
|
|
const message_list_id = await common.get_current_msg_list_id(page, true);
|
|
|
|
await page.waitForSelector(`.message-list[data-message-list-id='${message_list_id}']`, {
|
|
|
|
visible: true,
|
|
|
|
});
|
|
|
|
await common.check_messages_sent(page, message_list_id, [
|
2020-08-27 21:09:54 +02:00
|
|
|
["Verona > test", ["verona test a", "verona test b", "verona test d"]],
|
|
|
|
]);
|
|
|
|
assert.strictEqual(
|
2023-10-04 16:11:48 +02:00
|
|
|
await common.get_text_from_selector(page, "#new_conversation_button"),
|
|
|
|
"Start new conversation",
|
2020-08-27 21:09:54 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
async function expect_verona_other_topic(page: Page): Promise<void> {
|
2024-01-17 07:53:40 +01:00
|
|
|
const message_list_id = await common.get_current_msg_list_id(page, true);
|
|
|
|
await page.waitForSelector(`.message-list[data-message-list-id='${message_list_id}']`, {
|
|
|
|
visible: true,
|
|
|
|
});
|
|
|
|
await common.check_messages_sent(page, message_list_id, [
|
2020-08-27 21:09:54 +02:00
|
|
|
["Verona > other topic", ["verona other topic c"]],
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
async function expect_test_topic(page: Page): Promise<void> {
|
2024-01-17 07:53:40 +01:00
|
|
|
const message_list_id = await common.get_current_msg_list_id(page, true);
|
|
|
|
await page.waitForSelector(`.message-list[data-message-list-id='${message_list_id}']`, {
|
|
|
|
visible: true,
|
|
|
|
});
|
|
|
|
await common.check_messages_sent(page, message_list_id, [
|
2020-08-27 21:09:54 +02:00
|
|
|
["Verona > test", ["verona test a", "verona test b"]],
|
|
|
|
["Denmark > test", ["denmark message"]],
|
|
|
|
["Verona > test", ["verona test d"]],
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2023-04-11 21:04:33 +02:00
|
|
|
async function expect_group_direct_messages(page: Page): Promise<void> {
|
2024-01-17 07:53:40 +01:00
|
|
|
const message_list_id = await common.get_current_msg_list_id(page, true);
|
|
|
|
await page.waitForSelector(`.message-list[data-message-list-id='${message_list_id}']`, {
|
|
|
|
visible: true,
|
|
|
|
});
|
|
|
|
await common.check_messages_sent(page, message_list_id, [
|
2021-04-11 16:26:54 +02:00
|
|
|
[
|
|
|
|
"You and Cordelia, Lear's daughter, King Hamlet",
|
2023-04-11 21:04:33 +02:00
|
|
|
["group direct message a", "group direct message b", "group direct message d"],
|
2021-04-11 16:26:54 +02:00
|
|
|
],
|
2020-08-27 21:09:54 +02:00
|
|
|
]);
|
2021-04-11 16:26:54 +02:00
|
|
|
assert.strictEqual(
|
|
|
|
await page.title(),
|
|
|
|
"Cordelia, Lear's daughter, King Hamlet - Zulip Dev - Zulip",
|
|
|
|
);
|
2020-08-27 21:09:54 +02:00
|
|
|
}
|
|
|
|
|
2023-04-11 21:04:33 +02:00
|
|
|
async function expect_cordelia_direct_messages(page: Page): Promise<void> {
|
2024-01-17 07:53:40 +01:00
|
|
|
const message_list_id = await common.get_current_msg_list_id(page, true);
|
|
|
|
await page.waitForSelector(`.message-list[data-message-list-id='${message_list_id}']`, {
|
|
|
|
visible: true,
|
|
|
|
});
|
|
|
|
await common.check_messages_sent(page, message_list_id, [
|
2023-04-11 21:04:33 +02:00
|
|
|
["You and Cordelia, Lear's daughter", ["direct message c", "direct message e"]],
|
2021-04-11 16:26:54 +02:00
|
|
|
]);
|
2020-08-27 21:09:54 +02:00
|
|
|
}
|
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
async function un_narrow(page: Page): Promise<void> {
|
2021-03-27 04:40:48 +01:00
|
|
|
if ((await (await page.$(".message_comp"))!.boundingBox())?.height) {
|
2020-08-27 21:09:54 +02:00
|
|
|
await page.keyboard.press("Escape");
|
|
|
|
}
|
2023-10-11 19:08:42 +02:00
|
|
|
await page.click("#left-sidebar-navigation-list .top_left_all_messages");
|
2020-08-27 21:09:54 +02:00
|
|
|
}
|
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
async function un_narrow_by_clicking_org_icon(page: Page): Promise<void> {
|
2020-08-27 21:09:54 +02:00
|
|
|
await page.click(".brand");
|
|
|
|
}
|
|
|
|
|
2023-09-07 00:08:09 +02:00
|
|
|
async function expect_recent_view(page: Page): Promise<void> {
|
2023-09-06 23:38:15 +02:00
|
|
|
await page.waitForSelector("#recent_view_table", {visible: true});
|
2022-10-12 19:54:34 +02:00
|
|
|
assert.strictEqual(await page.title(), "Recent conversations - Zulip Dev - Zulip");
|
2021-02-19 09:18:16 +01:00
|
|
|
}
|
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
async function test_navigations_from_home(page: Page): Promise<void> {
|
2022-12-19 09:16:05 +01:00
|
|
|
return; // No idea why this is broken.
|
2020-08-27 21:09:54 +02:00
|
|
|
console.log("Narrowing by clicking stream");
|
2024-01-17 07:53:40 +01:00
|
|
|
await page.click(`.focused-message-list [title='Narrow to stream "Verona"']`);
|
2020-08-27 21:09:54 +02:00
|
|
|
await expect_verona_stream(page);
|
|
|
|
|
2022-10-07 18:14:08 +02:00
|
|
|
assert.strictEqual(await page.title(), "#Verona - Zulip Dev - Zulip");
|
2020-08-27 21:09:54 +02:00
|
|
|
await un_narrow(page);
|
|
|
|
await expect_home(page);
|
|
|
|
|
|
|
|
console.log("Narrowing by clicking topic");
|
2024-01-17 07:53:40 +01:00
|
|
|
await page.click(`.focused-message-list [title='Narrow to stream "Verona", topic "test"']`);
|
2020-08-27 21:09:54 +02:00
|
|
|
await expect_verona_stream_test_topic(page);
|
|
|
|
|
2021-02-19 09:18:16 +01:00
|
|
|
await un_narrow(page);
|
2020-08-27 21:09:54 +02:00
|
|
|
await expect_home(page);
|
|
|
|
|
2022-09-13 01:07:17 +02:00
|
|
|
return; // TODO: rest of this test seems nondeterministically broken
|
2020-08-27 21:09:54 +02:00
|
|
|
console.log("Narrowing by clicking group personal header");
|
2021-03-27 04:40:48 +01:00
|
|
|
await page.click(
|
2024-01-17 07:53:40 +01:00
|
|
|
`.focused-message-list [title="Narrow to your direct messages with Cordelia, Lear's daughter, King Hamlet"]`,
|
2020-08-27 21:09:54 +02:00
|
|
|
);
|
2023-04-11 21:04:33 +02:00
|
|
|
await expect_group_direct_messages(page);
|
2020-08-27 21:09:54 +02:00
|
|
|
|
2021-02-19 09:18:16 +01:00
|
|
|
await un_narrow(page);
|
2020-08-27 21:09:54 +02:00
|
|
|
await expect_home(page);
|
2021-02-19 09:18:16 +01:00
|
|
|
|
2021-03-27 04:40:48 +01:00
|
|
|
await page.click(
|
2024-01-17 07:53:40 +01:00
|
|
|
`.focused-message-list [title="Narrow to your direct messages with Cordelia, Lear's daughter, King Hamlet"]`,
|
2021-02-19 09:18:16 +01:00
|
|
|
);
|
|
|
|
await un_narrow_by_clicking_org_icon(page);
|
2023-09-07 00:08:09 +02:00
|
|
|
await expect_recent_view(page);
|
2020-08-27 21:09:54 +02:00
|
|
|
}
|
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
async function search_and_check(
|
|
|
|
page: Page,
|
|
|
|
search_str: string,
|
|
|
|
item_to_select: string,
|
|
|
|
check: (page: Page) => Promise<void>,
|
|
|
|
expected_narrow_title: string,
|
|
|
|
): Promise<void> {
|
2021-03-13 03:39:22 +01:00
|
|
|
await page.click(".search_icon");
|
2022-05-16 19:24:49 +02:00
|
|
|
await page.waitForSelector(".navbar-search.expanded", {visible: true});
|
2020-08-27 21:09:54 +02:00
|
|
|
await common.select_item_via_typeahead(page, "#search_query", search_str, item_to_select);
|
|
|
|
await check(page);
|
|
|
|
assert.strictEqual(await page.title(), expected_narrow_title);
|
|
|
|
await un_narrow(page);
|
|
|
|
await expect_home(page);
|
|
|
|
}
|
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
async function search_silent_user(page: Page, str: string, item: string): Promise<void> {
|
2021-03-13 03:39:22 +01:00
|
|
|
await page.click(".search_icon");
|
2022-05-16 19:24:49 +02:00
|
|
|
await page.waitForSelector(".navbar-search.expanded", {visible: true});
|
2020-08-27 21:09:54 +02:00
|
|
|
await common.select_item_via_typeahead(page, "#search_query", str, item);
|
2021-09-01 18:23:28 +02:00
|
|
|
await page.waitForSelector(".empty_feed_notice", {visible: true});
|
2022-11-04 14:39:50 +01:00
|
|
|
const expect_message = "You haven't received any messages sent by Email Gateway yet.";
|
2021-09-01 18:23:28 +02:00
|
|
|
assert.strictEqual(
|
|
|
|
await common.get_text_from_selector(page, ".empty_feed_notice"),
|
|
|
|
expect_message,
|
|
|
|
);
|
2024-01-17 07:53:40 +01:00
|
|
|
await common.get_current_msg_list_id(page, true);
|
2020-08-27 21:09:54 +02:00
|
|
|
await un_narrow(page);
|
2023-07-03 21:17:46 +02:00
|
|
|
await expect_home(page);
|
2020-08-27 21:09:54 +02:00
|
|
|
}
|
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
async function expect_non_existing_user(page: Page): Promise<void> {
|
2024-01-17 07:53:40 +01:00
|
|
|
await common.get_current_msg_list_id(page, true);
|
2021-09-01 18:23:28 +02:00
|
|
|
await page.waitForSelector(".empty_feed_notice", {visible: true});
|
2020-08-27 21:09:54 +02:00
|
|
|
const expected_message = "This user does not exist!";
|
|
|
|
assert.strictEqual(
|
2021-09-01 18:23:28 +02:00
|
|
|
await common.get_text_from_selector(page, ".empty_feed_notice"),
|
2020-08-27 21:09:54 +02:00
|
|
|
expected_message,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
async function expect_non_existing_users(page: Page): Promise<void> {
|
2024-01-17 07:53:40 +01:00
|
|
|
await common.get_current_msg_list_id(page, true);
|
2021-09-01 18:23:28 +02:00
|
|
|
await page.waitForSelector(".empty_feed_notice", {visible: true});
|
2020-08-27 21:09:54 +02:00
|
|
|
const expected_message = "One or more of these users do not exist!";
|
|
|
|
assert.strictEqual(
|
2021-09-01 18:23:28 +02:00
|
|
|
await common.get_text_from_selector(page, ".empty_feed_notice"),
|
2020-08-27 21:09:54 +02:00
|
|
|
expected_message,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
async function search_non_existing_user(page: Page, str: string, item: string): Promise<void> {
|
2021-03-13 03:39:22 +01:00
|
|
|
await page.click(".search_icon");
|
2022-05-16 19:24:49 +02:00
|
|
|
await page.waitForSelector(".navbar-search.expanded", {visible: true});
|
2020-08-27 21:09:54 +02:00
|
|
|
await common.select_item_via_typeahead(page, "#search_query", str, item);
|
|
|
|
await expect_non_existing_user(page);
|
|
|
|
await un_narrow(page);
|
2023-07-03 21:17:46 +02:00
|
|
|
await expect_home(page);
|
2020-08-27 21:09:54 +02:00
|
|
|
}
|
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
async function search_tests(page: Page): Promise<void> {
|
2020-08-27 21:09:54 +02:00
|
|
|
await search_and_check(
|
|
|
|
page,
|
|
|
|
"Verona",
|
2024-04-23 21:51:34 +02:00
|
|
|
"Channel",
|
2020-08-27 21:09:54 +02:00
|
|
|
expect_verona_stream,
|
2022-10-07 18:14:08 +02:00
|
|
|
"#Verona - Zulip Dev - Zulip",
|
2020-08-27 21:09:54 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
await search_and_check(
|
|
|
|
page,
|
|
|
|
"Cordelia",
|
2023-01-24 19:49:56 +01:00
|
|
|
"Direct",
|
2023-04-11 21:04:33 +02:00
|
|
|
expect_cordelia_direct_messages,
|
2021-04-11 16:26:54 +02:00
|
|
|
"Cordelia, Lear's daughter - Zulip Dev - Zulip",
|
2020-08-27 21:09:54 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
await search_and_check(
|
|
|
|
page,
|
|
|
|
"stream:Verona",
|
|
|
|
"",
|
|
|
|
expect_verona_stream,
|
2022-10-07 18:14:08 +02:00
|
|
|
"#Verona - Zulip Dev - Zulip",
|
2020-08-27 21:09:54 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
await search_and_check(
|
|
|
|
page,
|
|
|
|
"stream:Verona topic:test",
|
|
|
|
"",
|
|
|
|
expect_verona_stream_test_topic,
|
2022-10-07 18:14:08 +02:00
|
|
|
"#Verona > test - Zulip Dev - Zulip",
|
2020-08-27 21:09:54 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
await search_and_check(
|
|
|
|
page,
|
|
|
|
"stream:Verona topic:other+topic",
|
|
|
|
"",
|
|
|
|
expect_verona_other_topic,
|
2022-10-07 18:14:08 +02:00
|
|
|
"#Verona > other topic - Zulip Dev - Zulip",
|
2020-08-27 21:09:54 +02:00
|
|
|
);
|
|
|
|
|
2021-02-19 09:43:50 +01:00
|
|
|
await search_and_check(
|
|
|
|
page,
|
|
|
|
"topic:test",
|
|
|
|
"",
|
|
|
|
expect_test_topic,
|
2022-10-17 17:48:51 +02:00
|
|
|
"Search results - Zulip Dev - Zulip",
|
2021-02-19 09:43:50 +01:00
|
|
|
);
|
2020-08-27 21:09:54 +02:00
|
|
|
|
|
|
|
await search_silent_user(page, "sender:emailgateway@zulip.com", "");
|
|
|
|
|
|
|
|
await search_non_existing_user(page, "sender:dummyuser@zulip.com", "");
|
|
|
|
|
|
|
|
await search_and_check(
|
|
|
|
page,
|
2023-04-11 21:04:33 +02:00
|
|
|
"dm:dummyuser@zulip.com",
|
2020-08-27 21:09:54 +02:00
|
|
|
"",
|
|
|
|
expect_non_existing_user,
|
|
|
|
"Invalid user - Zulip Dev - Zulip",
|
|
|
|
);
|
|
|
|
|
|
|
|
await search_and_check(
|
|
|
|
page,
|
2023-04-11 21:04:33 +02:00
|
|
|
"dm:dummyuser@zulip.com,dummyuser2@zulip.com",
|
2020-08-27 21:09:54 +02:00
|
|
|
"",
|
|
|
|
expect_non_existing_users,
|
|
|
|
"Invalid users - Zulip Dev - Zulip",
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-04-11 21:04:33 +02:00
|
|
|
async function expect_all_direct_messages(page: Page): Promise<void> {
|
2024-01-17 07:53:40 +01:00
|
|
|
const message_list_id = await common.get_current_msg_list_id(page, true);
|
|
|
|
await page.waitForSelector(`.message-list[data-message-list-id='${message_list_id}']`, {
|
|
|
|
visible: true,
|
|
|
|
});
|
|
|
|
await common.check_messages_sent(page, message_list_id, [
|
2023-04-11 21:04:33 +02:00
|
|
|
[
|
|
|
|
"You and Cordelia, Lear's daughter, King Hamlet",
|
|
|
|
["group direct message a", "group direct message b"],
|
|
|
|
],
|
|
|
|
["You and Cordelia, Lear's daughter", ["direct message c"]],
|
|
|
|
["You and Cordelia, Lear's daughter, King Hamlet", ["group direct message d"]],
|
|
|
|
["You and Cordelia, Lear's daughter", ["direct message e"]],
|
2020-08-27 21:09:54 +02:00
|
|
|
]);
|
|
|
|
assert.strictEqual(
|
2023-10-04 16:11:48 +02:00
|
|
|
await common.get_text_from_selector(page, "#new_conversation_button"),
|
|
|
|
"Start new conversation",
|
2020-08-27 21:09:54 +02:00
|
|
|
);
|
2024-04-17 20:53:00 +02:00
|
|
|
assert.strictEqual(await page.title(), "Direct message feed - Zulip Dev - Zulip");
|
2020-08-27 21:09:54 +02:00
|
|
|
}
|
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
async function test_narrow_by_clicking_the_left_sidebar(page: Page): Promise<void> {
|
2020-08-27 21:09:54 +02:00
|
|
|
console.log("Narrowing with left sidebar");
|
|
|
|
|
|
|
|
await page.click((await get_stream_li(page, "Verona")) + " a");
|
|
|
|
await expect_verona_stream(page);
|
|
|
|
|
2023-10-11 19:08:42 +02:00
|
|
|
await page.click("#left-sidebar-navigation-list .top_left_all_messages a");
|
2020-08-27 21:09:54 +02:00
|
|
|
await expect_home(page);
|
|
|
|
|
2022-09-13 13:15:57 +02:00
|
|
|
const all_private_messages_icon = "#show_all_private_messages";
|
|
|
|
await page.waitForSelector(all_private_messages_icon, {visible: true});
|
|
|
|
await page.click(all_private_messages_icon);
|
2023-04-11 21:04:33 +02:00
|
|
|
await expect_all_direct_messages(page);
|
2020-08-27 21:09:54 +02:00
|
|
|
|
|
|
|
await un_narrow(page);
|
2024-04-21 05:31:35 +02:00
|
|
|
await expect_home(page);
|
2020-08-27 21:09:54 +02:00
|
|
|
}
|
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
async function arrow(page: Page, direction: "Up" | "Down"): Promise<void> {
|
|
|
|
await page.keyboard.press(({Up: "ArrowUp", Down: "ArrowDown"} as const)[direction]);
|
2020-08-27 21:09:54 +02:00
|
|
|
}
|
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
async function test_search_venice(page: Page): Promise<void> {
|
2021-03-27 04:40:48 +01:00
|
|
|
await common.clear_and_type(page, ".stream-list-filter", "vEnI"); // Must be case insensitive.
|
2020-08-27 21:09:54 +02:00
|
|
|
await page.waitForSelector(await get_stream_li(page, "Denmark"), {hidden: true});
|
|
|
|
await page.waitForSelector(await get_stream_li(page, "Verona"), {hidden: true});
|
|
|
|
await page.waitForSelector((await get_stream_li(page, "Venice")) + ".highlighted_stream", {
|
|
|
|
visible: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
// Clearing list gives back all the streams in the list
|
2021-03-27 04:40:48 +01:00
|
|
|
await common.clear_and_type(page, ".stream-list-filter", "");
|
2020-08-27 21:09:54 +02:00
|
|
|
await page.waitForSelector(await get_stream_li(page, "Denmark"), {visible: true});
|
|
|
|
await page.waitForSelector(await get_stream_li(page, "Venice"), {visible: true});
|
|
|
|
await page.waitForSelector(await get_stream_li(page, "Verona"), {visible: true});
|
|
|
|
|
2023-11-08 20:33:55 +01:00
|
|
|
await page.click("#streams_header .left-sidebar-title");
|
2020-08-27 21:09:54 +02:00
|
|
|
await page.waitForSelector(".input-append.notdisplayed");
|
|
|
|
}
|
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
async function test_stream_search_filters_stream_list(page: Page): Promise<void> {
|
2021-04-15 21:01:42 +02:00
|
|
|
console.log("Filter streams using left side bar");
|
2020-08-27 21:09:54 +02:00
|
|
|
|
|
|
|
await page.waitForSelector(".input-append.notdisplayed"); // Stream filter box invisible initially
|
2023-11-08 20:33:55 +01:00
|
|
|
await page.click("#streams_header .left-sidebar-title");
|
2020-08-27 21:09:54 +02:00
|
|
|
|
|
|
|
await page.waitForSelector("#streams_list .input-append.notdisplayed", {hidden: true});
|
|
|
|
|
|
|
|
// assert streams exist by waiting till they're visible
|
|
|
|
await page.waitForSelector(await get_stream_li(page, "Denmark"), {visible: true});
|
|
|
|
await page.waitForSelector(await get_stream_li(page, "Venice"), {visible: true});
|
|
|
|
await page.waitForSelector(await get_stream_li(page, "Verona"), {visible: true});
|
|
|
|
|
|
|
|
// Enter the search box and test highlighted suggestion
|
2021-03-06 21:16:35 +01:00
|
|
|
await page.click(".stream-list-filter");
|
2020-08-27 21:09:54 +02:00
|
|
|
|
|
|
|
await page.waitForSelector("#stream_filters .highlighted_stream", {visible: true});
|
2022-02-08 00:13:33 +01:00
|
|
|
// First stream in list gets highlighted on clicking search.
|
2021-04-29 17:22:48 +02:00
|
|
|
await page.waitForSelector((await get_stream_li(page, "core team")) + ".highlighted_stream", {
|
2020-08-27 21:09:54 +02:00
|
|
|
visible: true,
|
|
|
|
});
|
2021-04-29 17:22:48 +02:00
|
|
|
|
|
|
|
await page.waitForSelector((await get_stream_li(page, "Denmark")) + ".highlighted_stream", {
|
|
|
|
hidden: true,
|
|
|
|
});
|
2024-03-26 13:58:30 +01:00
|
|
|
await page.waitForSelector((await get_stream_li(page, "sandbox")) + ".highlighted_stream", {
|
|
|
|
hidden: true,
|
|
|
|
});
|
2020-08-27 21:09:54 +02:00
|
|
|
await page.waitForSelector((await get_stream_li(page, "Venice")) + ".highlighted_stream", {
|
|
|
|
hidden: true,
|
|
|
|
});
|
|
|
|
await page.waitForSelector((await get_stream_li(page, "Verona")) + ".highlighted_stream", {
|
|
|
|
hidden: true,
|
|
|
|
});
|
2024-03-26 13:58:30 +01:00
|
|
|
await page.waitForSelector((await get_stream_li(page, "Zulip")) + ".highlighted_stream", {
|
|
|
|
hidden: true,
|
|
|
|
});
|
2020-08-27 21:09:54 +02:00
|
|
|
|
2021-04-29 17:22:48 +02:00
|
|
|
// Navigate through suggestions using arrow keys
|
|
|
|
await arrow(page, "Down"); // core team -> Denmark
|
2024-03-26 13:58:30 +01:00
|
|
|
await arrow(page, "Down"); // Denmark -> sandbox
|
|
|
|
await arrow(page, "Up"); // sandbox -> Denmark
|
2021-04-29 17:22:48 +02:00
|
|
|
await arrow(page, "Up"); // Denmark -> core team
|
|
|
|
await arrow(page, "Up"); // core team -> core team
|
|
|
|
await arrow(page, "Down"); // core team -> Denmark
|
2024-03-26 13:58:30 +01:00
|
|
|
await arrow(page, "Down"); // Denmark -> sandbox
|
|
|
|
await arrow(page, "Down"); // sandbox-> Venice
|
2021-04-29 17:22:48 +02:00
|
|
|
await arrow(page, "Down"); // Venice -> Verona
|
2020-08-27 21:09:54 +02:00
|
|
|
|
2021-04-29 17:22:48 +02:00
|
|
|
await page.waitForSelector((await get_stream_li(page, "Verona")) + ".highlighted_stream", {
|
2020-08-27 21:09:54 +02:00
|
|
|
visible: true,
|
|
|
|
});
|
2021-04-29 17:22:48 +02:00
|
|
|
|
|
|
|
await page.waitForSelector((await get_stream_li(page, "core team")) + ".highlighted_stream", {
|
|
|
|
hidden: true,
|
|
|
|
});
|
2020-08-27 21:09:54 +02:00
|
|
|
await page.waitForSelector((await get_stream_li(page, "Denmark")) + ".highlighted_stream", {
|
|
|
|
hidden: true,
|
|
|
|
});
|
2021-04-29 17:22:48 +02:00
|
|
|
await page.waitForSelector((await get_stream_li(page, "Venice")) + ".highlighted_stream", {
|
2020-08-27 21:09:54 +02:00
|
|
|
hidden: true,
|
|
|
|
});
|
2024-03-26 13:58:30 +01:00
|
|
|
await page.waitForSelector((await get_stream_li(page, "Zulip")) + ".highlighted_stream", {
|
|
|
|
hidden: true,
|
|
|
|
});
|
2020-08-27 21:09:54 +02:00
|
|
|
await test_search_venice(page);
|
|
|
|
|
2021-04-29 17:22:48 +02:00
|
|
|
// Search for beginning of "Verona".
|
2023-11-08 20:33:55 +01:00
|
|
|
await page.click("#streams_header .left-sidebar-title");
|
2021-03-06 21:16:35 +01:00
|
|
|
await page.type(".stream-list-filter", "ver");
|
2021-04-29 17:22:48 +02:00
|
|
|
await page.waitForSelector(await get_stream_li(page, "core team"), {hidden: true});
|
2020-08-27 21:09:54 +02:00
|
|
|
await page.waitForSelector(await get_stream_li(page, "Denmark"), {hidden: true});
|
2021-05-10 22:04:56 +02:00
|
|
|
await page.waitForSelector(await get_stream_li(page, "Venice"), {hidden: true});
|
2020-08-27 21:09:54 +02:00
|
|
|
await page.click(await get_stream_li(page, "Verona"));
|
|
|
|
await expect_verona_stream(page);
|
|
|
|
assert.strictEqual(
|
|
|
|
await common.get_text_from_selector(page, ".stream-list-filter"),
|
|
|
|
"",
|
|
|
|
"Clicking on stream didn't clear search",
|
|
|
|
);
|
|
|
|
await un_narrow(page);
|
|
|
|
}
|
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
async function test_users_search(page: Page): Promise<void> {
|
2020-08-27 21:09:54 +02:00
|
|
|
console.log("Search users using right sidebar");
|
2021-02-20 05:52:06 +01:00
|
|
|
async function assert_in_list(page: Page, name: string): Promise<void> {
|
2023-08-23 02:18:53 +02:00
|
|
|
await page.waitForSelector(`#buddy-list-other-users li [data-name="${CSS.escape(name)}"]`, {
|
|
|
|
visible: true,
|
|
|
|
});
|
2020-08-27 21:09:54 +02:00
|
|
|
}
|
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
async function assert_selected(page: Page, name: string): Promise<void> {
|
2021-02-03 23:23:32 +01:00
|
|
|
await page.waitForSelector(
|
2023-08-23 02:18:53 +02:00
|
|
|
`#buddy-list-other-users li.highlighted_user [data-name="${CSS.escape(name)}"]`,
|
2021-02-20 05:58:35 +01:00
|
|
|
{visible: true},
|
2021-02-03 23:23:32 +01:00
|
|
|
);
|
2020-08-27 21:09:54 +02:00
|
|
|
}
|
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
async function assert_not_selected(page: Page, name: string): Promise<void> {
|
2021-02-20 05:58:35 +01:00
|
|
|
await page.waitForSelector(
|
2023-08-23 02:18:53 +02:00
|
|
|
`#buddy-list-other-users li.highlighted_user [data-name="${CSS.escape(name)}"]`,
|
2021-02-20 05:58:35 +01:00
|
|
|
{hidden: true},
|
2020-08-27 21:09:54 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
await assert_in_list(page, "Desdemona");
|
2021-04-11 16:26:54 +02:00
|
|
|
await assert_in_list(page, "Cordelia, Lear's daughter");
|
2020-08-27 21:09:54 +02:00
|
|
|
await assert_in_list(page, "King Hamlet");
|
|
|
|
await assert_in_list(page, "aaron");
|
|
|
|
|
|
|
|
// Enter the search box and test selected suggestion navigation
|
2021-03-06 21:16:35 +01:00
|
|
|
await page.click("#user_filter_icon");
|
2023-08-23 02:18:53 +02:00
|
|
|
await page.waitForSelector("#buddy-list-other-users .highlighted_user", {visible: true});
|
2020-08-27 21:09:54 +02:00
|
|
|
await assert_selected(page, "Desdemona");
|
2021-04-11 16:26:54 +02:00
|
|
|
await assert_not_selected(page, "Cordelia, Lear's daughter");
|
2020-08-27 21:09:54 +02:00
|
|
|
await assert_not_selected(page, "King Hamlet");
|
|
|
|
await assert_not_selected(page, "aaron");
|
|
|
|
|
|
|
|
// Navigate using arrow keys.
|
|
|
|
// go down 2, up 3, then down 3
|
|
|
|
// Desdemona
|
|
|
|
// aaron
|
2021-04-11 16:26:54 +02:00
|
|
|
// Cordelia, Lear's daughter
|
2020-08-27 21:09:54 +02:00
|
|
|
// Iago
|
|
|
|
await arrow(page, "Down");
|
|
|
|
await arrow(page, "Down");
|
|
|
|
await arrow(page, "Up");
|
|
|
|
await arrow(page, "Up");
|
2021-04-25 22:54:23 +02:00
|
|
|
await arrow(page, "Up"); // does nothing; already on the top.
|
2020-08-27 21:09:54 +02:00
|
|
|
await arrow(page, "Down");
|
|
|
|
await arrow(page, "Down");
|
|
|
|
await arrow(page, "Down");
|
|
|
|
|
|
|
|
// Now Iago must be highlighted
|
2023-08-23 02:18:53 +02:00
|
|
|
await page.waitForSelector('#buddy-list-other-users li.highlighted_user [data-name="Iago"]', {
|
|
|
|
visible: true,
|
|
|
|
});
|
2020-08-27 21:09:54 +02:00
|
|
|
await assert_not_selected(page, "King Hamlet");
|
|
|
|
await assert_not_selected(page, "aaron");
|
|
|
|
await assert_not_selected(page, "Desdemona");
|
|
|
|
|
2023-04-11 21:04:33 +02:00
|
|
|
// arrow up and press Enter. We should be taken to direct messages with Cordelia, Lear's daughter
|
2020-08-27 21:09:54 +02:00
|
|
|
await arrow(page, "Up");
|
|
|
|
await page.keyboard.press("Enter");
|
2023-04-11 21:04:33 +02:00
|
|
|
await expect_cordelia_direct_messages(page);
|
2020-08-27 21:09:54 +02:00
|
|
|
}
|
|
|
|
|
2022-08-09 23:20:48 +02:00
|
|
|
async function test_narrow_public_streams(page: Page): Promise<void> {
|
2022-08-10 09:34:25 +02:00
|
|
|
const stream_id = await common.get_stream_id(page, "Denmark");
|
2024-04-30 13:30:24 +02:00
|
|
|
await page.goto(`http://zulip.zulipdev.com:9981/#channels/${stream_id}/Denmark`);
|
2022-08-10 09:34:25 +02:00
|
|
|
await page.waitForSelector("button.sub_unsub_button", {visible: true});
|
|
|
|
await page.click("button.sub_unsub_button");
|
2021-03-27 04:40:48 +01:00
|
|
|
await page.waitForSelector(
|
|
|
|
`xpath///button[${common.has_class_x(
|
|
|
|
"sub_unsub_button",
|
|
|
|
)} and normalize-space()="Subscribe"]`,
|
|
|
|
);
|
2022-08-10 09:34:25 +02:00
|
|
|
await page.click(".subscriptions-header .exit-sign");
|
|
|
|
await page.waitForSelector("#subscription_overlay", {hidden: true});
|
|
|
|
await page.goto(`http://zulip.zulipdev.com:9981/#narrow/stream/${stream_id}-Denmark`);
|
2024-01-17 07:53:40 +01:00
|
|
|
let message_list_id = await common.get_current_msg_list_id(page, true);
|
|
|
|
await page.waitForSelector(
|
|
|
|
`.message-list[data-message-list-id='${message_list_id}'] .recipient_row ~ .recipient_row ~ .recipient_row`,
|
|
|
|
);
|
|
|
|
assert.ok(
|
|
|
|
(await page.$(
|
|
|
|
`.message-list[data-message-list-id='${message_list_id}'] .stream-status`,
|
|
|
|
)) !== null,
|
|
|
|
);
|
2022-08-09 23:20:48 +02:00
|
|
|
|
|
|
|
await page.goto("http://zulip.zulipdev.com:9981/#narrow/streams/public");
|
2024-01-17 07:53:40 +01:00
|
|
|
message_list_id = await common.get_current_msg_list_id(page, true);
|
|
|
|
await page.waitForSelector(
|
|
|
|
`.message-list[data-message-list-id='${message_list_id}'] .recipient_row ~ .recipient_row ~ .recipient_row`,
|
|
|
|
);
|
|
|
|
assert.ok(
|
|
|
|
(await page.$(
|
|
|
|
`.message-list[data-message-list-id='${message_list_id}'] .stream-status`,
|
|
|
|
)) === null,
|
|
|
|
);
|
2022-08-09 23:20:48 +02:00
|
|
|
}
|
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
async function message_basic_tests(page: Page): Promise<void> {
|
2020-06-12 17:57:02 +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");
|
2024-01-17 07:53:40 +01:00
|
|
|
await page.waitForSelector(".message-list .message_row", {visible: true});
|
|
|
|
// Assert that there is only one message list.
|
|
|
|
assert.equal((await page.$$(".message-list")).length, 1);
|
2020-06-12 17:57:02 +02:00
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
console.log("Sending messages");
|
2020-06-12 17:57:02 +02:00
|
|
|
await common.send_multiple_messages(page, [
|
2023-08-04 06:46:35 +02:00
|
|
|
{stream_name: "Verona", topic: "test", content: "verona test a"},
|
|
|
|
{stream_name: "Verona", topic: "test", content: "verona test b"},
|
2024-06-10 11:09:43 +02:00
|
|
|
{
|
|
|
|
stream_name: "Verona",
|
|
|
|
topic: "other topic",
|
|
|
|
content: "verona other topic c",
|
|
|
|
outside_view: true,
|
|
|
|
},
|
|
|
|
{stream_name: "Denmark", topic: "test", content: "denmark message", outside_view: true},
|
|
|
|
{
|
|
|
|
recipient: "cordelia@zulip.com, hamlet@zulip.com",
|
|
|
|
content: "group direct message a",
|
|
|
|
outside_view: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
recipient: "cordelia@zulip.com, hamlet@zulip.com",
|
|
|
|
content: "group direct message b",
|
|
|
|
outside_view: true,
|
|
|
|
},
|
|
|
|
{recipient: "cordelia@zulip.com", content: "direct message c", outside_view: true},
|
2023-08-04 06:46:35 +02:00
|
|
|
{stream_name: "Verona", topic: "test", content: "verona test d"},
|
2024-06-10 11:09:43 +02:00
|
|
|
{
|
|
|
|
recipient: "cordelia@zulip.com, hamlet@zulip.com",
|
|
|
|
content: "group direct message d",
|
|
|
|
outside_view: true,
|
|
|
|
},
|
|
|
|
{recipient: "cordelia@zulip.com", content: "direct message e", outside_view: true},
|
2020-06-12 17:57:02 +02:00
|
|
|
]);
|
|
|
|
|
2024-03-06 13:12:08 +01:00
|
|
|
await page.click("#left-sidebar-navigation-list .top_left_all_messages");
|
2020-08-27 21:09:54 +02:00
|
|
|
await expect_home(page);
|
|
|
|
|
|
|
|
await test_navigations_from_home(page);
|
|
|
|
await search_tests(page);
|
|
|
|
await test_narrow_by_clicking_the_left_sidebar(page);
|
|
|
|
await test_stream_search_filters_stream_list(page);
|
|
|
|
await test_users_search(page);
|
2022-08-09 23:20:48 +02:00
|
|
|
await test_narrow_public_streams(page);
|
2020-06-12 17:57:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
common.run_test(message_basic_tests);
|