Skip to content

Commit 3bd1ac0

Browse files
author
Nicholas Ray
committed
Replace jsReady.js and moduleReady.js with waitForNetworkIdle call
jsReady.js and moduleReady.js effectively wait for various JS resource loader modules to load which can be tedious to write and error prone. There might be a better and more future-proof alternative by waiting for the network to idle instead. Therefore, this commit: * Replaces all usages of waitForModule with waitForNetworkIdle * Removes moduleReady.js and jsReady.js
1 parent 9905041 commit 3bd1ac0

5 files changed

Lines changed: 7 additions & 76 deletions

File tree

src/engine-scripts/puppet/echo.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
const moduleReady = require( './moduleReady' );
2-
31
/**
42
* Setup Echo notifications
53
*
@@ -15,15 +13,12 @@ module.exports = async ( page, hashtags ) => {
1513

1614
// Open the drawer for tests that require interaction
1715
if ( hashtags.includes( '#echo-drawer' ) ) {
18-
await moduleReady( page, 'ext.echo.init' );
1916
await page.evaluate( async () => {
2017
const btn = document.querySelector( '#pt-notifications-alert a' );
2118
btn.click();
2219
} );
23-
await moduleReady(
24-
page,
25-
hashtags.includes( '#mobile' ) ? 'ext.echo.mobile' : 'ext.echo.ui.desktop'
26-
);
20+
// Wait for JS to load.
21+
await page.waitForNetworkIdle();
2722

2823
// Wait for the OOUI pending element to disappear.
2924
await page.waitForSelector( '.oo-ui-pendingElement-pending', {

src/engine-scripts/puppet/jsReady.js

Lines changed: 0 additions & 44 deletions
This file was deleted.

src/engine-scripts/puppet/moduleReady.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/engine-scripts/puppet/onReady.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ module.exports = async ( page, scenario ) => {
1212
const label = scenario.label;
1313
const hashtags = label.match( /(#[^ ,)]*)/g ) || [];
1414

15-
// Make sure the main skin JavaScript module has loaded.
16-
await require( './jsReady' )( page, hashtags );
15+
// Wait for async js to finish loading.
16+
await page.waitForNetworkIdle();
1717

1818
if ( hashtags.includes( '#scroll' ) ) {
1919
await require( './scroll.js' )( page );

src/engine-scripts/puppet/search.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const moduleReady = require( './moduleReady' );
21
const fastForwardAnimations = require( './fastForwardAnimations' );
32

43
/**
@@ -49,8 +48,9 @@ module.exports = async ( page, hashtags ) => {
4948
} else {
5049
// Make sure Codex kicked in.
5150
await page.waitForSelector( '.cdx-typeahead-search' );
52-
// Wait for Vue to load.
53-
await moduleReady( page, 'vue' );
51+
52+
// Wait for JS to load.
53+
await page.waitForNetworkIdle();
5454
// focus and type into the newly added input
5555
await page.focus( selectorSearchInput );
5656
await page.keyboard.type( 't' );

0 commit comments

Comments
 (0)