Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E2E Tests: Run tests against WP 5.9 RC1 #10101

Merged
merged 14 commits into from
Jan 11, 2022
4 changes: 4 additions & 0 deletions .github/workflows/tests-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ jobs:
- browser: 'chrome'
wp: 'latest'
snapshots: true
- browser: 'chrome'
wp: '5.9-RC1'
experimental: true
snapshots: false
- browser: 'chrome'
wp: '5.5'
snapshots: false
Expand Down
12 changes: 8 additions & 4 deletions packages/e2e-test-utils/src/trashAllTerms.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,14 @@ async function trashAllTerms(taxonomy) {

await visitAdminPage('edit-tags.php', `taxonomy=${taxonomy}`);

await page.waitForSelector('[id^=cb-select-all-]');
await page.click('[id^=cb-select-all-]');
await page.select('#bulk-action-selector-top', 'delete');
await Promise.all([page.waitForNavigation(), page.click('#doaction')]);
// If this selector doesn't exist there are no terms for us to delete.
const bulkSelector = await page.$('#bulk-action-selector-top');
if (bulkSelector) {
await page.waitForSelector('[id^=cb-select-all-]');
await page.click('[id^=cb-select-all-]');
await page.select('#bulk-action-selector-top', 'delete');
await Promise.all([page.waitForNavigation(), page.click('#doaction')]);
}

await setCurrentUser(currentUser.username, currentUser.password);
}
Expand Down
32 changes: 23 additions & 9 deletions packages/e2e-test-utils/src/visitBlockWidgetScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,34 @@ import visitAdminPage from './visitAdminPage';
* @return {Promise<void>}
*/
async function visitBlockWidgetScreen() {
const WPVersion = process.env?.WP_VERSION;
await visitAdminPage('widgets.php');

// Disable welcome guide if it is enabled.
const isWelcomeGuideActive = await page.evaluate(() =>
wp.data
.select('core/edit-widgets')
.__unstableIsFeatureActive('welcomeGuide')
);
const isWelcomeGuideActive = await page.evaluate((version) => {
// TODO Change after 5.9 release.
if ('latest' === version) {
return wp.data
.select('core/edit-widgets')
.__unstableIsFeatureActive('welcomeGuide');
}
return wp.data
.select('core/interface')
.isFeatureActive('core/edit-widgets', 'welcomeGuide');
}, WPVersion);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the version check really needed? Didn't it work the way you had it before, by checking whether the functions exist?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would love another way around doing this check.

Copy link
Collaborator

@swissspidy swissspidy Jan 7, 2022

Choose a reason for hiding this comment

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

Hmm sounds like all that is needed is some conditional check, perhaps easiest with optional chaining (?.) ,to avoid the isFeatureActive is not a function error.

// Disable welcome guide if it is enabled.

// The former selector is for WP < 5.9
const isWelcomeGuideActive = await page.evaluate(() => {
  return wp.data.select('core/edit-widgets')?.__unstableIsFeatureActive?.('welcomeGuide') ||
  wp.data.select( 'core/interface' )?.isFeatureActive?.( 'core/edit-widgets', 'welcomeGuide' );
});

if (isWelcomeGuideActive) {
  // The former action is for WP < 5.9
  await page.evaluate(() => {
    wp.data.dispatch('core/edit-widgets')?.__unstableToggleFeature?.('welcomeGuide');
    wp.data.dispatch( 'core/interface' )?.toggleFeature?.( 'core/edit-widgets', 'welcomeGuide' );
  });
}

if (isWelcomeGuideActive) {
await page.evaluate(() =>
await page.evaluate((version) => {
// TODO Change after 5.9 release.
if ('latest' === version) {
wp.data
.dispatch('core/edit-widgets')
.__unstableToggleFeature('welcomeGuide');
return;
}
wp.data
.dispatch('core/edit-widgets')
.__unstableToggleFeature('welcomeGuide')
);
.dispatch('core/interface')
.toggleFeature('core/edit-widgets', 'welcomeGuide');
}, WPVersion);
}
}
export default visitBlockWidgetScreen;
7 changes: 7 additions & 0 deletions packages/e2e-tests/src/config/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ const ALLOWED_ERROR_MESSAGES = [

// Another Firefox warning.
'Layout was forced before the page was fully loaded',

// Upsteam issue in gutenberg and twentytwenty theme.
'Stylesheet twentytwenty-block-editor-styles-css was not properly added.',

// deprecated notice in 5.9.
// @todo fix issue.
spacedmonkey marked this conversation as resolved.
Show resolved Hide resolved
"select( 'core' ).getAuthors() is deprecated since version 5.9.",
];

export function addAllowedErrorMessage(message) {
Expand Down
2 changes: 1 addition & 1 deletion packages/e2e-tests/src/specs/wordpress/blockWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('Web Stories Widget Block', () => {
it('should insert a new web stories block', async () => {
await visitBlockWidgetScreen();
await expect(page).toClick('button[aria-label="Add block"]');
await page.type('.block-editor-inserter__search-input', 'Web Stories');
await page.type('input[placeholder="Search"]', 'Web Stories');
spacedmonkey marked this conversation as resolved.
Show resolved Hide resolved
await expect(page).toClick('button span', { text: 'Web Stories' });

await page.waitForSelector('.web-stories-block-configuration-panel');
Expand Down