Files
upstream-zulip/web/e2e-tests/navigation.test.ts
upstream-mirror 64898b2c79
Some checks failed
Code scanning / CodeQL (push) Failing after 15s
Zulip production suite / Ubuntu 22.04 production build (push) Failing after 26s
Zulip production suite / Debian 12 production install with custom db name and user (push) Has been skipped
Zulip production suite / Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga (push) Has been skipped
Zulip production suite / Ubuntu 24.04 production install (push) Has been skipped
Zulip production suite / Ubuntu 26.04 production install (push) Has been skipped
Zulip production suite / Debian 13 production install (push) Has been skipped
Zulip production suite / 7.0 Version Upgrade (push) Has been skipped
Zulip production suite / 8.0 Version Upgrade (push) Has been skipped
Zulip production suite / 6.0 Version Upgrade (push) Has been skipped
Zulip production suite / 10.0 Version Upgrade (push) Has been skipped
Zulip production suite / 9.0 Version Upgrade (push) Has been skipped
Zulip production suite / 12.0 Version Upgrade (push) Has been skipped
Zulip production suite / 11.0 Version Upgrade (push) Has been skipped
GitHub Actions Security Analysis with zizmor / zizmor (push) Failing after 3s
Zulip CI / Debian 12 (Python 3.11, backend + documentation) (push) Failing after 26s
Zulip CI / Ubuntu 22.04 (Python 3.10, backend + frontend) (push) Failing after 3s
Zulip CI / Ubuntu 24.04 (Python 3.12, backend) (push) Failing after 25s
Zulip CI / Ubuntu 26.04 (Python 3.14, backend) (push) Failing after 25s
Zulip CI / Debian 13 (Python 3.13, backend) (push) Failing after 28s
Zulip production suite / Required jobs (push) Has been cancelled
Zulip CI / Required jobs (push) Has been cancelled
API Documentation Update Check / check-feature-level-updated (push) Has been cancelled
API Documentation Update Check / notify-if-api-docs-changed (push) Has been cancelled
snapshot of https://github.com/zulip/zulip.git @ 48c69911c7dd4e03b20552eb3bd77ad8151c1357 (2026-09-15)
2026-09-15 15:05:30 +05:00

120 lines
4.6 KiB
TypeScript

import assert from "node:assert/strict";
import type {Page} from "puppeteer";
import * as common from "./lib/common.ts";
async function navigate_using_left_sidebar(page: Page, stream_name: string): Promise<void> {
console.log("Visiting #" + stream_name);
const stream_id = await page.evaluate(() => zulip_test.get_sub("Verona")!.stream_id);
await page.click(`.narrow-filter[data-stream-id="${stream_id}"] .stream-name`);
await page.waitForSelector("#message_view_header .zulip-icon-hashtag", {visible: true});
}
async function open_menu(page: Page): Promise<void> {
const menu_selector = "#settings-dropdown";
await page.waitForSelector(menu_selector, {visible: true});
await page.click(menu_selector);
}
async function navigate_to_settings(page: Page): Promise<void> {
console.log("Navigating to settings");
await common.open_personal_menu(page);
const settings_selector = "#personal-menu-dropdown a[href^='#settings']";
await page.waitForSelector(settings_selector, {visible: true});
await page.click(settings_selector);
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.waitForSelector(`${profile_section_tab_selector}:focus`, {visible: true});
await page.click("#settings_page .content-wrapper .exit");
// Wait until the overlay is completely closed.
await page.waitForSelector("#settings_overlay_container", {hidden: true});
}
async function navigate_to_subscriptions(page: Page): Promise<void> {
console.log("Navigate to subscriptions");
await open_menu(page);
const manage_streams_selector = '.link-item a[href^="#channels"]';
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");
// Wait until the overlay is completely closed.
await page.waitForSelector("#subscription_overlay", {hidden: true});
}
async function navigate_to_private_messages(page: Page): Promise<void> {
console.log("Navigate to direct messages");
const all_private_messages_icon = ".show-all-direct-messages";
await page.waitForSelector(all_private_messages_icon, {visible: true});
await page.click(all_private_messages_icon);
await page.waitForSelector("#message_view_header .zulip-icon-user", {visible: true});
}
async function test_reload_hash(page: Page): Promise<void> {
const initial_page_load_time = await page.evaluate(() => zulip_test.page_load_time);
assert.ok(initial_page_load_time !== undefined);
console.log(`initial load time: ${initial_page_load_time}`);
const initial_hash = await page.evaluate(() => window.location.hash);
await page.evaluate(() => {
zulip_test.initiate_reload({immediate: true});
});
await page.waitForNavigation();
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,
});
const page_load_time = await page.evaluate(() => zulip_test.page_load_time);
assert.ok(page_load_time !== undefined);
assert.ok(page_load_time > initial_page_load_time, "Page not reloaded.");
const hash = await page.evaluate(() => window.location.hash);
assert.strictEqual(hash, initial_hash, "Hash not preserved.");
}
async function navigation_tests(page: Page): Promise<void> {
await common.log_in(page);
await navigate_to_settings(page);
await navigate_using_left_sidebar(page, "Verona");
await page.click("#left-sidebar-navigation-list .top_left_all_messages");
await page.waitForSelector("#message_view_header .zulip-icon-all-messages", {visible: true});
await navigate_to_subscriptions(page);
await page.click("#left-sidebar-navigation-list .top_left_all_messages");
await page.waitForSelector("#message_view_header .zulip-icon-all-messages", {visible: true});
await navigate_to_settings(page);
await navigate_to_private_messages(page);
await navigate_to_subscriptions(page);
await navigate_using_left_sidebar(page, "Verona");
await test_reload_hash(page);
// Verify that we're narrowed to the target stream
await page.waitForSelector(
`xpath///*[@id="message_view_header"]//*[${common.has_class_x(
"message-header-stream-settings-button",
)} and normalize-space()="Verona"]`,
);
}
await common.run_test(navigation_tests);