Skip to content

Commit

Permalink
package(e2e-test-utils): update fixtures (#54128)
Browse files Browse the repository at this point in the history
* Update `activatePlugin` to redirect to `plugins.php` after plugin activation

* Update `activateTheme` to redirect to `themes.php` after theme activation

* Update promises order in `loginUser`

* Fix `isCurrentURL` import

* Add changelog for latest enhancements in `e2e-test-utils`
  • Loading branch information
thelovekesh committed Sep 4, 2023
1 parent 6830aec commit d711a96
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
6 changes: 6 additions & 0 deletions packages/e2e-test-utils/CHANGELOG.md
Expand Up @@ -2,6 +2,12 @@

## Unreleased

### Enhancement

- Update promise order in `loginUser` to avoid any flakiness in the tests.
- Update `activateTheme` to redirect to `themes.php` after theme activation, if theme redirects to some other page.
- Update `activatePlugin` to redirect to `plugins.php` after plugin activation, if plugin redirects to some other page.

## 10.12.0 (2023-08-31)

## 10.11.0 (2023-08-16)
Expand Down
5 changes: 5 additions & 0 deletions packages/e2e-test-utils/src/activate-plugin.js
Expand Up @@ -4,6 +4,7 @@
import { switchUserToAdmin } from './switch-user-to-admin';
import { switchUserToTest } from './switch-user-to-test';
import { visitAdminPage } from './visit-admin-page';
import { isCurrentURL } from './is-current-url';

/**
* Activates an installed plugin.
Expand All @@ -21,6 +22,10 @@ export async function activatePlugin( slug ) {
return;
}
await page.click( `tr[data-slug="${ slug }"] .activate a` );

if ( ! isCurrentURL( 'plugins.php' ) ) {
await visitAdminPage( 'plugins.php' );
}
await page.waitForSelector( `tr[data-slug="${ slug }"] .deactivate a` );
await switchUserToTest();
}
5 changes: 5 additions & 0 deletions packages/e2e-test-utils/src/activate-theme.js
Expand Up @@ -4,6 +4,7 @@
import { switchUserToAdmin } from './switch-user-to-admin';
import { switchUserToTest } from './switch-user-to-test';
import { visitAdminPage } from './visit-admin-page';
import { isCurrentURL } from './is-current-url';

/**
* Activates an installed theme.
Expand All @@ -23,6 +24,10 @@ export async function activateTheme( slug ) {
}

await page.click( `div[data-slug="${ slug }"] .button.activate` );

if ( ! isCurrentURL( 'themes.php' ) ) {
await visitAdminPage( 'themes.php' );
}
await page.waitForSelector( `div[data-slug="${ slug }"].active` );
await switchUserToTest();
}
6 changes: 4 additions & 2 deletions packages/e2e-test-utils/src/login-user.js
Expand Up @@ -29,6 +29,8 @@ export async function loginUser(
await pressKeyWithModifier( 'primary', 'a' );
await page.type( '#user_pass', password );

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

1 comment on commit d711a96

@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 d711a96.
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/6070672827
📝 Reported issues:

Please sign in to comment.