puppeteer_lib: Explode CommonUtils class.

This may have originally made sense as a class that managed the
browser state, but it has since turned into a dumping ground for
mostly pure functions that don’t make sense to instantiate.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2021-03-26 19:52:16 -07:00
committed by Tim Abbott
parent 53cf974b89
commit 663f1a387d
20 changed files with 588 additions and 584 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -2,7 +2,7 @@ import {strict as assert} from "assert";
import type {ElementHandle, Page} from "puppeteer";
import common from "../puppeteer_lib/common";
import * as common from "../puppeteer_lib/common";
async function submit_notifications_stream_settings(page: Page): Promise<void> {
await page.waitForSelector('#org-submit-notifications[data-status="unsaved"]', {visible: true});

View File

@@ -2,7 +2,7 @@ import {strict as assert} from "assert";
import type {ElementHandle, Page} from "puppeteer";
import common from "../puppeteer_lib/common";
import * as common from "../puppeteer_lib/common";
async function check_compose_form_empty(page: Page): Promise<void> {
await common.check_form_contents(page, "#send_message_form", {

View File

@@ -2,7 +2,7 @@ import {strict as assert} from "assert";
import type {Page} from "puppeteer";
import common from "../puppeteer_lib/common";
import * as common from "../puppeteer_lib/common";
async function copy_messages(
page: Page,

View File

@@ -2,7 +2,7 @@ import {strict as assert} from "assert";
import type {Page} from "puppeteer";
import common from "../puppeteer_lib/common";
import * as common from "../puppeteer_lib/common";
// This will be the row of the the custom profile field we add.
const profile_field_row = "#admin_profile_fields_table tr:nth-last-child(1)";

View File

@@ -1,6 +1,6 @@
import type {Page} from "puppeteer";
import common from "../puppeteer_lib/common";
import * as common from "../puppeteer_lib/common";
async function click_delete_and_return_last_msg_id(page: Page): Promise<string | undefined> {
return await page.evaluate(() => {

View File

@@ -2,7 +2,7 @@ import {strict as assert} from "assert";
import type {Page} from "puppeteer";
import common from "../puppeteer_lib/common";
import * as common from "../puppeteer_lib/common";
async function wait_for_drafts_to_disappear(page: Page): Promise<void> {
await page.waitForFunction(

View File

@@ -1,6 +1,6 @@
import type {Page} from "puppeteer";
import common from "../puppeteer_lib/common";
import * as common from "../puppeteer_lib/common";
async function trigger_edit_last_message(page: Page): Promise<void> {
await page.evaluate(() => {

View File

@@ -2,7 +2,7 @@ import {strict as assert} from "assert";
import type {Page} from "puppeteer";
import common from "../puppeteer_lib/common";
import * as common from "../puppeteer_lib/common";
async function test_mention(page: Page): Promise<void> {
await common.log_in(page);

View File

@@ -2,7 +2,7 @@ import {strict as assert} from "assert";
import type {Page} from "puppeteer";
import common from "../puppeteer_lib/common";
import * as common from "../puppeteer_lib/common";
async function get_stream_li(page: Page, stream_name: string): Promise<string> {
const stream_id = await common.get_stream_id(page, stream_name);

View File

@@ -2,7 +2,7 @@ import {strict as assert} from "assert";
import type {Page} from "puppeteer";
import common from "../puppeteer_lib/common";
import * as common from "../puppeteer_lib/common";
async function wait_for_tab(page: Page, tab: string): Promise<void> {
const tab_slector = `#${CSS.escape(tab)}.tab-pane`;

View File

@@ -2,7 +2,7 @@ import {strict as assert} from "assert";
import type {Page} from "puppeteer";
import common from "../puppeteer_lib/common";
import * as common from "../puppeteer_lib/common";
const email = "alice@test.example.com";
const subdomain = "testsubdomain";
@@ -67,7 +67,7 @@ async function realm_creation_tests(page: Page): Promise<void> {
await page.waitForSelector("#lightbox_overlay"); // if element doesn't exist,timeout error raises
// Updating common.realm_url because we are redirecting to it when logging out.
common.realm_url = page.url();
common.set_realm_url(page.url());
}
common.run_test(realm_creation_tests);

View File

@@ -2,7 +2,7 @@ import {strict as assert} from "assert";
import type {Page} from "puppeteer";
import common from "../puppeteer_lib/common";
import * as common from "../puppeteer_lib/common";
async function test_add_linkifier(page: Page): Promise<void> {
await page.waitForSelector(".admin-linkifier-form", {visible: true});

View File

@@ -2,7 +2,7 @@ import {strict as assert} from "assert";
import type {Page} from "puppeteer";
import common from "../puppeteer_lib/common";
import * as common from "../puppeteer_lib/common";
type Playground = {
playground_name: string;

View File

@@ -3,7 +3,7 @@ import {strict as assert} from "assert";
import type {Page} from "puppeteer";
import {test_credentials} from "../../var/puppeteer/test_credentials";
import common from "../puppeteer_lib/common";
import * as common from "../puppeteer_lib/common";
const OUTGOING_WEBHOOK_BOT_TYPE = "3";
const GENERIC_BOT_TYPE = "1";

View File

@@ -2,7 +2,7 @@ import {strict as assert} from "assert";
import type {Page} from "puppeteer";
import common from "../puppeteer_lib/common";
import * as common from "../puppeteer_lib/common";
const message = "test star";

View File

@@ -2,7 +2,7 @@ import {strict as assert} from "assert";
import type {Page} from "puppeteer";
import common from "../puppeteer_lib/common";
import * as common from "../puppeteer_lib/common";
async function user_row_selector(page: Page, name: string): Promise<string> {
const user_id = await common.get_user_id_from_name(page, name);

View File

@@ -1,6 +1,6 @@
import type {ElementHandle, Page} from "puppeteer";
import common from "../puppeteer_lib/common";
import * as common from "../puppeteer_lib/common";
async function test_subscription_button(page: Page): Promise<void> {
const stream_selector = "[data-stream-name='Venice']";

View File

@@ -2,7 +2,7 @@ import {strict as assert} from "assert";
import type {Page} from "puppeteer";
import common from "../puppeteer_lib/common";
import * as common from "../puppeteer_lib/common";
async function navigate_to_user_list(page: Page): Promise<void> {
const menu_selector = "#settings-dropdown";

View File

@@ -1,6 +1,6 @@
import type {Page} from "puppeteer";
import common from "../puppeteer_lib/common";
import * as common from "../puppeteer_lib/common";
async function open_set_user_status_modal(page: Page): Promise<void> {
const menu_icon_selector = ".user_sidebar_entry:first-child .user-list-sidebar-menu-icon";