diff --git a/.dev/tests/cypress/helpers.js b/.dev/tests/cypress/helpers.js index 3bf3d95a3c8..b60c1c54461 100644 --- a/.dev/tests/cypress/helpers.js +++ b/.dev/tests/cypress/helpers.js @@ -16,8 +16,15 @@ export function addFormChild( name ) { cy.get( '.components-popover__content button' ).contains( /insert after|add after/i ).click( { force: true } ); cy.get( '[data-type="coblocks/form"] [data-type="core/paragraph"]' ).click( { force: true } ); - cy.get( '.edit-post-header-toolbar' ).find( '.edit-post-header-toolbar__inserter-toggle' ).click( { force: true } ); - cy.get( '.block-editor-inserter__search .components-search-control__input' ).click().type( name ); + if ( isWP65AtLeast() ) { + cy.get( '.edit-post-header-toolbar' ).find( '.editor-document-tools__inserter-toggle' ).click( { force: true } ); + + cy.get( '.components-input-control__input' ).click().type( name ); + } else { + cy.get( '.edit-post-header-toolbar' ).find( '.edit-post-header-toolbar__inserter-toggle' ).click( { force: true } ); + + cy.get( '.block-editor-inserter__search .components-search-control__input' ).click().type( name ); + } cy.get( '.editor-block-list-item-coblocks-field-' + name ).first().click( { force: true } ); cy.get( `[data-type="coblocks/field-${ name }"]` ).should( 'exist' ).click( { force: true } ); @@ -137,8 +144,15 @@ export function addBlockToPost( blockName, clearEditor = false ) { export function addNewGroupToPost() { clearBlocks(); - cy.get( '.edit-post-header [aria-label="Add block"], .edit-site-header [aria-label="Add block"], .edit-post-header-toolbar__inserter-toggle' ).click(); - cy.get( '.block-editor-inserter__search-input,input.block-editor-inserter__search, .components-search-control__input' ).click().type( 'group' ); + if ( isWP65AtLeast() ) { + cy.get( '.editor-document-tools__inserter-toggle' ).click(); + + cy.get( '.components-input-control__input' ).click().type( 'group' ); + } else { + cy.get( '.edit-post-header [aria-label="Add block"], .edit-site-header [aria-label="Add block"], .edit-post-header-toolbar__inserter-toggle' ).click(); + + cy.get( '.block-editor-inserter__search-input,input.block-editor-inserter__search, .components-search-control__input' ).click().type( 'group' ); + } cy.wait( 1000 ); @@ -196,9 +210,15 @@ export function viewPage() { } } ); - cy.get( 'button[data-label="Post"]' ); + if ( isWP65AtLeast() ) { + cy.get( '[data-tab-id="edit-post/document"]' ); - cy.get( '.edit-post-post-url__dropdown button' ).click(); + cy.get( '.editor-post-url__panel-dropdown button' ).click(); + } else { + cy.get( 'button[data-label="Post"]' ); + + cy.get( '.edit-post-post-url__dropdown button' ).click(); + } cy.get( '.editor-post-url__link' ).then( ( pageLink ) => { const linkAddress = Cypress.$( pageLink ).attr( 'href' ); @@ -461,9 +481,14 @@ export function setColorPanelSetting( settingName, hexColor ) { * @param {RegExp} panelText The panel label text to open. eg: Color Settings */ export function openSettingsPanel( panelText ) { - // Ensure block tab is selected. - if ( Cypress.$( 'button[data-label="Block"]:not(.is-active)' ) ) { - cy.get( 'button[data-label="Block"]' ).click(); + if ( isWP65AtLeast() ) { + cy.get( '[data-tab-id="edit-post/block"]' ).click(); + } else { + // Ensure block tab is selected. + // eslint-disable-next-line no-lonely-if + if ( Cypress.$( 'button[data-label="Block"]:not(.is-active)' ) ) { + cy.get( 'button[data-label="Block"]' ).click(); + } } cy.get( '.components-panel__body' ) @@ -588,11 +613,14 @@ export function isNotWPLocalEnv() { } // A condition to determine if we are testing on WordPress 6.4+ -// This function should be removed in the process of the work for WP 6.5 compatibility export function isWP64AtLeast() { return Cypress.$( "[class*='branch-6-4']" ).length > 0 || Cypress.$( "[class*='branch-6-5']" ).length > 0; } +export function isWP65AtLeast() { + return Cypress.$( "[class*='branch-6-5']" ).length > 0 || Cypress.$( "[class*='branch-6-6']" ).length > 0; +} + function getIframeDocument( containerClass ) { return cy.get( containerClass + ' iframe' ).its( '0.contentDocument' ).should( 'exist' ); } diff --git a/.eslintrc.js b/.eslintrc.js index 0b64fbb6696..460d803164c 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -32,6 +32,7 @@ module.exports = { 'sort-imports': [ 'off' ], 'sort-keys': [ 'off' ], 'react/jsx-sort-props': [ 'off' ], + 'react-hooks/exhaustive-deps': [ 'off' ], }, noInlineConfig: false, diff --git a/.github/workflows/test-wp-next.yml b/.github/workflows/test-wp-next.yml index 6b75ff7120b..191feb1d66d 100644 --- a/.github/workflows/test-wp-next.yml +++ b/.github/workflows/test-wp-next.yml @@ -22,8 +22,8 @@ jobs: if: needs.check_if_released.outputs.should_run_workflow == 'true' runs-on: ubuntu-latest outputs: - # Should be current latest WP Next release on `wordpress.org`. eg: `https://wordpress.org/wordpress-6.4-RC3.zip` - wp_next: "https://wordpress.org/wordpress-6.4-RC3.zip" + # Should be current latest WP Next release on `wordpress.org`. eg: `https://wordpress.org/wordpress-6.5-beta2.zip` + wp_next: "https://wordpress.org/wordpress-6.5-RC1.zip" steps: - run: echo "Setting WP Next Constant" @@ -35,7 +35,7 @@ jobs: uses: ./.github/workflows/test-e2e-cypress.yml with: wpVersion: ${{ needs.set_constant.outputs.wp_next }} - installPath: "tests-wordpress-6.4-RC3" + installPath: "tests-wordpress-6.5-RC1" theme: "https://downloads.wordpress.org/theme/go.zip" concurrency: group: chrome-wp-next diff --git a/src/blocks/media-card/test/media-card.cypress.js b/src/blocks/media-card/test/media-card.cypress.js index c5057fd7e08..9b1c07c164b 100644 --- a/src/blocks/media-card/test/media-card.cypress.js +++ b/src/blocks/media-card/test/media-card.cypress.js @@ -1,14 +1,24 @@ +import { isWP65AtLeast } from '../../../../.dev/tests/cypress/helpers'; + describe( 'Test CoBlocks Media Card Block', function() { /** * Test that we can not insert a media-card block into the page. * Media-card blocks is deprecated and should not be usable. */ it( 'Test media-card block in not insertable.', function() { - cy.get( '.edit-post-header-toolbar' ).find( '.edit-post-header-toolbar__inserter-toggle' ).then( ( inserterButton ) => { - if ( ! Cypress.$( inserterButton ).hasClass( 'is-pressed' ) ) { - cy.get( inserterButton ).click(); - } - } ); + if ( isWP65AtLeast() ) { + cy.get( '.edit-post-header-toolbar' ).find( '.editor-document-tools__inserter-toggle' ).then( ( inserterButton ) => { + if ( ! Cypress.$( inserterButton ).hasClass( 'is-pressed' ) ) { + cy.get( inserterButton ).click(); + } + } ); + } else { + cy.get( '.edit-post-header-toolbar' ).find( '.edit-post-header-toolbar__inserter-toggle' ).then( ( inserterButton ) => { + if ( ! Cypress.$( inserterButton ).hasClass( 'is-pressed' ) ) { + cy.get( inserterButton ).click(); + } + } ); + } cy.get( '.block-editor-inserter__search' ).find( 'input' ).clear(); cy.get( '.block-editor-inserter__search' ).click().type( 'media-card' ); diff --git a/src/components/media-filter-control/test/media-filter-control.cypress.js b/src/components/media-filter-control/test/media-filter-control.cypress.js index 59931b56d8d..6b37eedc0f4 100644 --- a/src/components/media-filter-control/test/media-filter-control.cypress.js +++ b/src/components/media-filter-control/test/media-filter-control.cypress.js @@ -2,6 +2,7 @@ * Include our constants */ import * as helpers from '../../../../.dev/tests/cypress/helpers'; +import { isWP65AtLeast } from '../../../../.dev/tests/cypress/helpers'; const filters = [ 'Original', @@ -95,8 +96,12 @@ describe( 'Test CoBlocks Media Filter Control component', function() { helpers.upload.imageToBlock( 'core/gallery' ); helpers.selectBlock( 'core/gallery' ); - cy.get( '.components-tab-panel__tab-content' ); - cy.get( '.block-editor-block-toolbar__slot .components-coblocks-media-filter' ).click(); + if ( isWP65AtLeast() ) { + cy.get( '.components-coblocks-media-filter' ).click(); + } else { + cy.get( '.components-tab-panel__tab-content' ); + cy.get( '.block-editor-block-toolbar__slot .components-coblocks-media-filter' ).click(); + } let childIteration = 1;