Skip to content

Commit

Permalink
Bump workflow for 6.5 version (#2590)
Browse files Browse the repository at this point in the history
* bump the workflow for wp next

* RC1

* Start fixes for WP 6.5

* More fixes

* Fix Form block test

* Fix padding controls test

* Fix media filter control test

* Remove exhaustive deps eslint warning

* revert date to not trigger test-wp-next flow on main

---------

Co-authored-by: aledesma-godaddy <[email protected]>
Co-authored-by: Olivier Lafleur <[email protected]>
  • Loading branch information
3 people authored Mar 12, 2024
1 parent 4463d19 commit 9c358fa
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 20 deletions.
48 changes: 38 additions & 10 deletions .dev/tests/cypress/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 } );
Expand Down Expand Up @@ -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 );

Expand Down Expand Up @@ -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' );
Expand Down Expand Up @@ -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' )
Expand Down Expand Up @@ -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' );
}
Expand Down
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ module.exports = {
'sort-imports': [ 'off' ],
'sort-keys': [ 'off' ],
'react/jsx-sort-props': [ 'off' ],
'react-hooks/exhaustive-deps': [ 'off' ],
},

noInlineConfig: false,
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test-wp-next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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
Expand Down
20 changes: 15 additions & 5 deletions src/blocks/media-card/test/media-card.cypress.js
Original file line number Diff line number Diff line change
@@ -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' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 9c358fa

Please sign in to comment.