mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 06:23:38 +00:00
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:
committed by
Tim Abbott
parent
53cf974b89
commit
663f1a387d
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,7 @@ import {strict as assert} from "assert";
|
|||||||
|
|
||||||
import type {ElementHandle, Page} from "puppeteer";
|
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> {
|
async function submit_notifications_stream_settings(page: Page): Promise<void> {
|
||||||
await page.waitForSelector('#org-submit-notifications[data-status="unsaved"]', {visible: true});
|
await page.waitForSelector('#org-submit-notifications[data-status="unsaved"]', {visible: true});
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {strict as assert} from "assert";
|
|||||||
|
|
||||||
import type {ElementHandle, Page} from "puppeteer";
|
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> {
|
async function check_compose_form_empty(page: Page): Promise<void> {
|
||||||
await common.check_form_contents(page, "#send_message_form", {
|
await common.check_form_contents(page, "#send_message_form", {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {strict as assert} from "assert";
|
|||||||
|
|
||||||
import type {Page} from "puppeteer";
|
import type {Page} from "puppeteer";
|
||||||
|
|
||||||
import common from "../puppeteer_lib/common";
|
import * as common from "../puppeteer_lib/common";
|
||||||
|
|
||||||
async function copy_messages(
|
async function copy_messages(
|
||||||
page: Page,
|
page: Page,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {strict as assert} from "assert";
|
|||||||
|
|
||||||
import type {Page} from "puppeteer";
|
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.
|
// 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)";
|
const profile_field_row = "#admin_profile_fields_table tr:nth-last-child(1)";
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import type {Page} from "puppeteer";
|
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> {
|
async function click_delete_and_return_last_msg_id(page: Page): Promise<string | undefined> {
|
||||||
return await page.evaluate(() => {
|
return await page.evaluate(() => {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {strict as assert} from "assert";
|
|||||||
|
|
||||||
import type {Page} from "puppeteer";
|
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> {
|
async function wait_for_drafts_to_disappear(page: Page): Promise<void> {
|
||||||
await page.waitForFunction(
|
await page.waitForFunction(
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import type {Page} from "puppeteer";
|
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> {
|
async function trigger_edit_last_message(page: Page): Promise<void> {
|
||||||
await page.evaluate(() => {
|
await page.evaluate(() => {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {strict as assert} from "assert";
|
|||||||
|
|
||||||
import type {Page} from "puppeteer";
|
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> {
|
async function test_mention(page: Page): Promise<void> {
|
||||||
await common.log_in(page);
|
await common.log_in(page);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {strict as assert} from "assert";
|
|||||||
|
|
||||||
import type {Page} from "puppeteer";
|
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> {
|
async function get_stream_li(page: Page, stream_name: string): Promise<string> {
|
||||||
const stream_id = await common.get_stream_id(page, stream_name);
|
const stream_id = await common.get_stream_id(page, stream_name);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {strict as assert} from "assert";
|
|||||||
|
|
||||||
import type {Page} from "puppeteer";
|
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> {
|
async function wait_for_tab(page: Page, tab: string): Promise<void> {
|
||||||
const tab_slector = `#${CSS.escape(tab)}.tab-pane`;
|
const tab_slector = `#${CSS.escape(tab)}.tab-pane`;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {strict as assert} from "assert";
|
|||||||
|
|
||||||
import type {Page} from "puppeteer";
|
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 email = "alice@test.example.com";
|
||||||
const subdomain = "testsubdomain";
|
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
|
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.
|
// 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);
|
common.run_test(realm_creation_tests);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {strict as assert} from "assert";
|
|||||||
|
|
||||||
import type {Page} from "puppeteer";
|
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> {
|
async function test_add_linkifier(page: Page): Promise<void> {
|
||||||
await page.waitForSelector(".admin-linkifier-form", {visible: true});
|
await page.waitForSelector(".admin-linkifier-form", {visible: true});
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {strict as assert} from "assert";
|
|||||||
|
|
||||||
import type {Page} from "puppeteer";
|
import type {Page} from "puppeteer";
|
||||||
|
|
||||||
import common from "../puppeteer_lib/common";
|
import * as common from "../puppeteer_lib/common";
|
||||||
|
|
||||||
type Playground = {
|
type Playground = {
|
||||||
playground_name: string;
|
playground_name: string;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import {strict as assert} from "assert";
|
|||||||
import type {Page} from "puppeteer";
|
import type {Page} from "puppeteer";
|
||||||
|
|
||||||
import {test_credentials} from "../../var/puppeteer/test_credentials";
|
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 OUTGOING_WEBHOOK_BOT_TYPE = "3";
|
||||||
const GENERIC_BOT_TYPE = "1";
|
const GENERIC_BOT_TYPE = "1";
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {strict as assert} from "assert";
|
|||||||
|
|
||||||
import type {Page} from "puppeteer";
|
import type {Page} from "puppeteer";
|
||||||
|
|
||||||
import common from "../puppeteer_lib/common";
|
import * as common from "../puppeteer_lib/common";
|
||||||
|
|
||||||
const message = "test star";
|
const message = "test star";
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {strict as assert} from "assert";
|
|||||||
|
|
||||||
import type {Page} from "puppeteer";
|
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> {
|
async function user_row_selector(page: Page, name: string): Promise<string> {
|
||||||
const user_id = await common.get_user_id_from_name(page, name);
|
const user_id = await common.get_user_id_from_name(page, name);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import type {ElementHandle, Page} from "puppeteer";
|
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> {
|
async function test_subscription_button(page: Page): Promise<void> {
|
||||||
const stream_selector = "[data-stream-name='Venice']";
|
const stream_selector = "[data-stream-name='Venice']";
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {strict as assert} from "assert";
|
|||||||
|
|
||||||
import type {Page} from "puppeteer";
|
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> {
|
async function navigate_to_user_list(page: Page): Promise<void> {
|
||||||
const menu_selector = "#settings-dropdown";
|
const menu_selector = "#settings-dropdown";
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import type {Page} from "puppeteer";
|
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> {
|
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";
|
const menu_icon_selector = ".user_sidebar_entry:first-child .user-list-sidebar-menu-icon";
|
||||||
|
|||||||
Reference in New Issue
Block a user