2021-02-20 05:52:06 +01:00
|
|
|
import {strict as assert} from "assert";
|
2020-08-05 19:38:08 +02:00
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
import type {Page} from "puppeteer";
|
2020-08-05 19:38:08 +02:00
|
|
|
|
2023-02-22 23:04:11 +01:00
|
|
|
import * as common from "./lib/common";
|
2020-08-05 19:38:08 +02:00
|
|
|
|
2024-03-13 14:08:14 +01:00
|
|
|
async function navigate_using_left_sidebar(page: Page, stream_name: string): Promise<void> {
|
|
|
|
console.log("Visiting #" + stream_name);
|
|
|
|
await page.click(`.stream-name[title="${stream_name}"]`);
|
2022-11-21 03:58:31 +01:00
|
|
|
await page.waitForSelector(`#message_feed_container`, {visible: true});
|
2020-08-05 19:38:08 +02:00
|
|
|
}
|
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
async function open_menu(page: Page): Promise<void> {
|
2020-08-05 19:38:08 +02:00
|
|
|
const menu_selector = "#settings-dropdown";
|
|
|
|
await page.waitForSelector(menu_selector, {visible: true});
|
|
|
|
await page.click(menu_selector);
|
|
|
|
}
|
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
async function navigate_to_settings(page: Page): Promise<void> {
|
2020-08-05 19:38:08 +02:00
|
|
|
console.log("Navigating to settings");
|
|
|
|
|
2023-07-17 18:01:16 +02:00
|
|
|
await common.open_personal_menu(page);
|
2020-08-05 19:38:08 +02:00
|
|
|
|
2023-07-17 18:01:16 +02:00
|
|
|
const settings_selector = "#personal-menu-dropdown a[href^='#settings']";
|
2020-08-05 19:38:08 +02:00
|
|
|
await page.waitForSelector(settings_selector, {visible: true});
|
|
|
|
await page.click(settings_selector);
|
|
|
|
|
2022-08-17 03:50:29 +02:00
|
|
|
const profile_section_tab_selector = "li[data-section='profile']";
|
|
|
|
await page.waitForSelector(profile_section_tab_selector, {visible: true});
|
|
|
|
await page.click(profile_section_tab_selector);
|
|
|
|
await page.waitForFunction(
|
|
|
|
() => document.activeElement?.getAttribute("data-section") === "profile",
|
|
|
|
);
|
2020-08-05 19:38:08 +02:00
|
|
|
|
|
|
|
await page.click("#settings_page .content-wrapper .exit");
|
2021-03-12 12:30:25 +01:00
|
|
|
// Wait until the overlay is completely closed.
|
|
|
|
await page.waitForSelector("#settings_overlay_container", {hidden: true});
|
2020-08-05 19:38:08 +02:00
|
|
|
}
|
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
async function navigate_to_subscriptions(page: Page): Promise<void> {
|
2020-08-05 19:38:08 +02:00
|
|
|
console.log("Navigate to subscriptions");
|
|
|
|
|
|
|
|
await open_menu(page);
|
|
|
|
|
2024-04-30 13:30:24 +02:00
|
|
|
const manage_streams_selector = '.link-item a[href^="#channels"]';
|
2020-08-05 19:38:08 +02:00
|
|
|
await page.waitForSelector(manage_streams_selector, {visible: true});
|
|
|
|
await page.click(manage_streams_selector);
|
|
|
|
|
|
|
|
await page.waitForSelector("#subscription_overlay", {visible: true});
|
|
|
|
|
|
|
|
await page.click("#subscription_overlay .exit");
|
2021-03-12 12:30:25 +01:00
|
|
|
// Wait until the overlay is completely closed.
|
2021-03-12 22:26:39 +01:00
|
|
|
await page.waitForSelector("#subscription_overlay", {hidden: true});
|
2020-08-05 19:38:08 +02:00
|
|
|
}
|
|
|
|
|
2022-09-13 13:15:57 +02:00
|
|
|
async function navigate_to_private_messages(page: Page): Promise<void> {
|
2023-06-16 13:52:33 +02:00
|
|
|
console.log("Navigate to direct messages");
|
2022-09-13 13:15:57 +02:00
|
|
|
|
2024-06-07 05:32:34 +02:00
|
|
|
const all_private_messages_icon = "#show-all-direct-messages";
|
2022-09-13 13:15:57 +02:00
|
|
|
await page.waitForSelector(all_private_messages_icon, {visible: true});
|
|
|
|
await page.click(all_private_messages_icon);
|
|
|
|
|
2024-07-17 13:50:10 +02:00
|
|
|
await page.waitForSelector("#message_view_header .zulip-icon-user", {visible: true});
|
2022-09-13 13:15:57 +02:00
|
|
|
}
|
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
async function test_reload_hash(page: Page): Promise<void> {
|
2024-05-04 00:31:56 +02:00
|
|
|
const initial_page_load_time = await page.evaluate(() => zulip_test.page_load_time);
|
|
|
|
assert(initial_page_load_time !== undefined);
|
2021-09-22 23:34:58 +02:00
|
|
|
console.log(`initial load time: ${initial_page_load_time}`);
|
2020-08-05 19:38:08 +02:00
|
|
|
|
|
|
|
const initial_hash = await page.evaluate(() => window.location.hash);
|
|
|
|
|
2024-05-04 00:31:56 +02:00
|
|
|
await page.evaluate(() => {
|
|
|
|
zulip_test.initiate_reload({immediate: true});
|
|
|
|
});
|
2021-03-03 05:51:58 +01:00
|
|
|
await page.waitForNavigation();
|
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,
|
|
|
|
});
|
2020-08-05 19:38:08 +02:00
|
|
|
|
2023-12-29 02:23:51 +01:00
|
|
|
const page_load_time = await page.evaluate(() => zulip_test.page_load_time);
|
2024-05-04 00:31:56 +02:00
|
|
|
assert(page_load_time !== undefined);
|
2021-06-10 08:32:54 +02:00
|
|
|
assert.ok(page_load_time > initial_page_load_time, "Page not reloaded.");
|
2020-08-05 19:38:08 +02:00
|
|
|
|
|
|
|
const hash = await page.evaluate(() => window.location.hash);
|
|
|
|
assert.strictEqual(hash, initial_hash, "Hash not preserved.");
|
|
|
|
}
|
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
async function navigation_tests(page: Page): Promise<void> {
|
2020-08-05 19:38:08 +02:00
|
|
|
await common.log_in(page);
|
|
|
|
|
|
|
|
await navigate_to_settings(page);
|
|
|
|
|
2024-03-13 14:08:14 +01:00
|
|
|
await navigate_using_left_sidebar(page, "Verona");
|
2020-08-05 19:38:08 +02:00
|
|
|
|
2023-10-11 19:08:42 +02:00
|
|
|
await page.click("#left-sidebar-navigation-list .home-link");
|
2022-11-21 03:58:31 +01:00
|
|
|
await page.waitForSelector("#message_feed_container", {visible: true});
|
2020-08-05 19:38:08 +02:00
|
|
|
|
|
|
|
await navigate_to_subscriptions(page);
|
2023-10-11 19:08:42 +02:00
|
|
|
|
|
|
|
await page.click("#left-sidebar-navigation-list .home-link");
|
|
|
|
await page.waitForSelector(`#message_feed_container`, {visible: true});
|
|
|
|
|
2020-08-05 19:38:08 +02:00
|
|
|
await navigate_to_settings(page);
|
2022-09-13 13:15:57 +02:00
|
|
|
await navigate_to_private_messages(page);
|
2020-08-05 19:38:08 +02:00
|
|
|
await navigate_to_subscriptions(page);
|
2024-03-13 14:08:14 +01:00
|
|
|
await navigate_using_left_sidebar(page, "Verona");
|
2020-08-05 19:38:08 +02:00
|
|
|
|
|
|
|
await test_reload_hash(page);
|
|
|
|
|
|
|
|
// Verify that we're narrowed to the target stream
|
2022-09-10 05:37:50 +02:00
|
|
|
await page.waitForSelector(
|
2021-03-27 04:20:49 +01:00
|
|
|
`xpath///*[@id="message_view_header"]//*[${common.has_class_x(
|
2023-06-17 18:48:49 +02:00
|
|
|
"message-header-stream-settings-button",
|
2021-03-27 04:20:49 +01:00
|
|
|
)} and normalize-space()="Verona"]`,
|
2021-03-12 23:13:45 +01:00
|
|
|
);
|
2020-08-05 19:38:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
common.run_test(navigation_tests);
|