puppeteer_tests: Don’t read from most deprecated global variables.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2021-02-09 19:51:11 -08:00
parent 5182505302
commit 34e37cea1c
4 changed files with 32 additions and 13 deletions

View File

@ -105,7 +105,15 @@
},
"overrides": [
{
"files": ["frontend_tests/**", "static/js/**"],
"files": ["frontend_tests/puppeteer_lib/**", "frontend_tests/puppeteer_tests/**"],
"globals": {
"$": false,
"current_msg_list": false,
"page_params": false
}
},
{
"files": ["frontend_tests/node_tests/**", "frontend_tests/zjsunit/**", "static/js/**"],
"globals": {
"$": false,
"FetchStatus": false,

View File

@ -39,9 +39,10 @@ class CommonUtils {
},
async expect(page, expected) {
const actual_recipients = await page.evaluate(() =>
compose_state.private_message_recipient(),
);
const actual_recipients = await page.evaluate(() => {
const compose_state = window.require("./static/js/compose_state");
return compose_state.private_message_recipient();
});
assert.equal(actual_recipients, expected);
},
};
@ -171,10 +172,10 @@ class CommonUtils {
}
async get_stream_id(page, stream_name) {
return await page.evaluate(
(stream_name) => stream_data.get_stream_id(stream_name),
stream_name,
);
return await page.evaluate((stream_name) => {
const stream_data = window.require("./static/js/stream_data");
return stream_data.get_stream_id(stream_name);
}, stream_name);
}
async get_user_id_from_name(page, name) {
@ -279,6 +280,7 @@ class CommonUtils {
- does it look to have been
re-rendered based on server info?
*/
const rows = window.require("./static/js/rows");
const last_msg = current_msg_list.last();
if (last_msg === undefined) {
return false;
@ -359,6 +361,7 @@ class CommonUtils {
// Close the compose box after sending the message.
await page.evaluate(() => {
const compose_actions = window.require("./static/js/compose_actions");
compose_actions.cancel();
});
// Make sure the compose box is closed.

View File

@ -57,7 +57,10 @@ async function test_reload_hash(page) {
const initial_hash = await page.evaluate(() => window.location.hash);
await page.evaluate(() => reload.initiate({immediate: true}));
await page.evaluate(() => {
const reload = window.require("./static/js/reload");
reload.initiate({immediate: true});
});
await page.waitForSelector("#zfilt", {visible: true});
const page_load_time = await page.evaluate(() => page_params.page_load_time);
@ -72,7 +75,10 @@ async function navigation_tests(page) {
await navigate_to_settings(page);
const verona_id = await page.evaluate(() => stream_data.get_stream_id("Verona"));
const verona_id = await page.evaluate(() => {
const stream_data = window.require("./static/js/stream_data");
return stream_data.get_stream_id("Verona");
});
const verona_narrow = `narrow/stream/${verona_id}-Verona`;
await navigate_to(page, verona_narrow, "message_feed_container");

View File

@ -17,10 +17,12 @@ async function test_mention(page) {
await common.ensure_enter_does_not_send(page);
console.log("Checking for all everyone warning");
const stream_size = await page.evaluate(() =>
stream_data.get_subscriber_count(stream_data.get_sub("Verona").stream_id),
);
const stream_size = await page.evaluate(() => {
const stream_data = window.require("./static/js/stream_data");
return stream_data.get_subscriber_count(stream_data.get_sub("Verona").stream_id);
});
const threshold = await page.evaluate(() => {
const compose = window.require("./static/js/compose");
compose.wildcard_mention_large_stream_threshold = 5;
return compose.wildcard_mention_large_stream_threshold;
});