diff --git a/.gitignore b/.gitignore index 1b8bedf2..3cf71228 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ vendor # Test files .phpunit.result.cache +artifacts/ diff --git a/tests/e2e/config/setup-test-framework.js b/tests/e2e/config/setup-test-framework.js index 45c9043a..d5353138 100644 --- a/tests/e2e/config/setup-test-framework.js +++ b/tests/e2e/config/setup-test-framework.js @@ -1,21 +1,18 @@ /** * External dependencies */ -import { get, isEqual, reduce, some, forEach } from 'lodash'; -import { matcherHint, printExpected, printReceived } from 'jest-matcher-utils'; /** * WordPress dependencies */ import { - activatePlugin, clearLocalStorage, enablePageDialogAccept, isOfflineMode, setBrowserViewport, switchUserToAdmin, switchUserToTest, - visitAdminPage, + visitAdminPage } from '@wordpress/e2e-test-utils'; /** @@ -125,7 +122,9 @@ function observeConsoleLogging() { // See: https://core.trac.wordpress.org/ticket/37000 // See: https://www.chromestatus.com/feature/5088147346030592 // See: https://www.chromestatus.com/feature/5633521622188032 - if ( text.includes( 'A cookie associated with a cross-site resource' ) ) { + if ( + text.includes( 'A cookie associated with a cross-site resource' ) + ) { return; } @@ -137,7 +136,10 @@ function observeConsoleLogging() { // Network errors are ignored only if we are intentionally testing // offline mode. - if ( text.includes( 'net::ERR_INTERNET_DISCONNECTED' ) && isOfflineMode() ) { + if ( + text.includes( 'net::ERR_INTERNET_DISCONNECTED' ) && + isOfflineMode() + ) { return; } @@ -146,6 +148,19 @@ function observeConsoleLogging() { return; } + // As of WordPress 5.3.2 in Chrome 79, navigating to the block editor + // (Posts > Add New) will display a console warning about + // non - unique IDs. + // See: https://core.trac.wordpress.org/ticket/23165 + if ( text.includes( 'elements with non-unique id #_wpnonce' ) ) { + return; + } + + // Ignore all JQMIGRATE (jQuery migrate) deprecation warnings. + if ( text.includes( 'JQMIGRATE' ) ) { + return; + } + const logFunction = OBSERVED_CONSOLE_MESSAGE_TYPES[ type ]; // As of Puppeteer 1.6.1, `message.text()` wrongly returns an object of @@ -159,7 +174,7 @@ function observeConsoleLogging() { // correctly. Instead, the logic here synchronously inspects the // internal object shape of the JSHandle to find the error text. If it // cannot be found, the default text value is used instead. - text = get( message.args(), [ 0, '_remoteObject', 'description' ], text ); + text = message.args()[ 0 ]?._remoteObject?.description ?? text; // Disable reason: We intentionally bubble up the console message // which, unless the test explicitly anticipates the logging via @@ -171,43 +186,6 @@ function observeConsoleLogging() { } ); } -/** - * Runs Axe tests when the block editor is found on the current page. - * - * @return {?Promise} Promise resolving once Axe texts are finished. - */ -async function runAxeTestsForBlockEditor() { - if ( ! await page.$( '.block-editor' ) ) { - return; - } - - await expect( page ).toPassAxeTests( { - // Temporary disabled rules to enable initial integration. - // See: https://github.com/WordPress/gutenberg/pull/15018. - disabledRules: [ - 'aria-allowed-role', - 'aria-hidden-focus', - 'aria-input-field-name', - 'aria-valid-attr-value', - 'button-name', - 'color-contrast', - 'dlitem', - 'duplicate-id', - 'label', - 'link-name', - 'listitem', - 'region', - 'heading-order' - ], - exclude: [ - // Ignores elements created by metaboxes. - '.edit-post-layout__metaboxes', - // Ignores elements created by TinyMCE. - '.mce-container', - ], - } ); -} - // Before every test suite run, delete all content created by the test. This ensures // other posts/comments/etc. aren't dirtying tests and tests don't depend on // each other's side-effects. @@ -221,7 +199,6 @@ beforeAll( async () => { } ); afterEach( async () => { - await runAxeTestsForBlockEditor(); await setupBrowser(); } );