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

Compatibility with WP 6.4 #2568

Merged
merged 40 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
c61b063
Remove scaffolding for WP 6.3
olafleur-godaddy Sep 18, 2023
8322342
Do not test on 6.2 anymore
olafleur-godaddy Sep 18, 2023
07d2d85
Fix Pricing Table Item test
olafleur-godaddy Sep 27, 2023
e141350
try something else
olafleur-godaddy Sep 27, 2023
cc2b3f6
not yet 6.4
olafleur-godaddy Sep 27, 2023
7612728
Merge branch 'master' into WP64-compat
olafleur-godaddy Oct 3, 2023
ce35d5c
Skip two layout selector tests for the moment
olafleur-godaddy Oct 11, 2023
1d3a211
Forgot a skip
olafleur-godaddy Oct 11, 2023
68882d2
try using new workflow
aledesma-godaddy Oct 20, 2023
937c50d
add a step to flow
aledesma-godaddy Oct 20, 2023
de3a61e
try more flows
aledesma-godaddy Oct 20, 2023
346c08d
reference workflow version
aledesma-godaddy Oct 20, 2023
3f18c56
correct path for workflows
aledesma-godaddy Oct 20, 2023
7aa2537
remove version :|
aledesma-godaddy Oct 20, 2023
570e8cc
correct variable naming
aledesma-godaddy Oct 20, 2023
d17998a
more workflow changes
aledesma-godaddy Oct 20, 2023
aaa064e
fix syntax for npx command
aledesma-godaddy Oct 20, 2023
8e87eab
allow custom path on e2e
aledesma-godaddy Oct 20, 2023
436f5a5
Merge branch 'master' into WP64-compat
AnthonyLedesma Oct 20, 2023
082e5d3
try pricing refactor
aledesma-godaddy Oct 20, 2023
4df5272
refactors to pricing table and update deps for tests
aledesma-godaddy Oct 24, 2023
6199353
update the deps and tests
aledesma-godaddy Oct 24, 2023
80ef230
apply mass lint fixes & composer deps update
aledesma-godaddy Oct 24, 2023
5744e52
test against 6.4rc2 now
aledesma-godaddy Oct 25, 2023
86488d4
debug workflow
aledesma-godaddy Oct 26, 2023
b61fb6a
add theme to wp next testing
aledesma-godaddy Oct 26, 2023
ef38fd9
fix layout selector tests and run all tests
aledesma-godaddy Oct 26, 2023
15cc800
update workflow logic
aledesma-godaddy Oct 26, 2023
2321fdf
bug fix in unit test matrix
aledesma-godaddy Oct 26, 2023
13fbcd3
update test selectors for backward compat
aledesma-godaddy Oct 27, 2023
f9028b3
fix helper logic
aledesma-godaddy Oct 27, 2023
945854a
improvements around test workflows and fix media filter tests
aledesma-godaddy Oct 27, 2023
39d965c
workflow logic
aledesma-godaddy Oct 27, 2023
70b828e
try to fix that race conditon in when inserting and selecting blocks
aledesma-godaddy Oct 30, 2023
5b067e6
more selectors in helpers
aledesma-godaddy Oct 30, 2023
c03da06
Merge branch 'master' into WP64-compat
AnthonyLedesma Oct 31, 2023
f32da23
bump to rc3
aledesma-godaddy Oct 31, 2023
6a489a2
oh right, rc3 is out tomorrow
aledesma-godaddy Oct 31, 2023
c642a36
fix block deprecation, typo fixes
aledesma-godaddy Oct 31, 2023
8d67d51
css fix
aledesma-godaddy Oct 31, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 33 additions & 26 deletions .dev/tests/cypress/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,19 +275,29 @@ export function selectBlock( name ) {
* For that reason is difficult to assert against those requests from core code.
* We introduce an arbitrary wait to avoid a race condition by interacting too quickly.
*/
cy.wait( 1000 );
cy.wait( 600 );

let id = ''; // The block client ID.
cy.window().then( ( win ) => {
// Prefer selector from data-store.
id = win.wp.data.select( 'core/block-editor' ).getBlocks().filter( ( i ) => i?.name === name )[ 0 ]?.clientId;

// Fallback to selector from DOM.
if ( ! id ) {
cy.get( `[data-type*="${ name }"], [data-title*="${ name }"]` )
.invoke( 'attr', 'data-block' )
.then( ( clientId ) => id = clientId );
}
} );

// `data-type` includes lower case name and `data-title` includes upper case name.
// Allows for case-insensitive search.
cy.get( `[data-type*="${ name }"], [data-title*="${ name }"]` )
.invoke( 'attr', 'data-block' )
.then( ( clientId ) => {
cy.window().then( ( win ) => {
// Open the block sidebar.
win.wp.data.dispatch( 'core/edit-post' ).openGeneralSidebar( 'edit-post/block' );
win.wp.data.dispatch( 'core/block-editor' ).selectBlock( clientId );
} );
} );
cy.window().then( ( win ) => {
win.wp.data.dispatch( 'core/block-editor' ).selectBlock( id );
} );

cy.window().then( ( win ) => {
win.wp.data.dispatch( 'core/edit-post' ).openGeneralSidebar( 'edit-post/block' );
} );
cy.wait( 600 );
}

/**
Expand Down Expand Up @@ -408,6 +418,11 @@ export const upload = {
},
};

const customColorPalatteSelector = ( () => [
'.components-color-palette__custom-color-button', // WP 6.3+
'.components-color-palette__custom-color', // WP 6.2.
].join() )();

/**
* Set a Color Setting value to a custom hex color
*
Expand All @@ -419,11 +434,7 @@ export function setColorSettingsFoldableSetting( settingName, hexColor ) {

cy.get( '.block-editor-panel-color-gradient-settings__dropdown' ).contains( settingName, { matchCase: false } ).click();

if ( isWP63AtLeast() ) {
cy.get( '.components-color-palette__custom-color-button' ).click();
} else {
cy.get( '.components-color-palette__custom-color' ).click();
}
cy.get( customColorPalatteSelector ).click();

cy.get( '.components-color-picker' ).find( '.components-input-control__input' ).click().clear().type( formattedHex );

Expand All @@ -437,11 +448,7 @@ export function setColorPanelSetting( settingName, hexColor ) {

cy.get( '.block-editor-panel-color-gradient-settings__dropdown' ).contains( settingName, { matchCase: false } ).click();

if ( isWP63AtLeast() ) {
cy.get( '.components-color-palette__custom-color-button' ).click();
} else {
cy.get( '.components-color-palette__custom-color' ).click();
}
cy.get( customColorPalatteSelector ).click();

cy.get( '.components-color-picker' ).find( '.components-input-control__input' ).click().clear().type( formattedHex );

Expand Down Expand Up @@ -580,10 +587,10 @@ export function isNotWPLocalEnv() {
return Cypress.env( 'testURL' ) !== 'http://localhost:8889';
}

// A condition to determine if we are testing on WordPress 6.3+
// This function should be removed in the process of the work for WP 6.4 compatibility
export function isWP63AtLeast() {
return Cypress.$( "[class*='branch-6-3']" ).length > 0 || Cypress.$( "[class*='branch-6-4']" ).length > 0;
// 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;
}

function getIframeDocument( containerClass ) {
Expand Down
6 changes: 4 additions & 2 deletions .dev/tests/jest/assets-transformer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const path = require( 'path' );

module.exports = {
process( src, filename ) {
return 'module.exports = ' + JSON.stringify( path.basename( filename ) ) + ';';
process( sourceText, sourcePath ) {
return {
code: `module.exports = ${ JSON.stringify( path.basename( sourcePath ) ) };`,
};
},
};
6 changes: 6 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ module.exports = {
browser: true,
'cypress/globals': true,
jest: true,
'jest/globals': true,
},
plugins: [
'cypress',
'react',
'jest',
],

// Specific Globals used in CoBlocks
Expand All @@ -30,6 +33,9 @@ module.exports = {
'sort-keys': [ 'off' ],
'react/jsx-sort-props': [ 'off' ],
},

noInlineConfig: false,

overrides: [
{
files: [ 'deprecated.js', 'save.js' ],
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/date-checker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# .github/workflows/date-checker.yml
name: Date Checker Workflow

on:
workflow_call:
inputs:
scheduled_release_date:
required: true
type: string
outputs:
should_run_workflow:
description: "String as `true` or `false` indicating if the workflow should run"
value: ${{jobs.check_date.outputs.should_run_workflow}}

jobs:
check_date:
runs-on: ubuntu-latest
outputs:
should_run_workflow: ${{ steps.date_check.outputs.should_run_workflow }}
steps:
- name: Check if workflow should run
id: date_check
env:
# Get release cut off date
SCHEDULED_RELEASE_DATE: ${{github.event.inputs.scheduled_release_date}}
run: |
SCHEDULED_RELEASE_DATE_UNIX=$(date -d "$SCHEDULED_RELEASE_DATE" +%s)
current_date=$(date +%s)
if [[ $current_date -lt $SCHEDULED_RELEASE_DATE_UNIX ]]; then
echo "should_run_workflow=false" >> $GITHUB_OUTPUT
else
echo "should_run_workflow=true" >> $GITHUB_OUTPUT
fi
11 changes: 8 additions & 3 deletions .github/workflows/test-e2e-cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ on:
required: false
type: string
default: "8.2"
installPath:
required: false
type: string
default: "tests-WordPress"
secrets:
record-key:
description: 'Record key for Cypress Dashboard'
Expand Down Expand Up @@ -92,6 +96,7 @@ jobs:
plugins: '["."]'
themes: '["https://downloads.wordpress.org/theme/go.zip"]'


- name: Setup Node
uses: actions/setup-node@v3
with:
Expand All @@ -107,14 +112,14 @@ jobs:
run: |
npx grunt build
# moving the built directory to this location means no dev files in tests-container.
mv ./build/coblocks $(wp-env install-path)/tests-WordPress/wp-content/plugins/
mv ./build/coblocks $(wp-env install-path)/${{ inputs.installPath }}/wp-content/plugins/

- name: Prepare Theme
run: |
if [ "${{ inputs.theme }}" = "https://downloads.wordpress.org/theme/go.zip" ]; then
if [ "$theme_url" = "https://downloads.wordpress.org/theme/go.zip" ]; then
cd $(wp-env install-path)/go
else
cd $(wp-env install-path)/tests-WordPress/wp-content/themes/twentytwentythree
cd $(wp-env install-path)/${{ inputs.installPath }}/wp-content/themes/twentytwentythree
fi
mkdir -p coblocks/icons
echo '<svg height="20" viewBox="0 0 20 20" width="20" xmlns="http://www.w3.org/2000/svg"><circle class="inner-circle" cx="20" cy="20" r="8" stroke-width="8" stroke-dasharray="50.2655 50.2655" stroke-dashoffset="0"></circle></svg>' >> coblocks/icons/custom.svg
Expand Down
79 changes: 35 additions & 44 deletions .github/workflows/test-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,51 +6,42 @@ on:
- master

jobs:
# Requires re-working our helpers to be backward compat.
# chrome_e2e_major_before_previous_major:
# name: Chrome with major before previous major WP version
# uses: ./.github/workflows/test-e2e-cypress.yml
# with:
# wpVersion: "WordPress/WordPress#6.1"
# concurrency:
# group: chrome-defaults-major-before-previous-major
# cancel-in-progress: true

chrome_e2e_previous_major:
name: Chrome with previous major WP version
chrome_e2e_gamut_tests:
name: >
E2E - ${{
format(
'WP{0} + PHP{1} + {2} theme',
matrix.wp,
matrix.php,
matrix.theme == '' && 'TwentyTwentyThree' || 'Go'
)
}}
uses: ./.github/workflows/test-e2e-cypress.yml
strategy:
fail-fast: false
matrix:
wp: # Test against Prev-Prev Major, Prev-Major, and current Major release versions.
- "6.2"
- "6.3"
# - "6.4" Should enable this when 6.4 is released.
theme:
- "https://downloads.wordpress.org/theme/go.zip"
- "" # Default theme is TwentyTwentyThree
php: # Test against minimum and latest PHP versions.
- "7.4"
- "8.2"
with:
wpVersion: "WordPress/WordPress#6.2"
wpVersion: "WordPress/WordPress#${{matrix.wp}}"
theme: ${{matrix.theme}}
phpVersion: ${{matrix.php}}
concurrency:
group: chrome-defaults-previous-major
group: >
${{
format(
'chrome-e2e-WP{0}-PHP{1}-{2}',
matrix.wp,
matrix.php,
matrix.theme == '' && 'twentytwentythree' || 'go'
)
}}
cancel-in-progress: true

chrome_e2e:
name: Chrome with defaults
uses: ./.github/workflows/test-e2e-cypress.yml
with:
wpVersion: "WordPress/WordPress#6.3"
concurrency:
group: chrome-defaults
cancel-in-progress: true

chrome_e2e_go:
name: Chrome and Go theme
uses: ./.github/workflows/test-e2e-cypress.yml
with:
wpVersion: "WordPress/WordPress#6.3"
theme: "https://downloads.wordpress.org/theme/go.zip"
concurrency:
group: chrome-go-theme
cancel-in-progress: true

chrome_e2e_php74:
name: Chrome on PHP 7.4
uses: ./.github/workflows/test-e2e-cypress.yml
with:
wpVersion: "WordPress/WordPress#6.3"
phpVersion: "7.4"
concurrency:
group: chrome-php74
cancel-in-progress: true

49 changes: 11 additions & 38 deletions .github/workflows/test-php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,17 @@ on:
- master

jobs:
php_unit_74:
name: PHP 7.4 Current Major
# PHP Unit testing
# Unit testing should be run across WP current, previous, and major before previous.
# Unit tests should be run across all supported versions of PHP.
php_unit_versions_matrix:
strategy:
matrix:
php: ['7.4','8.0','8.1','8.2']
wp: ['6.3', '6.2', '6.1']
name: PHP Unit ${{ matrix.php }} | WP Version ${{ matrix.wp }}
uses: ./.github/workflows/test-php-unit.yml
with:
phpVersion: '7.4'
wpVersion: 'WordPress/WordPress#6.3'
phpVersion: ${{ matrix.php }}
wpVersion: 'WordPress/WordPress#${{ matrix.wp }}'

php_unit_80:
name: PHP 8.0 Current Major
uses: ./.github/workflows/test-php-unit.yml
with:
phpVersion: '8.0'
wpVersion: 'WordPress/WordPress#6.3'

php_unit_81:
name: PHP 8.1 Current Major
uses: ./.github/workflows/test-php-unit.yml
with:
phpVersion: '8.1'
wpVersion: 'WordPress/WordPress#6.3'

php_unit_82:
name: PHP 8.2 Current Major
uses: ./.github/workflows/test-php-unit.yml
with:
phpVersion: '8.2'
wpVersion: 'WordPress/WordPress#6.3'

php_unit_82_wp_last_major:
name: PHP 8.2 Last Major
uses: ./.github/workflows/test-php-unit.yml
with:
phpVersion: '8.2'
wpVersion: 'WordPress/WordPress#6.2'

php_unit_82_wp_major_before_last_major:
name: PHP 8.2 Major Before Last Major
uses: ./.github/workflows/test-php-unit.yml
with:
phpVersion: '8.2'
wpVersion: 'WordPress/WordPress#6.1'
53 changes: 53 additions & 0 deletions .github/workflows/test-wp-next.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Test / E2E Runner & Jest & PHP Unit runner for WordPress Next version.

on:
pull_request:
branches:
- master

jobs:
# Check if WP Next is released
check_if_released:
name: Check if WP Next is released
uses: ./.github/workflows/date-checker.yml
with:
# WP Next scheduled release date. Should be based on `https://make.wordpress.org/core/6-4/` or later.
scheduled_release_date: "2023-11-7"

# Create WP NEXT Version Constant
set_constant:
name: Set WP Next Version Constant
needs: check_if_released
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-RC2.zip`
wp_next: "https://wordpress.org/wordpress-6.4-RC2.zip"
steps:
- run: echo "Setting WP Next Constant"


# E2E Testing
chrome_e2e_wp_next:
name: Chrome E2E WP Next Version
needs: set_constant
uses: ./.github/workflows/test-e2e-cypress.yml
with:
wpVersion: ${{ needs.set_constant.outputs.wp_next }}
installPath: "tests-wordpress-6.4-RC2"
theme: "https://downloads.wordpress.org/theme/go.zip"
concurrency:
group: chrome-wp-next
cancel-in-progress: true

# PHP Unit testing
php_unit_wp_next:
needs: set_constant
name: PHP ${{ matrix.php }} WP Next Version
strategy:
matrix:
php: ['7.4','8.0','8.1','8.2']
uses: ./.github/workflows/test-php-unit.yml
with:
phpVersion: ${{ matrix.php }}
wpVersion: ${{ needs.set_constant.outputs.wp_next }}
Loading
Loading