puppeteer_lib: Remove jQuery dependency from pm_recipient.set.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2021-03-12 14:12:51 -08:00
committed by Steve Howell
parent d8af33d24e
commit 4434e2c687

View File

@@ -22,20 +22,16 @@ class CommonUtils {
// a flake where the typeahead doesn't show up. // a flake where the typeahead doesn't show up.
await page.type("#private_message_recipient", recipient, {delay: 100}); await page.type("#private_message_recipient", recipient, {delay: 100});
// We use jQuery here because we need to use it's :visible // We use [style*="display: block"] here to distinguish
// pseudo selector to actually wait for typeahead item that // the visible typeahead menu from the invisible ones
// is visible; there can be typeahead item with this selector // meant for something else; e.g., the private message
// that is invisible because it is meant for something else // input typeahead is different from the topic input
// e.g. private message input typeahead is different from topic // typeahead but both can be present in the DOM.
// input typeahead but both can be present in the dom. const entry = await page.waitForSelector(
await page.waitForFunction(() => { '.typeahead[style*="display: block"] .active a',
const selector = ".typeahead-menu .active a:visible"; {visible: true},
return $(selector).length !== 0; );
}); await entry!.click();
await page.evaluate(() => {
$(".typeahead-menu .active a:visible").trigger("click");
});
}, },
async expect(page: Page, expected: string): Promise<void> { async expect(page: Page, expected: string): Promise<void> {