Skip to content

Commit

Permalink
E2E Test Utils: Improve test reliability in plugins/themes and login …
Browse files Browse the repository at this point in the history
…procedures (#52144)

* Create logical promise ordering for navigation watchers.

By Creating the promise for navigations before attempting the navigation, we ensure that there's no risk of race conditions where one promise triggers before the other, leaving the navigation watcher in limbo.

* Add heightened timeout values when waiting for plugins or themes to be installed.

Plugin and theme installations are dependent on external factors, such as WordPress.org availability, disk read/writes, and such. Some inconsistent test runs were traced back to prolonged time needed to install either, causing false positive test failures.

* Update packages/e2e-test-utils/src/install-plugin.js

* Update packages/e2e-test-utils/src/install-theme.js

* Allow linting to pass

---------

Co-authored-by: Ari Stathopoulos <aristath@gmail.com>
Co-authored-by: Sergey Biryukov <sergeybiryukov.ru@gmail.com>
  • Loading branch information
3 people authored Jul 10, 2023
1 parent b0a3ef9 commit de251b6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 3 additions & 1 deletion packages/e2e-test-utils/src/install-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export async function installPlugin( slug, searchTerm ) {
'&tab=search&type=term'
);
await page.click( `.install-now[data-slug="${ slug }"]` );
await page.waitForSelector( `.activate-now[data-slug="${ slug }"]` );
await page.waitForSelector( `.activate-now[data-slug="${ slug }"]`, {
timeout: 60000,
} );
await switchUserToTest();
}
4 changes: 3 additions & 1 deletion packages/e2e-test-utils/src/install-theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ export async function installTheme( slug, { searchTerm } = {} ) {

await page.waitForSelector( `.theme-install[data-slug="${ slug }"]` );
await page.click( `.theme-install[data-slug="${ slug }"]` );
await page.waitForSelector( `.theme[data-slug="${ slug }"] .activate` );
await page.waitForSelector( `.theme[data-slug="${ slug }"] .activate`, {
timeout: 60000,
} );
await switchUserToTest();
}
8 changes: 4 additions & 4 deletions packages/e2e-test-utils/src/login-user.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ export async function loginUser(
password = WP_PASSWORD
) {
if ( ! isCurrentURL( 'wp-login.php' ) ) {
const waitForLoginPageNavigation = page.waitForNavigation();
await page.goto( createURL( 'wp-login.php' ) );
await waitForLoginPageNavigation;
}

await page.focus( '#user_login' );
Expand All @@ -27,8 +29,6 @@ export async function loginUser(
await pressKeyWithModifier( 'primary', 'a' );
await page.type( '#user_pass', password );

await Promise.all( [
page.waitForNavigation(),
page.click( '#wp-submit' ),
] );
const waitForLoginNavigation = page.waitForNavigation();
await Promise.all( [ waitForLoginNavigation, page.click( '#wp-submit' ) ] );
}

1 comment on commit de251b6

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in de251b6.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5506200864
📝 Reported issues:

Please sign in to comment.