Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
puppeteer_test: Fix `page.url()` for Firefox.
Riken Shahde96aeb822a4
diff --git a/frontend_tests/puppeteer_lib/common.ts b/frontend_tests/puppeteer_lib/common.tsindex 71328354ac9..6ea3f17299b 100644--- a/frontend_tests/puppeteer_lib/common.ts+++ b/frontend_tests/puppeteer_lib/common.ts@@ -94,6 +94,16 @@ class CommonUtils {});}+ async page_url_with_fragment(page: Page): Promise<string> {+ // `page.url()` does not include the url fragment when running+ // Puppeteer with Firefox: https://github.com/puppeteer/puppeteer/issues/6787.+ //+ // This function hacks around that issue; once it's fixed in+ // puppeteer upstream, we can delete this function and return+ // its callers to using `page.url()`+ return await page.evaluate("location.href");+ }+/*** This function takes a params object whose fields* are referenced by name attribute of an input field and@@ -444,7 +454,7 @@ class CommonUtils {await page.click(organization_settings);await page.waitForSelector("#settings_overlay_container.show", {visible: true});- const url = page.url();+ const url = await this.page_url_with_fragment(page);assert(/^http:\/\/[^/]+\/#organization/.test(url), "Unexpected manage organization URL");const organization_settings_data_section = "li[data-section='organization-settings']";diff --git a/frontend_tests/puppeteer_tests/04-subscriptions.ts b/frontend_tests/puppeteer_tests/04-subscriptions.tsindex 098bc5750bf..552ccd3f24b 100644--- a/frontend_tests/puppeteer_tests/04-subscriptions.ts+++ b/frontend_tests/puppeteer_tests/04-subscriptions.ts@@ -44,7 +44,8 @@ async function open_streams_modal(page: Page): Promise<void> {await page.click(all_streams_selector);await page.waitForSelector("#subscription_overlay.new-style", {visible: true});- assert(page.url().includes("#streams/all"));+ const url = await common.page_url_with_fragment(page);+ assert(url.includes("#streams/all"));}async function test_subscription_button_verona_stream(page: Page): Promise<void> {diff --git a/frontend_tests/puppeteer_tests/16-settings.ts b/frontend_tests/puppeteer_tests/16-settings.tsindex e5a385d70a5..c3ecc0e39c6 100644--- a/frontend_tests/puppeteer_tests/16-settings.ts+++ b/frontend_tests/puppeteer_tests/16-settings.ts@@ -27,7 +27,7 @@ async function open_settings(page: Page): Promise<void> {await page.click(settings_selector);await page.waitForSelector("#settings_content .account-settings-form", {visible: true});- const page_url = page.url();+ const page_url = await common.page_url_with_fragment(page);assert(page_url.includes("/#settings/"), `Page url: ${page_url} does not contain /#settings/`);}