From 3706206f1f8203abeb399e21e76a1651831a4540 Mon Sep 17 00:00:00 2001 From: aledesma-godaddy Date: Wed, 1 Nov 2023 14:44:55 -0700 Subject: [PATCH 01/30] move animation CSS to its own import --- .../includes/test-coblocks-block-assets.php | 52 ++++++- .github/workflows/test-e2e-cypress.yml | 144 +++++++++++++++++- includes/class-coblocks-block-assets.php | 20 ++- src/styles/coblocks-animation.scss | 4 + src/styles/index.scss | 1 - src/styles/style.scss | 1 - webpack.config.js | 1 + 7 files changed, 217 insertions(+), 6 deletions(-) create mode 100644 src/styles/coblocks-animation.scss diff --git a/.dev/tests/phpunit/includes/test-coblocks-block-assets.php b/.dev/tests/phpunit/includes/test-coblocks-block-assets.php index cde0b260867..510709ff3d4 100644 --- a/.dev/tests/phpunit/includes/test-coblocks-block-assets.php +++ b/.dev/tests/phpunit/includes/test-coblocks-block-assets.php @@ -98,7 +98,31 @@ public function test_editor_assets_scripts() { $this->go_to( '/wp-admin/post-new.php' ); $this->coblocks_block_assets->editor_assets(); - $this->assertTrue( array_key_exists( 'coblocks-editor', $wp_scripts->registered ) ); + $this->assertTrue( array_key_exists( 'coblocks-editor', $wp_scripts->registered, ) ); + + $path = 'wp-content/plugins/coblocks/dist/coblocks-*.js'; + $files = glob( $path ); + + foreach($files as $file) { + $dist_script = end( + explode('/', + explode('.', + $file + )[0] + ) + ); + + if ($dist_script == 'coblocks-plugin-deactivation') { + $this->assertFalse( array_key_exists( $dist_script, $wp_scripts->registered ) ); + continue; + } + + if ( $dist_script === 'coblocks-extensions' ) { + $dist_script = 'coblocks-editor'; + } + + $this->assertTrue( array_key_exists( $dist_script, $wp_scripts->registered ) ); + } } /** @@ -154,6 +178,7 @@ public function test_block_assets_loaded_with_coblocks_block() { do_action( 'enqueue_block_assets' ); $this->assertContains( 'coblocks-frontend', $wp_styles->queue ); + $this->assertContains( 'coblocks-animation', $wp_styles->queue ); // Should have animation } public function test_block_assets_loaded_with_any_reusable_block() { @@ -212,7 +237,11 @@ public function test_block_assets_loaded_with_core_image_block() { $this->coblocks_block_assets->block_assets(); do_action( 'enqueue_block_assets' ); + // Core blocks should also have coblocks-animation. $this->assertContains( 'coblocks-frontend', $wp_styles->queue ); + $this->assertContains( 'coblocks-animation', $wp_styles->queue ); + $this->assertContains( 'coblocks-extensions', $wp_styles->queue ); + } public function test_typography_styles_loaded_with_core_button_block() { @@ -235,7 +264,10 @@ public function test_typography_styles_loaded_with_core_button_block() { $this->coblocks_block_assets->block_assets(); do_action( 'enqueue_block_assets' ); + // Core blocks should also have coblocks-animation. $this->assertContains( 'coblocks-frontend', $wp_styles->queue ); + $this->assertContains( 'coblocks-animation', $wp_styles->queue ); + $this->assertContains( 'coblocks-extensions', $wp_styles->queue ); } public function test_typography_styles_loaded_with_core_cover_block() { @@ -258,7 +290,10 @@ public function test_typography_styles_loaded_with_core_cover_block() { $this->coblocks_block_assets->block_assets(); do_action( 'enqueue_block_assets' ); + // Core blocks should also have coblocks-animation. $this->assertContains( 'coblocks-frontend', $wp_styles->queue ); + $this->assertContains( 'coblocks-animation', $wp_styles->queue ); + $this->assertContains( 'coblocks-extensions', $wp_styles->queue ); } public function test_typography_styles_loaded_with_core_heading_block() { @@ -281,7 +316,10 @@ public function test_typography_styles_loaded_with_core_heading_block() { $this->coblocks_block_assets->block_assets(); do_action( 'enqueue_block_assets' ); + // Core blocks should also have coblocks-animation. $this->assertContains( 'coblocks-frontend', $wp_styles->queue ); + $this->assertContains( 'coblocks-animation', $wp_styles->queue ); + $this->assertContains( 'coblocks-extensions', $wp_styles->queue ); } public function test_typography_styles_loaded_with_core_list_block() { @@ -304,7 +342,10 @@ public function test_typography_styles_loaded_with_core_list_block() { $this->coblocks_block_assets->block_assets(); do_action( 'enqueue_block_assets' ); + // Core blocks should also have coblocks-animation. $this->assertContains( 'coblocks-frontend', $wp_styles->queue ); + $this->assertContains( 'coblocks-animation', $wp_styles->queue ); + $this->assertContains( 'coblocks-extensions', $wp_styles->queue ); } public function test_typography_styles_loaded_with_core_paragraph_block() { @@ -327,7 +368,10 @@ public function test_typography_styles_loaded_with_core_paragraph_block() { $this->coblocks_block_assets->block_assets(); do_action( 'enqueue_block_assets' ); + // Core blocks should also have coblocks-animation. $this->assertContains( 'coblocks-frontend', $wp_styles->queue ); + $this->assertContains( 'coblocks-animation', $wp_styles->queue ); + $this->assertContains( 'coblocks-extensions', $wp_styles->queue ); } public function test_typography_styles_loaded_with_core_pullquote_block() { @@ -350,7 +394,10 @@ public function test_typography_styles_loaded_with_core_pullquote_block() { $this->coblocks_block_assets->block_assets(); do_action( 'enqueue_block_assets' ); + // Core blocks should also have coblocks-animation. $this->assertContains( 'coblocks-frontend', $wp_styles->queue ); + $this->assertContains( 'coblocks-animation', $wp_styles->queue ); + $this->assertContains( 'coblocks-extensions', $wp_styles->queue ); } public function test_typography_styles_loaded_with_core_quote_block() { @@ -373,6 +420,9 @@ public function test_typography_styles_loaded_with_core_quote_block() { $this->coblocks_block_assets->block_assets(); do_action( 'enqueue_block_assets' ); + // Core blocks should also have coblocks-animation. $this->assertContains( 'coblocks-frontend', $wp_styles->queue ); + $this->assertContains( 'coblocks-animation', $wp_styles->queue ); + $this->assertContains( 'coblocks-extensions', $wp_styles->queue ); } } diff --git a/.github/workflows/test-e2e-cypress.yml b/.github/workflows/test-e2e-cypress.yml index 463c6b0eb5d..b95ed66ad23 100644 --- a/.github/workflows/test-e2e-cypress.yml +++ b/.github/workflows/test-e2e-cypress.yml @@ -28,7 +28,149 @@ on: required: false jobs: - test_cypress_e2e: + setup-matrix: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.setup-spec-matrix.outputs.matrix }} + steps: + - name: Setup wp-env + id: setup-spec-matrix + run: | + changed_files=$(git diff --name-only --diff-filter=ACDMRTUXB origin/master) + spec_list=() + specs="" + + for line in $changed_files; do + + if [[ "$line" =~ src/(blocks|extensions|componets).* ]]; then + changed_path=$(echo $line | cut -d'/' -f3) + + # Only add the spec if it has not already been processed. + if [[ ! " ${spec_list[@]} " =~ " ${changed_path} " ]]; then # changed_path is not in spec_list + spec_list+=" ${changed_path} " # Add to list of processed specs + + # Append spec file path + specs+="\"src/**/${changed_path}/**/*.cypress.js\"," + + fi + fi + done + + # All changes processed. Format string for cypress run. + # Remove trailing comma. + updated_string=$(echo $specs | sed 's/,$//') + + # Wrap in brackets. + $updated_string=[$updated_string] + + # Save the matrix array to the output. + echo "matrix=$updated_string" >> $GITHUB_OUTPUT + + test_cypress_e2e_changed_files: + needs: setup-matrix + if: github.event_name == 'pull_request' + name: E2E Test - Changed Files + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + spec: ${{ fromJson(needs.setup-matrix.outputs.matrix) }} + + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup wp-env + uses: godaddy-wordpress/setup-wp-env@v1 + with: + core: ${{ inputs.wpVersion }} + phpVersion: ${{ inputs.phpVersion }} + plugins: '["."]' + themes: '["https://downloads.wordpress.org/theme/go.zip"]' + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version-file: '.nvmrc' + cache: 'yarn' + + - name: Install dependencies + run: | + composer install --prefer-dist --optimize-autoloader & + yarn install --immutable + + - name: Build plugin + 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)/${{ inputs.installPath }}/wp-content/plugins/ + + - name: Prepare Theme + run: | + if [ "$theme_url" = "https://downloads.wordpress.org/theme/go.zip" ]; then + cd $(wp-env install-path)/go + else + cd $(wp-env install-path)/${{ inputs.installPath }}/wp-content/themes/twentytwentythree + fi + mkdir -p coblocks/icons + echo '' >> coblocks/icons/custom.svg + + - name: Prepare tests + run: | + WP_CORE_VERSION=$(wp-env run cli wp core version) + echo "WP_CORE_VERSION=${WP_CORE_VERSION}" >> $GITHUB_ENV + wp-env run tests-cli wp post generate --count=5 + wp-env run cli wp post generate --count=5 + wp-env run cli wp option update permalink_structure '/%postname%' + if [ "${{ inputs.theme }}" = "https://downloads.wordpress.org/theme/go.zip" ]; then + wp-env run tests-cli wp theme activate go + fi + + # Only create a new post if running the migrated specs + - name: Create post and get ID + if: matrix.spec == 'alert.cypress.js' || matrix.spec == 'author.cypress.js' + run: | + # Generate application-password to use with WP REST API. + app_password=$(wp-env run tests-cli wp user application-password create admin gha-password --porcelain) + + # Retrieve post content from fixture. + post_content=$(cat .dev/tests/cypress/fixtures/${{matrix.spec}}.html) + echo $post_content + + # Create a post using the REST API and parse the postId from the response. + postId=$(curl -s -X POST 'http://localhost:8889/?rest_route=/wp/v2/posts' --data-urlencode "title=${{matrix.spec}}" --data-raw "content=$post_content" --data-urlencode "status=publish" --user "admin:$app_password"| jq '.id') + + # Save the postId to the output. + echo "postId=$postId" >> $GITHUB_OUTPUT + id: create-post + + # Only retrieve the post ID if running the first spec + - name: Save post ID to file + if: matrix.spec == 'alert.cypress.js' || matrix.spec == 'author.cypress.js' + run: | + path="$GITHUB_WORKSPACE/.dev/tests/cypress/fixtures/${{matrix.spec}}.json" + touch "$path" + echo "{\"${{matrix.spec}}\": \"$(echo "${{ steps.create-post.outputs.postId }}")\"}" > "$path" + + - name: Run tests + run: | + echo '{"wpUsername":"admin","wpPassword":"password","testURL":"http://localhost:8889"}' | jq . > cypress.env.json + ./node_modules/.bin/cypress verify + ./node_modules/.bin/cypress run --browser ${{ inputs.browser }} --spec "${{ matrix.spec }}" + + - name: Upload failure video + if: ${{ failure() }} + uses: actions/upload-artifact@v3 + with: + name: ${{ matrix.spec }}-fail.mp4 + path: ./.dev/tests/cypress/videos/${{ matrix.spec }}.mp4 + retention-days: 1 + + + test_cypress_e2e_full: + if: github.event_name == 'push' + needs: setup-matrix name: E2E Test runs-on: ubuntu-latest strategy: diff --git a/includes/class-coblocks-block-assets.php b/includes/class-coblocks-block-assets.php index 09bc7720e0c..07ee52a4695 100644 --- a/includes/class-coblocks-block-assets.php +++ b/includes/class-coblocks-block-assets.php @@ -133,7 +133,11 @@ public function block_assets() { return; } - // Styles. + /** + * Check the `test-coblocks-block-assets.php` file. + * Registered scripts should show for specific blocks that need them. + * For example the Core blocks all use `coblocks-animation` style + * */ $name = 'style-coblocks-1'; $filepath = 'dist/' . $name; $asset_file = $this->get_asset_file( $filepath ); @@ -157,6 +161,18 @@ public function block_assets() { $asset_file['dependencies'], $asset_file['version'], ); + + $name = 'style-coblocks-animation'; + $filepath = 'dist/' . $name; + $asset_file = $this->get_asset_file( $filepath ); + $rtl = ! is_rtl() ? '' : '-rtl'; + + wp_enqueue_style( + 'coblocks-animation', + COBLOCKS_PLUGIN_URL . $filepath . $rtl . '.css', + $asset_file['dependencies'], + $asset_file['version'], + ); } /** @@ -200,7 +216,7 @@ public function editor_assets() { } wp_register_script( - 'coblocks-editor', + 'coblocks-editor', // 'coblocks-extensions' COBLOCKS_PLUGIN_URL . $filepath . '.js', array_merge( $asset_file['dependencies'], array( 'wp-api' ) ), $asset_file['version'], diff --git a/src/styles/coblocks-animation.scss b/src/styles/coblocks-animation.scss new file mode 100644 index 00000000000..0028e8d5bae --- /dev/null +++ b/src/styles/coblocks-animation.scss @@ -0,0 +1,4 @@ + +@import "node_modules/@wordpress/base-styles/variables"; +@import "../extensions/animation/styles/editor.scss"; +@import "../extensions/animation/styles/style.scss"; diff --git a/src/styles/index.scss b/src/styles/index.scss index 5b29fcdf56a..8c985565172 100644 --- a/src/styles/index.scss +++ b/src/styles/index.scss @@ -23,7 +23,6 @@ // @import "../extensions/**/editor.scss"; @import "../extensions/advanced-controls/styles/editor.scss"; -@import "../extensions/animation/styles/editor.scss"; @import "../extensions/button-controls/styles/editor.scss"; @import "../extensions/coblocks-labs/styles/editor.scss"; @import "../extensions/image-crop/styles/editor.scss"; diff --git a/src/styles/style.scss b/src/styles/style.scss index 167a03409c6..a018bef5f8b 100644 --- a/src/styles/style.scss +++ b/src/styles/style.scss @@ -21,7 +21,6 @@ // @import "../extensions/**/style.scss"; @import "../extensions/advanced-controls/styles/style.scss"; -@import "../extensions/animation/styles/style.scss"; @import "../extensions/block-patterns/styles/style.scss"; @import "../extensions/button-controls/styles/style.scss"; @import "../extensions/button-styles/styles/style.scss"; diff --git a/webpack.config.js b/webpack.config.js index 60032fcbc68..6fd72a40fff 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -40,6 +40,7 @@ module.exports = { ...coblocksChunks, 'coblocks-extensions': path.resolve( process.cwd(), 'src/extensions.js' ), 'coblocks-plugin-deactivation': path.resolve( process.cwd(), 'src/components/coblocks-deactivate-modal/index.js' ), + 'style-coblocks-animation': path.resolve( process.cwd(), 'src/styles/coblocks-animation.scss' ), ...scripts.reduce( ( memo, script ) => { memo[ `js/${ script }` ] = path.resolve( process.cwd(), 'src', 'js', `${ script }.js` ); From 16ab5def57e5712c2cb85ae199e53d1287d9c4bd Mon Sep 17 00:00:00 2001 From: aledesma-godaddy Date: Wed, 1 Nov 2023 14:52:47 -0700 Subject: [PATCH 02/30] try moving checkout in workflow --- .github/workflows/test-e2e-cypress.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test-e2e-cypress.yml b/.github/workflows/test-e2e-cypress.yml index b95ed66ad23..4b62fa433b8 100644 --- a/.github/workflows/test-e2e-cypress.yml +++ b/.github/workflows/test-e2e-cypress.yml @@ -33,7 +33,10 @@ jobs: outputs: matrix: ${{ steps.setup-spec-matrix.outputs.matrix }} steps: - - name: Setup wp-env + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Spec Matrix id: setup-spec-matrix run: | changed_files=$(git diff --name-only --diff-filter=ACDMRTUXB origin/master) @@ -78,9 +81,6 @@ jobs: steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Setup wp-env uses: godaddy-wordpress/setup-wp-env@v1 with: @@ -227,9 +227,6 @@ jobs: steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Setup wp-env uses: godaddy-wordpress/setup-wp-env@v1 with: From 881b625263f4aec58cc54d81352914518b6126da Mon Sep 17 00:00:00 2001 From: aledesma-godaddy Date: Wed, 1 Nov 2023 15:10:08 -0700 Subject: [PATCH 03/30] use fetch-depth 0 --- .github/workflows/test-e2e-cypress.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test-e2e-cypress.yml b/.github/workflows/test-e2e-cypress.yml index 4b62fa433b8..720157ecc5b 100644 --- a/.github/workflows/test-e2e-cypress.yml +++ b/.github/workflows/test-e2e-cypress.yml @@ -35,6 +35,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + with: + fetch-depth: 0 - name: Setup Spec Matrix id: setup-spec-matrix From 7598388344c6eb472d478f0bdd9da2bd2401cbe6 Mon Sep 17 00:00:00 2001 From: aledesma-godaddy Date: Wed, 1 Nov 2023 15:13:04 -0700 Subject: [PATCH 04/30] typo and bash syntax --- .github/workflows/test-e2e-cypress.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-e2e-cypress.yml b/.github/workflows/test-e2e-cypress.yml index 720157ecc5b..4d35c77b017 100644 --- a/.github/workflows/test-e2e-cypress.yml +++ b/.github/workflows/test-e2e-cypress.yml @@ -47,7 +47,7 @@ jobs: for line in $changed_files; do - if [[ "$line" =~ src/(blocks|extensions|componets).* ]]; then + if [[ "$line" =~ src/(blocks|extensions|components).* ]]; then changed_path=$(echo $line | cut -d'/' -f3) # Only add the spec if it has not already been processed. @@ -66,7 +66,7 @@ jobs: updated_string=$(echo $specs | sed 's/,$//') # Wrap in brackets. - $updated_string=[$updated_string] + updated_string=[$updated_string] # Save the matrix array to the output. echo "matrix=$updated_string" >> $GITHUB_OUTPUT From 2ee8b5f098c3740f81d45da1e2bab581705b0792 Mon Sep 17 00:00:00 2001 From: aledesma-godaddy Date: Wed, 1 Nov 2023 15:39:20 -0700 Subject: [PATCH 05/30] why is the github output not persisting between jobs? --- .github/workflows/test-e2e-cypress.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-e2e-cypress.yml b/.github/workflows/test-e2e-cypress.yml index 4d35c77b017..dcf6c47b438 100644 --- a/.github/workflows/test-e2e-cypress.yml +++ b/.github/workflows/test-e2e-cypress.yml @@ -69,7 +69,7 @@ jobs: updated_string=[$updated_string] # Save the matrix array to the output. - echo "matrix=$updated_string" >> $GITHUB_OUTPUT + echo "matrix=$updated_string" >> $GITHUB_ENV test_cypress_e2e_changed_files: needs: setup-matrix From c6ef6d00feb0eb3a27da9a03138ec2162a12ffba Mon Sep 17 00:00:00 2001 From: aledesma-godaddy Date: Wed, 1 Nov 2023 15:44:48 -0700 Subject: [PATCH 06/30] simple change to test spec finder --- src/blocks/author/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/blocks/author/index.js b/src/blocks/author/index.js index 4a558e699ea..1c973877546 100644 --- a/src/blocks/author/index.js +++ b/src/blocks/author/index.js @@ -10,7 +10,7 @@ import { createBlock } from '@wordpress/blocks'; import { dispatch, select } from '@wordpress/data'; /** - * Block constants + * Block constants. */ const { name } = metadata; From 4a7aaef55c113129ee6de6beeed48e679744e322 Mon Sep 17 00:00:00 2001 From: aledesma-godaddy Date: Wed, 1 Nov 2023 15:48:02 -0700 Subject: [PATCH 07/30] inspect the output of the spec finder --- .github/workflows/test-e2e-cypress.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-e2e-cypress.yml b/.github/workflows/test-e2e-cypress.yml index dcf6c47b438..756f3a5614d 100644 --- a/.github/workflows/test-e2e-cypress.yml +++ b/.github/workflows/test-e2e-cypress.yml @@ -69,7 +69,8 @@ jobs: updated_string=[$updated_string] # Save the matrix array to the output. - echo "matrix=$updated_string" >> $GITHUB_ENV + echo $updated_string + echo "matrix=$updated_string" >> "$GITHUB_OUTPUT" test_cypress_e2e_changed_files: needs: setup-matrix From 4bd1607f11a09e69e2f76870d456f307b920e2ff Mon Sep 17 00:00:00 2001 From: aledesma-godaddy Date: Wed, 1 Nov 2023 15:55:26 -0700 Subject: [PATCH 08/30] have to checkout in the new jobs --- .github/workflows/test-e2e-cypress.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/test-e2e-cypress.yml b/.github/workflows/test-e2e-cypress.yml index 756f3a5614d..ba15f73bc8d 100644 --- a/.github/workflows/test-e2e-cypress.yml +++ b/.github/workflows/test-e2e-cypress.yml @@ -84,6 +84,9 @@ jobs: steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup wp-env uses: godaddy-wordpress/setup-wp-env@v1 with: @@ -230,6 +233,9 @@ jobs: steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup wp-env uses: godaddy-wordpress/setup-wp-env@v1 with: From 6c4e02104d27ccf9e93154b84ec170d2357fc693 Mon Sep 17 00:00:00 2001 From: aledesma-godaddy Date: Thu, 2 Nov 2023 12:52:21 -0700 Subject: [PATCH 09/30] try some workflow updates --- .github/workflows/test-e2e-cypress.yml | 37 +++++++++++++++++--------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test-e2e-cypress.yml b/.github/workflows/test-e2e-cypress.yml index ba15f73bc8d..7365599d0a3 100644 --- a/.github/workflows/test-e2e-cypress.yml +++ b/.github/workflows/test-e2e-cypress.yml @@ -41,32 +41,42 @@ jobs: - name: Setup Spec Matrix id: setup-spec-matrix run: | - changed_files=$(git diff --name-only --diff-filter=ACDMRTUXB origin/master) + changed_files=$(git diff --name-only --diff-filter=ACDMRTUXB ${{ github.event.before }} ${{ github.sha }}) spec_list=() specs="" + # echo $changed_files + + for line in $changed_files; do + if [[ "$line" =~ src/(blocks|extensions|componets).* ]]; then + + changed_path=$(echo $line | cut -d'/' -f3) # Get the main path of the changed file, e.g. author, food-and-drinks, lightbox. - if [[ "$line" =~ src/(blocks|extensions|components).* ]]; then - changed_path=$(echo $line | cut -d'/' -f3) + found_specs=$(find . -type f -name "*.cypress.js") # Find real spec files. + pattern="/src/(blocks|extensions|components)/${changed_path}/" # Changed files pattern to match against. - # Only add the spec if it has not already been processed. - if [[ ! " ${spec_list[@]} " =~ " ${changed_path} " ]]; then # changed_path is not in spec_list - spec_list+=" ${changed_path} " # Add to list of processed specs + for spec in $found_specs; do + if [[ $spec =~ $pattern ]]; then - # Append spec file path - specs+="\"src/**/${changed_path}/**/*.cypress.js\"," + # Remove the path from the spec. + spec=$(echo $spec | sed 's:.*/::') + + # Build spec list for cypress run. + spec_list+="${spec}," + + fi + done - fi fi done # All changes processed. Format string for cypress run. - # Remove trailing comma. - updated_string=$(echo $specs | sed 's/,$//') + # Remove trailing comma from spec_list. + updated_string=$(echo $spec_list | sed 's/,$//' ) - # Wrap in brackets. - updated_string=[$updated_string] + # Wrap list in brackets for GH Workflow. + echo [$updated_string] # Save the matrix array to the output. echo $updated_string @@ -161,6 +171,7 @@ jobs: - name: Run tests run: | + CYPRESS_SPEC=$(find ./src/* -name ${{ matrix.spec }} -type f) echo '{"wpUsername":"admin","wpPassword":"password","testURL":"http://localhost:8889"}' | jq . > cypress.env.json ./node_modules/.bin/cypress verify ./node_modules/.bin/cypress run --browser ${{ inputs.browser }} --spec "${{ matrix.spec }}" From e4efbcf68a50da96cb2553ae5076348a2521ec12 Mon Sep 17 00:00:00 2001 From: aledesma-godaddy Date: Thu, 2 Nov 2023 12:56:21 -0700 Subject: [PATCH 10/30] format the speclist as array --- .github/workflows/test-e2e-cypress.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-e2e-cypress.yml b/.github/workflows/test-e2e-cypress.yml index 7365599d0a3..eda3f06a2fb 100644 --- a/.github/workflows/test-e2e-cypress.yml +++ b/.github/workflows/test-e2e-cypress.yml @@ -63,7 +63,7 @@ jobs: spec=$(echo $spec | sed 's:.*/::') # Build spec list for cypress run. - spec_list+="${spec}," + spec_list+=""${spec}"," fi done From 63527ddf55b8fc124254fc446649afe3479428cd Mon Sep 17 00:00:00 2001 From: aledesma-godaddy Date: Thu, 2 Nov 2023 12:58:55 -0700 Subject: [PATCH 11/30] echo the changed files --- .github/workflows/test-e2e-cypress.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-e2e-cypress.yml b/.github/workflows/test-e2e-cypress.yml index eda3f06a2fb..250826673ea 100644 --- a/.github/workflows/test-e2e-cypress.yml +++ b/.github/workflows/test-e2e-cypress.yml @@ -45,7 +45,7 @@ jobs: spec_list=() specs="" - # echo $changed_files + echo $changed_files for line in $changed_files; do From 03229677b5bd522b882a0352a094c725b3705bdc Mon Sep 17 00:00:00 2001 From: aledesma-godaddy Date: Thu, 2 Nov 2023 13:24:37 -0700 Subject: [PATCH 12/30] more git changes in ci --- .github/workflows/test-e2e-cypress.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-e2e-cypress.yml b/.github/workflows/test-e2e-cypress.yml index 250826673ea..c3287738337 100644 --- a/.github/workflows/test-e2e-cypress.yml +++ b/.github/workflows/test-e2e-cypress.yml @@ -41,7 +41,7 @@ jobs: - name: Setup Spec Matrix id: setup-spec-matrix run: | - changed_files=$(git diff --name-only --diff-filter=ACDMRTUXB ${{ github.event.before }} ${{ github.sha }}) + changed_files=$(git diff --name-only --diff-filter=ACDMRTUXB ${{ github.event.before }} origin/master) spec_list=() specs="" @@ -84,7 +84,7 @@ jobs: test_cypress_e2e_changed_files: needs: setup-matrix - if: github.event_name == 'pull_request' + if: github.event_name == 'pull_request' && needs.setup-matrix.outputs.matrix != '[]' name: E2E Test - Changed Files runs-on: ubuntu-latest strategy: From a9dbf038507a38eeef33c9f43c836eb8a7c79307 Mon Sep 17 00:00:00 2001 From: aledesma-godaddy Date: Thu, 2 Nov 2023 13:35:13 -0700 Subject: [PATCH 13/30] more flow fixes --- .github/workflows/test-e2e-cypress.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test-e2e-cypress.yml b/.github/workflows/test-e2e-cypress.yml index c3287738337..dc8019a2a4f 100644 --- a/.github/workflows/test-e2e-cypress.yml +++ b/.github/workflows/test-e2e-cypress.yml @@ -45,9 +45,6 @@ jobs: spec_list=() specs="" - echo $changed_files - - for line in $changed_files; do if [[ "$line" =~ src/(blocks|extensions|componets).* ]]; then @@ -63,7 +60,7 @@ jobs: spec=$(echo $spec | sed 's:.*/::') # Build spec list for cypress run. - spec_list+=""${spec}"," + spec_list+="'${spec}'," fi done @@ -76,11 +73,11 @@ jobs: updated_string=$(echo $spec_list | sed 's/,$//' ) # Wrap list in brackets for GH Workflow. - echo [$updated_string] + wrapped_string="[$updated_string]" # Save the matrix array to the output. - echo $updated_string - echo "matrix=$updated_string" >> "$GITHUB_OUTPUT" + echo $wrapped_string + echo "matrix=$wrapped_string" >> "$GITHUB_OUTPUT" test_cypress_e2e_changed_files: needs: setup-matrix From b24a2c64d603c045ce642b1bccdc6b989b281783 Mon Sep 17 00:00:00 2001 From: aledesma-godaddy Date: Thu, 2 Nov 2023 13:45:20 -0700 Subject: [PATCH 14/30] pass the specs to the runner --- .github/workflows/test-e2e-cypress.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-e2e-cypress.yml b/.github/workflows/test-e2e-cypress.yml index dc8019a2a4f..b6e8016648d 100644 --- a/.github/workflows/test-e2e-cypress.yml +++ b/.github/workflows/test-e2e-cypress.yml @@ -171,7 +171,7 @@ jobs: CYPRESS_SPEC=$(find ./src/* -name ${{ matrix.spec }} -type f) echo '{"wpUsername":"admin","wpPassword":"password","testURL":"http://localhost:8889"}' | jq . > cypress.env.json ./node_modules/.bin/cypress verify - ./node_modules/.bin/cypress run --browser ${{ inputs.browser }} --spec "${{ matrix.spec }}" + ./node_modules/.bin/cypress run --browser ${{ inputs.browser }} --spec $CYPRESS_SPEC - name: Upload failure video if: ${{ failure() }} From 93d6725547b2de4380eb99385ee0c994e7c600a9 Mon Sep 17 00:00:00 2001 From: aledesma-godaddy Date: Thu, 2 Nov 2023 13:57:14 -0700 Subject: [PATCH 15/30] bump wp-next version testing --- .github/workflows/test-wp-next.yml | 6 +++--- docs/dev/test-override.md | 11 ----------- 2 files changed, 3 insertions(+), 14 deletions(-) delete mode 100644 docs/dev/test-override.md diff --git a/.github/workflows/test-wp-next.yml b/.github/workflows/test-wp-next.yml index c9193799ef5..dcf17981215 100644 --- a/.github/workflows/test-wp-next.yml +++ b/.github/workflows/test-wp-next.yml @@ -21,8 +21,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-RC2.zip` - wp_next: "https://wordpress.org/wordpress-6.4-RC2.zip" + # 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" steps: - run: echo "Setting WP Next Constant" @@ -34,7 +34,7 @@ jobs: uses: ./.github/workflows/test-e2e-cypress.yml with: wpVersion: ${{ needs.set_constant.outputs.wp_next }} - installPath: "tests-wordpress-6.4-RC2" + installPath: "tests-wordpress-6.4-RC3" theme: "https://downloads.wordpress.org/theme/go.zip" concurrency: group: chrome-wp-next diff --git a/docs/dev/test-override.md b/docs/dev/test-override.md deleted file mode 100644 index 293cfd1c921..00000000000 --- a/docs/dev/test-override.md +++ /dev/null @@ -1,11 +0,0 @@ -# Run All Tests Override -CoBlocks tests are setup to perform a check against changed files to determine which tests should run. There are situations where the existing configuration should be disabled such as when making sweeping changes, or when updating software versions. CoBlocks now supports the ability to force Continuous Integration to run all tests based on branch naming convention. - -To force all tests your branch must contain the string - -**`run-all-tests`** - -Here are a few example branch names: -- 'try/wordpress-rc2-**run-all-tests**' -- 'enhance/major-things-**run-all-tests**' -- 'fix/bugs-**run-all-tests**' \ No newline at end of file From 2681a2162e3e1023e210e3627d656e517810fefc Mon Sep 17 00:00:00 2001 From: aledesma-godaddy Date: Thu, 2 Nov 2023 14:56:26 -0700 Subject: [PATCH 16/30] add new e2e test for fos animation scripts --- .../test/settings-modal-control.cypress.js | 38 ++++++++++++++----- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/src/extensions/animation/test/settings-modal-control.cypress.js b/src/extensions/animation/test/settings-modal-control.cypress.js index f7ac3764741..9029b087802 100644 --- a/src/extensions/animation/test/settings-modal-control.cypress.js +++ b/src/extensions/animation/test/settings-modal-control.cypress.js @@ -4,10 +4,6 @@ import { ANIMATION_FEATURE_ENABLED_KEY, } from '../constants'; -before( () => { - helpers.addBlockToPost( 'core/cover', true ); -} ); - describe( 'Settings Modal: Animation feature', () => { beforeEach( () => { // Reset settings. @@ -16,6 +12,10 @@ describe( 'Settings Modal: Animation feature', () => { [ ANIMATION_FEATURE_ENABLED_KEY ]: true, } ); } ); + } ); + + it( 'can turn off all animation settings', () => { + helpers.addBlockToPost( 'core/cover', true ); cy.get( '.edit-post-visual-editor .wp-block[data-type="core/cover"]' ).first().click(); @@ -23,13 +23,7 @@ describe( 'Settings Modal: Animation feature', () => { cy.get( '.interface-interface-skeleton__header .edit-post-more-menu .components-button' + ', .interface-interface-skeleton__header .interface-more-menu-dropdown .components-button' ).click(); cy.get( '.components-menu-item__button,.components-button' ).contains( 'Editor settings' ).click(); - } ); - afterEach( () => { - cy.get( '.components-modal__header button[aria-label*="Close"]' ).click(); - } ); - - it( 'can turn off all animation settings', () => { cy.get( '.components-coblocks-animation-toggle' ).should( 'exist' ); cy.get( '.coblocks-settings-modal' ).contains( 'Animation controls' ).click(); @@ -37,5 +31,29 @@ describe( 'Settings Modal: Animation feature', () => { cy.get( '.components-coblocks-animation-toggle' ).should( 'not.exist' ); cy.get( '.coblocks-settings-modal' ).contains( 'Animation controls' ).click(); + + cy.get( '.components-modal__header button[aria-label*="Close"]' ).click(); + } ); + + it( 'functions with only core blocks on page', () => { + helpers.addBlockToPost( 'core/paragraph', true ); + + helpers.selectBlock( 'core/paragraph' ); + + cy.get( '.components-coblocks-animation-toggle' ).should( 'exist' ); + + cy.get( 'p[data-type="core/paragraph"]' ).first().type( 'Test Animation' ); + + helpers.savePage(); + + helpers.checkForBlockErrors( 'core/paragraph' ); + + helpers.viewPage(); + + // Ensure that on Front of the site, the animation script and styles are loaded. + cy.get( 'script[id="coblocks-animation-js"]' ); + cy.get( 'link[id="coblocks-animation-css"]' ); + + helpers.editPage(); } ); } ); From 5e97ffc20e72b1d4da1fc7c50465ce86c2d59fe9 Mon Sep 17 00:00:00 2001 From: aledesma-godaddy Date: Fri, 3 Nov 2023 07:46:24 -0700 Subject: [PATCH 17/30] cleanup the workflow a bit --- .github/workflows/test-e2e-cypress.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-e2e-cypress.yml b/.github/workflows/test-e2e-cypress.yml index b6e8016648d..4c1d70fb1b0 100644 --- a/.github/workflows/test-e2e-cypress.yml +++ b/.github/workflows/test-e2e-cypress.yml @@ -43,10 +43,9 @@ jobs: run: | changed_files=$(git diff --name-only --diff-filter=ACDMRTUXB ${{ github.event.before }} origin/master) spec_list=() - specs="" for line in $changed_files; do - if [[ "$line" =~ src/(blocks|extensions|componets).* ]]; then + if [[ "$line" =~ src/(blocks|extensions|componets).* ]]; then # If changed file is within our tested paths. changed_path=$(echo $line | cut -d'/' -f3) # Get the main path of the changed file, e.g. author, food-and-drinks, lightbox. @@ -72,10 +71,11 @@ jobs: # Remove trailing comma from spec_list. updated_string=$(echo $spec_list | sed 's/,$//' ) - # Wrap list in brackets for GH Workflow. + # Wrap list in brackets for GH workflow matrix. wrapped_string="[$updated_string]" # Save the matrix array to the output. + echo "Testing against the following specs:" echo $wrapped_string echo "matrix=$wrapped_string" >> "$GITHUB_OUTPUT" From ac292bd487f07ca037a0703dd47125500374ad23 Mon Sep 17 00:00:00 2001 From: Anthony Ledesma <30462574+AnthonyLedesma@users.noreply.github.com> Date: Fri, 3 Nov 2023 14:11:37 -0700 Subject: [PATCH 18/30] Update .github/workflows/test-e2e-cypress.yml Co-authored-by: JR Tashjian <85627927+mtashjianjr-godaddy@users.noreply.github.com> --- .github/workflows/test-e2e-cypress.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-e2e-cypress.yml b/.github/workflows/test-e2e-cypress.yml index 4c1d70fb1b0..57b419d41f0 100644 --- a/.github/workflows/test-e2e-cypress.yml +++ b/.github/workflows/test-e2e-cypress.yml @@ -41,7 +41,7 @@ jobs: - name: Setup Spec Matrix id: setup-spec-matrix run: | - changed_files=$(git diff --name-only --diff-filter=ACDMRTUXB ${{ github.event.before }} origin/master) + changed_files=$(git diff --name-only --diff-filter=ADMR ${{ github.event.before }} origin/master) spec_list=() for line in $changed_files; do From 777a3874c3329447dcc656aa47455d23803ba726 Mon Sep 17 00:00:00 2001 From: aledesma-godaddy Date: Mon, 6 Nov 2023 07:16:24 -0700 Subject: [PATCH 19/30] try making build coblocks an artifact --- .github/workflows/test-e2e-cypress.yml | 92 ++++++++++++++++++++------ 1 file changed, 72 insertions(+), 20 deletions(-) diff --git a/.github/workflows/test-e2e-cypress.yml b/.github/workflows/test-e2e-cypress.yml index 57b419d41f0..a4b45b8a338 100644 --- a/.github/workflows/test-e2e-cypress.yml +++ b/.github/workflows/test-e2e-cypress.yml @@ -79,8 +79,36 @@ jobs: echo $wrapped_string echo "matrix=$wrapped_string" >> "$GITHUB_OUTPUT" + build-coblocks: + name: Build CoBlocks and Upload build Artifacts + runs-on: ubuntu-latest + steps: + - name: Install dependencies + run: | + composer install --prefer-dist --optimize-autoloader & + yarn install --immutable + + - name: Build plugin + 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)/${{ inputs.installPath }}/wp-content/plugins/ + + - name: Upload build artifact + uses: actions/upload-artifact@v3 + with: + name: coblocks-build + path: ./build/coblocks + + - name: Upload node_modules artifact + uses: actions/upload-artifact@v3 + with: + name: node_modules + path: ./node_modules + + test_cypress_e2e_changed_files: - needs: setup-matrix + needs: [setup-matrix, build-coblocks] if: github.event_name == 'pull_request' && needs.setup-matrix.outputs.matrix != '[]' name: E2E Test - Changed Files runs-on: ubuntu-latest @@ -108,16 +136,28 @@ jobs: node-version-file: '.nvmrc' cache: 'yarn' - - name: Install dependencies - run: | - composer install --prefer-dist --optimize-autoloader & - yarn install --immutable + - name: Download dependencies + uses: actions/download-artifact@v2 + with: + name: node_modules + path: ./node_modules - - name: Build plugin - 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)/${{ inputs.installPath }}/wp-content/plugins/ + - name: Download dependencies + uses: actions/download-artifact@v2 + with: + name: coblocks-build + path: $(wp-env install-path)/${{ inputs.installPath }}/wp-content/plugins/ + + # - name: Install dependencies + # run: | + # composer install --prefer-dist --optimize-autoloader & + # yarn install --immutable + + # - name: Build plugin + # 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)/${{ inputs.installPath }}/wp-content/plugins/ - name: Prepare Theme run: | @@ -184,7 +224,7 @@ jobs: test_cypress_e2e_full: if: github.event_name == 'push' - needs: setup-matrix + needs: [setup-matrix, build-coblocks] name: E2E Test runs-on: ubuntu-latest strategy: @@ -259,16 +299,28 @@ jobs: node-version-file: '.nvmrc' cache: 'yarn' - - name: Install dependencies - run: | - composer install --prefer-dist --optimize-autoloader & - yarn install --immutable + - name: Download dependencies + uses: actions/download-artifact@v2 + with: + name: node_modules + path: ./node_modules - - name: Build plugin - 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)/${{ inputs.installPath }}/wp-content/plugins/ + - name: Download dependencies + uses: actions/download-artifact@v2 + with: + name: coblocks-build + path: $(wp-env install-path)/${{ inputs.installPath }}/wp-content/plugins/ + + # - name: Install dependencies + # run: | + # composer install --prefer-dist --optimize-autoloader & + # yarn install --immutable + + # - name: Build plugin + # 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)/${{ inputs.installPath }}/wp-content/plugins/ - name: Prepare Theme run: | From 027a7ee09956bd9e897e44c34e970e5f00977ff2 Mon Sep 17 00:00:00 2001 From: aledesma-godaddy Date: Mon, 6 Nov 2023 07:18:04 -0700 Subject: [PATCH 20/30] checkout repo first --- .github/workflows/test-e2e-cypress.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test-e2e-cypress.yml b/.github/workflows/test-e2e-cypress.yml index a4b45b8a338..1033db39135 100644 --- a/.github/workflows/test-e2e-cypress.yml +++ b/.github/workflows/test-e2e-cypress.yml @@ -83,6 +83,9 @@ jobs: name: Build CoBlocks and Upload build Artifacts runs-on: ubuntu-latest steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Install dependencies run: | composer install --prefer-dist --optimize-autoloader & From 48dba7dd16b379258d523d8a47081fd25f1d591a Mon Sep 17 00:00:00 2001 From: aledesma-godaddy Date: Mon, 6 Nov 2023 07:28:34 -0700 Subject: [PATCH 21/30] download deps everywhere --- .github/workflows/test-e2e-cypress.yml | 37 ++++++++++---------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/.github/workflows/test-e2e-cypress.yml b/.github/workflows/test-e2e-cypress.yml index 1033db39135..3d6b6d57963 100644 --- a/.github/workflows/test-e2e-cypress.yml +++ b/.github/workflows/test-e2e-cypress.yml @@ -103,11 +103,11 @@ jobs: name: coblocks-build path: ./build/coblocks - - name: Upload node_modules artifact - uses: actions/upload-artifact@v3 - with: - name: node_modules - path: ./node_modules + # - name: Upload node_modules artifact + # uses: actions/upload-artifact@v3 + # with: + # name: node_modules + # path: ./node_modules test_cypress_e2e_changed_files: @@ -139,11 +139,10 @@ jobs: node-version-file: '.nvmrc' cache: 'yarn' - - name: Download dependencies - uses: actions/download-artifact@v2 - with: - name: node_modules - path: ./node_modules + - name: Install dependencies + run: | + composer install --prefer-dist --optimize-autoloader & + yarn install --immutable - name: Download dependencies uses: actions/download-artifact@v2 @@ -151,10 +150,6 @@ jobs: name: coblocks-build path: $(wp-env install-path)/${{ inputs.installPath }}/wp-content/plugins/ - # - name: Install dependencies - # run: | - # composer install --prefer-dist --optimize-autoloader & - # yarn install --immutable # - name: Build plugin # run: | @@ -302,11 +297,10 @@ jobs: node-version-file: '.nvmrc' cache: 'yarn' - - name: Download dependencies - uses: actions/download-artifact@v2 - with: - name: node_modules - path: ./node_modules + - name: Install dependencies + run: | + composer install --prefer-dist --optimize-autoloader & + yarn install --immutable - name: Download dependencies uses: actions/download-artifact@v2 @@ -314,10 +308,7 @@ jobs: name: coblocks-build path: $(wp-env install-path)/${{ inputs.installPath }}/wp-content/plugins/ - # - name: Install dependencies - # run: | - # composer install --prefer-dist --optimize-autoloader & - # yarn install --immutable + # - name: Build plugin # run: | From af8bec4a027a6c9add9b441c8f788717e45cceb0 Mon Sep 17 00:00:00 2001 From: Anthony Ledesma <30462574+AnthonyLedesma@users.noreply.github.com> Date: Mon, 6 Nov 2023 10:41:27 -0700 Subject: [PATCH 22/30] Update .dev/tests/phpunit/includes/test-coblocks-block-assets.php Co-authored-by: Evan Herman --- .dev/tests/phpunit/includes/test-coblocks-block-assets.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.dev/tests/phpunit/includes/test-coblocks-block-assets.php b/.dev/tests/phpunit/includes/test-coblocks-block-assets.php index 510709ff3d4..c4b15e23fb1 100644 --- a/.dev/tests/phpunit/includes/test-coblocks-block-assets.php +++ b/.dev/tests/phpunit/includes/test-coblocks-block-assets.php @@ -100,7 +100,7 @@ public function test_editor_assets_scripts() { $this->assertTrue( array_key_exists( 'coblocks-editor', $wp_scripts->registered, ) ); - $path = 'wp-content/plugins/coblocks/dist/coblocks-*.js'; + $path = dirname( __FILE__ ) . '/../../../../dist/coblocks-*.js'; $files = glob( $path ); foreach($files as $file) { From 3ff1ca93f5d25047324d35f54c94befdab653100 Mon Sep 17 00:00:00 2001 From: Anthony Ledesma <30462574+AnthonyLedesma@users.noreply.github.com> Date: Mon, 6 Nov 2023 10:41:40 -0700 Subject: [PATCH 23/30] Update .dev/tests/phpunit/includes/test-coblocks-block-assets.php Co-authored-by: Evan Herman --- .dev/tests/phpunit/includes/test-coblocks-block-assets.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.dev/tests/phpunit/includes/test-coblocks-block-assets.php b/.dev/tests/phpunit/includes/test-coblocks-block-assets.php index c4b15e23fb1..d02549700f1 100644 --- a/.dev/tests/phpunit/includes/test-coblocks-block-assets.php +++ b/.dev/tests/phpunit/includes/test-coblocks-block-assets.php @@ -112,7 +112,7 @@ public function test_editor_assets_scripts() { ) ); - if ($dist_script == 'coblocks-plugin-deactivation') { + if ( $dist_script == 'coblocks-plugin-deactivation' ) { $this->assertFalse( array_key_exists( $dist_script, $wp_scripts->registered ) ); continue; } From 59a78d11a6736cf13473e74e41af0bae6817b314 Mon Sep 17 00:00:00 2001 From: Anthony Ledesma <30462574+AnthonyLedesma@users.noreply.github.com> Date: Mon, 6 Nov 2023 10:41:51 -0700 Subject: [PATCH 24/30] Update .dev/tests/phpunit/includes/test-coblocks-block-assets.php Co-authored-by: Evan Herman --- .dev/tests/phpunit/includes/test-coblocks-block-assets.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.dev/tests/phpunit/includes/test-coblocks-block-assets.php b/.dev/tests/phpunit/includes/test-coblocks-block-assets.php index d02549700f1..0d4bc1701da 100644 --- a/.dev/tests/phpunit/includes/test-coblocks-block-assets.php +++ b/.dev/tests/phpunit/includes/test-coblocks-block-assets.php @@ -98,7 +98,7 @@ public function test_editor_assets_scripts() { $this->go_to( '/wp-admin/post-new.php' ); $this->coblocks_block_assets->editor_assets(); - $this->assertTrue( array_key_exists( 'coblocks-editor', $wp_scripts->registered, ) ); + $this->assertTrue( array_key_exists( 'coblocks-editor', $wp_scripts->registered ) ); $path = dirname( __FILE__ ) . '/../../../../dist/coblocks-*.js'; $files = glob( $path ); From a05ede0db5f4ecae00ae67f03bef05227cfa6ff2 Mon Sep 17 00:00:00 2001 From: Anthony Ledesma <30462574+AnthonyLedesma@users.noreply.github.com> Date: Mon, 6 Nov 2023 10:42:22 -0700 Subject: [PATCH 25/30] Update .dev/tests/phpunit/includes/test-coblocks-block-assets.php Co-authored-by: Evan Herman --- .../tests/phpunit/includes/test-coblocks-block-assets.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.dev/tests/phpunit/includes/test-coblocks-block-assets.php b/.dev/tests/phpunit/includes/test-coblocks-block-assets.php index 0d4bc1701da..c382acf6ce1 100644 --- a/.dev/tests/phpunit/includes/test-coblocks-block-assets.php +++ b/.dev/tests/phpunit/includes/test-coblocks-block-assets.php @@ -104,13 +104,7 @@ public function test_editor_assets_scripts() { $files = glob( $path ); foreach($files as $file) { - $dist_script = end( - explode('/', - explode('.', - $file - )[0] - ) - ); + $dist_script = pathinfo( $file, PATHINFO_FILENAME ); if ( $dist_script == 'coblocks-plugin-deactivation' ) { $this->assertFalse( array_key_exists( $dist_script, $wp_scripts->registered ) ); From a6d512961bbf7003ccd4c4712d48cd0852285aa8 Mon Sep 17 00:00:00 2001 From: Anthony Ledesma <30462574+AnthonyLedesma@users.noreply.github.com> Date: Mon, 6 Nov 2023 10:42:36 -0700 Subject: [PATCH 26/30] Update .dev/tests/phpunit/includes/test-coblocks-block-assets.php Co-authored-by: Evan Herman --- .dev/tests/phpunit/includes/test-coblocks-block-assets.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.dev/tests/phpunit/includes/test-coblocks-block-assets.php b/.dev/tests/phpunit/includes/test-coblocks-block-assets.php index c382acf6ce1..7e164573021 100644 --- a/.dev/tests/phpunit/includes/test-coblocks-block-assets.php +++ b/.dev/tests/phpunit/includes/test-coblocks-block-assets.php @@ -103,7 +103,7 @@ public function test_editor_assets_scripts() { $path = dirname( __FILE__ ) . '/../../../../dist/coblocks-*.js'; $files = glob( $path ); - foreach($files as $file) { + foreach( $files as $file ) { $dist_script = pathinfo( $file, PATHINFO_FILENAME ); if ( $dist_script == 'coblocks-plugin-deactivation' ) { From e6ffd447e05a1a233d9b7b8e99e51137f07f8508 Mon Sep 17 00:00:00 2001 From: Anthony Ledesma <30462574+AnthonyLedesma@users.noreply.github.com> Date: Mon, 6 Nov 2023 10:42:51 -0700 Subject: [PATCH 27/30] Update .dev/tests/phpunit/includes/test-coblocks-block-assets.php Co-authored-by: Evan Herman --- .dev/tests/phpunit/includes/test-coblocks-block-assets.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.dev/tests/phpunit/includes/test-coblocks-block-assets.php b/.dev/tests/phpunit/includes/test-coblocks-block-assets.php index 7e164573021..9e4eef9e487 100644 --- a/.dev/tests/phpunit/includes/test-coblocks-block-assets.php +++ b/.dev/tests/phpunit/includes/test-coblocks-block-assets.php @@ -115,7 +115,7 @@ public function test_editor_assets_scripts() { $dist_script = 'coblocks-editor'; } - $this->assertTrue( array_key_exists( $dist_script, $wp_scripts->registered ) ); + $this->assertTrue( array_key_exists( $dist_script, $wp_scripts->registered ) ); } } From 0f6008c5a6dd5ee2b58cc95baf56c014a39bc655 Mon Sep 17 00:00:00 2001 From: Anthony Ledesma <30462574+AnthonyLedesma@users.noreply.github.com> Date: Mon, 6 Nov 2023 10:42:59 -0700 Subject: [PATCH 28/30] Update .dev/tests/phpunit/includes/test-coblocks-block-assets.php Co-authored-by: Evan Herman --- .dev/tests/phpunit/includes/test-coblocks-block-assets.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.dev/tests/phpunit/includes/test-coblocks-block-assets.php b/.dev/tests/phpunit/includes/test-coblocks-block-assets.php index 9e4eef9e487..95b4ccd66ed 100644 --- a/.dev/tests/phpunit/includes/test-coblocks-block-assets.php +++ b/.dev/tests/phpunit/includes/test-coblocks-block-assets.php @@ -107,7 +107,7 @@ public function test_editor_assets_scripts() { $dist_script = pathinfo( $file, PATHINFO_FILENAME ); if ( $dist_script == 'coblocks-plugin-deactivation' ) { - $this->assertFalse( array_key_exists( $dist_script, $wp_scripts->registered ) ); + $this->assertFalse( array_key_exists( $dist_script, $wp_scripts->registered ) ); continue; } From cb15774f07b8683a42ead04c72edde5f7637ac04 Mon Sep 17 00:00:00 2001 From: aledesma-godaddy Date: Mon, 6 Nov 2023 10:45:16 -0700 Subject: [PATCH 29/30] revert build artifact attempts --- .github/workflows/test-e2e-cypress.yml | 72 +++++--------------------- 1 file changed, 12 insertions(+), 60 deletions(-) diff --git a/.github/workflows/test-e2e-cypress.yml b/.github/workflows/test-e2e-cypress.yml index 3d6b6d57963..5b1b2e3b850 100644 --- a/.github/workflows/test-e2e-cypress.yml +++ b/.github/workflows/test-e2e-cypress.yml @@ -79,39 +79,8 @@ jobs: echo $wrapped_string echo "matrix=$wrapped_string" >> "$GITHUB_OUTPUT" - build-coblocks: - name: Build CoBlocks and Upload build Artifacts - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Install dependencies - run: | - composer install --prefer-dist --optimize-autoloader & - yarn install --immutable - - - name: Build plugin - 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)/${{ inputs.installPath }}/wp-content/plugins/ - - - name: Upload build artifact - uses: actions/upload-artifact@v3 - with: - name: coblocks-build - path: ./build/coblocks - - # - name: Upload node_modules artifact - # uses: actions/upload-artifact@v3 - # with: - # name: node_modules - # path: ./node_modules - - test_cypress_e2e_changed_files: - needs: [setup-matrix, build-coblocks] + needs: setup-matrix if: github.event_name == 'pull_request' && needs.setup-matrix.outputs.matrix != '[]' name: E2E Test - Changed Files runs-on: ubuntu-latest @@ -144,18 +113,11 @@ jobs: composer install --prefer-dist --optimize-autoloader & yarn install --immutable - - name: Download dependencies - uses: actions/download-artifact@v2 - with: - name: coblocks-build - path: $(wp-env install-path)/${{ inputs.installPath }}/wp-content/plugins/ - - - # - name: Build plugin - # 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)/${{ inputs.installPath }}/wp-content/plugins/ + - name: Build plugin + 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)/${{ inputs.installPath }}/wp-content/plugins/ - name: Prepare Theme run: | @@ -222,7 +184,7 @@ jobs: test_cypress_e2e_full: if: github.event_name == 'push' - needs: [setup-matrix, build-coblocks] + needs: setup-matrix name: E2E Test runs-on: ubuntu-latest strategy: @@ -277,7 +239,6 @@ jobs: - padding-controls.cypress.js - settings-modal-control.cypress.js - steps: - name: Checkout uses: actions/checkout@v3 @@ -290,7 +251,6 @@ jobs: plugins: '["."]' themes: '["https://downloads.wordpress.org/theme/go.zip"]' - - name: Setup Node uses: actions/setup-node@v3 with: @@ -302,19 +262,11 @@ jobs: composer install --prefer-dist --optimize-autoloader & yarn install --immutable - - name: Download dependencies - uses: actions/download-artifact@v2 - with: - name: coblocks-build - path: $(wp-env install-path)/${{ inputs.installPath }}/wp-content/plugins/ - - - - # - name: Build plugin - # 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)/${{ inputs.installPath }}/wp-content/plugins/ + - name: Build plugin + 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)/${{ inputs.installPath }}/wp-content/plugins/ - name: Prepare Theme run: | From 0162e9aa2db312d16d883f43e9d7107c14b75a1f Mon Sep 17 00:00:00 2001 From: aledesma-godaddy Date: Mon, 6 Nov 2023 11:11:50 -0700 Subject: [PATCH 30/30] fix use tripple equal operator --- .dev/tests/phpunit/includes/test-coblocks-block-assets.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.dev/tests/phpunit/includes/test-coblocks-block-assets.php b/.dev/tests/phpunit/includes/test-coblocks-block-assets.php index 95b4ccd66ed..fce2bd001ce 100644 --- a/.dev/tests/phpunit/includes/test-coblocks-block-assets.php +++ b/.dev/tests/phpunit/includes/test-coblocks-block-assets.php @@ -106,7 +106,7 @@ public function test_editor_assets_scripts() { foreach( $files as $file ) { $dist_script = pathinfo( $file, PATHINFO_FILENAME ); - if ( $dist_script == 'coblocks-plugin-deactivation' ) { + if ( $dist_script === 'coblocks-plugin-deactivation' ) { $this->assertFalse( array_key_exists( $dist_script, $wp_scripts->registered ) ); continue; }