puppeteer_tests: Use more stable selectors.

This commit changes some fragile selectors (like
`a[href=#link]`) to more stable selectors because they
are more prone to break from doing something normal
like adding another link in the app.

It also solves an inconsistency in `07-navigation.ts`,
where the subscription overlay was opened by clicking
on the header stream instead of the menu list.

It also fixes a rare flake (in `07-navigation.ts`), where
the close button of subscription overlay was not clicked
due to a delay in the opening. The delay was caused by
clicking the header stream to open subscription overlay
which caused unnecessary loading of the stream
setting(Verona).
This commit is contained in:
Riken Shah
2021-03-31 12:27:11 +05:30
committed by Steve Howell
parent c5f0806308
commit a527d196d7
6 changed files with 8 additions and 8 deletions

View File

@@ -252,7 +252,7 @@ class CommonUtils {
async log_out(page: Page): Promise<void> {
await page.goto(this.realm_url);
const menu_selector = "#settings-dropdown";
const logout_selector = 'a[href="#logout"]';
const logout_selector = '.dropdown-menu a[href="#logout"]';
console.log("Logging out");
await page.waitForSelector(menu_selector, {visible: true});
await page.click(menu_selector);
@@ -468,7 +468,7 @@ class CommonUtils {
await page.waitForSelector(menu_selector, {visible: true});
await page.click(menu_selector);
const organization_settings = 'a[href="#organization"]';
const organization_settings = '.dropdown-menu a[href="#organization"]';
await page.click(organization_settings);
await page.waitForSelector("#settings_overlay_container.show", {visible: true});

View File

@@ -39,7 +39,7 @@ async function stream_name_error(page: Page): Promise<string> {
}
async function open_streams_modal(page: Page): Promise<void> {
const all_streams_selector = 'a[href="#streams/all"]';
const all_streams_selector = "#add-stream-link";
await page.waitForSelector(all_streams_selector, {visible: true});
await page.click(all_streams_selector);

View File

@@ -27,7 +27,7 @@ async function toggle_test_star_message(page: Page): Promise<void> {
}
async function test_narrow_to_starred_messages(page: Page): Promise<void> {
await page.click('a[href^="#narrow/is/starred"]');
await page.click('#global_filters a[href^="#narrow/is/starred"]');
await common.check_messages_sent(page, "zfilt", [["Verona > stars", [message]]]);
// Go back to all messages narrow.

View File

@@ -31,7 +31,7 @@ async function navigate_to_settings(page: Page): Promise<void> {
await open_menu(page);
const settings_selector = "a[href^='#settings']";
const settings_selector = ".dropdown-menu a[href^='#settings']";
await page.waitForSelector(settings_selector, {visible: true});
await page.click(settings_selector);
@@ -47,7 +47,7 @@ async function navigate_to_subscriptions(page: Page): Promise<void> {
await open_menu(page);
const manage_streams_selector = 'a[href^="#streams"]';
const manage_streams_selector = '.dropdown-menu a[href^="#streams"]';
await page.waitForSelector(manage_streams_selector, {visible: true});
await page.click(manage_streams_selector);

View File

@@ -8,7 +8,7 @@ async function navigate_to_user_list(page: Page): Promise<void> {
const menu_selector = "#settings-dropdown";
await page.waitForSelector(menu_selector, {visible: true});
await page.click(menu_selector);
await page.click('a[href="#organization"]');
await page.click('.dropdown-menu a[href="#organization"]');
await page.waitForSelector("#settings_overlay_container.show", {visible: true});
await page.click("li[data-section='user-list-admin']");
}

View File

@@ -22,7 +22,7 @@ async function open_settings(page: Page): Promise<void> {
await page.waitForSelector(menu_selector, {visible: true});
await page.click(menu_selector);
const settings_selector = 'a[href="#settings"]';
const settings_selector = '.dropdown-menu a[href="#settings"]';
await page.waitForSelector(settings_selector, {visible: true});
await page.click(settings_selector);