diff --git a/.eslintrc.json b/.eslintrc.json index 392804daad..9e013ccc19 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -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, diff --git a/frontend_tests/puppeteer_lib/common.js b/frontend_tests/puppeteer_lib/common.js index 8eba08788f..d09bde6ee3 100644 --- a/frontend_tests/puppeteer_lib/common.js +++ b/frontend_tests/puppeteer_lib/common.js @@ -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. diff --git a/frontend_tests/puppeteer_tests/07-navigation.js b/frontend_tests/puppeteer_tests/07-navigation.js index cad967a15b..9f23d3b998 100644 --- a/frontend_tests/puppeteer_tests/07-navigation.js +++ b/frontend_tests/puppeteer_tests/07-navigation.js @@ -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"); diff --git a/frontend_tests/puppeteer_tests/09-mention.js b/frontend_tests/puppeteer_tests/09-mention.js index b3bfe0eca0..21f638f3af 100644 --- a/frontend_tests/puppeteer_tests/09-mention.js +++ b/frontend_tests/puppeteer_tests/09-mention.js @@ -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; });