From e8b5768277f716dfd10fd01a4977b992bff341d4 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Wed, 23 Nov 2022 19:31:02 -0600 Subject: [PATCH 01/65] Remove CircleCI config. --- .circleci/config.yml | 1006 ------------------------------------------ 1 file changed, 1006 deletions(-) delete mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 1bc05b31e05..00000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,1006 +0,0 @@ -version: 2.1 - -orbs: - jq: circleci/jq@2.2.0 - browser-tools: circleci/browser-tools@1.1 - node: circleci/node@5.0.0 - -executors: - node_latest: - docker: - - image: cimg/node:16.14 - auth: - username: $DOCKERHUB_USERNAME - password: $DOCKERHUB_PASSWORD - php_74_mysql: - docker: - - image: cimg/php:7.4-node - auth: - username: $DOCKERHUB_USERNAME - password: $DOCKERHUB_PASSWORD - environment: - XDEBUG_MODE=coverage - - image: cimg/mysql:5.7 - auth: - username: $DOCKERHUB_USERNAME - password: $DOCKERHUB_PASSWORD - php_74_browsers_mysql: - docker: - - image: cimg/php:7.4-browsers - auth: - username: $DOCKERHUB_USERNAME - password: $DOCKERHUB_PASSWORD - - image: cimg/mysql:5.7 - auth: - username: $DOCKERHUB_USERNAME - password: $DOCKERHUB_PASSWORD - php_74_browsers_mysql_mailhog: - docker: - - image: cimg/php:7.4-browsers - auth: - username: $DOCKERHUB_USERNAME - password: $DOCKERHUB_PASSWORD - - image: cimg/mysql:5.7 - auth: - username: $DOCKERHUB_USERNAME - password: $DOCKERHUB_PASSWORD - - image: mailhog/mailhog:v1.0.1 - auth: - username: $DOCKERHUB_USERNAME - password: $DOCKERHUB_PASSWORD - php_80_mysql: - docker: - - image: cimg/php:8.0-node - auth: - username: $DOCKERHUB_USERNAME - password: $DOCKERHUB_PASSWORD - environment: - XDEBUG_MODE=coverage - - image: cimg/mysql:5.7 - auth: - username: $DOCKERHUB_USERNAME - password: $DOCKERHUB_PASSWORD - php_81_mysql: - docker: - - image: cimg/php:8.1-node - auth: - username: $DOCKERHUB_USERNAME - password: $DOCKERHUB_PASSWORD - environment: - XDEBUG_MODE=coverage - - image: cimg/mysql:5.7 - auth: - username: $DOCKERHUB_USERNAME - password: $DOCKERHUB_PASSWORD - php_80_browsers_mysql_mailhog: - docker: - - image: cimg/php:8.0-browsers - auth: - username: $DOCKERHUB_USERNAME - password: $DOCKERHUB_PASSWORD - - image: cimg/mysql:5.7 - auth: - username: $DOCKERHUB_USERNAME - password: $DOCKERHUB_PASSWORD - - image: mailhog/mailhog:v1.0.1 - auth: - username: $DOCKERHUB_USERNAME - password: $DOCKERHUB_PASSWORD - php_74_node: - docker: - - image: cimg/php:7.4-node - auth: - username: $DOCKERHUB_USERNAME - password: $DOCKERHUB_PASSWORD - go_browsers: - docker: - - image: cimg/go:1.19-browsers - auth: - username: $DOCKERHUB_USERNAME - password: $DOCKERHUB_PASSWORD - -workflows: - version: 2 - main: - jobs: - - build: - filters: - tags: - only: /^(?!canary).*$/ - - - pr_artifact_comment: - requires: - - build - filters: - branches: - ignore: - - master - - # CODE LINTING - - php: - filters: - tags: - only: /^(?!canary).*$/ - requires: - - build - - css: - requires: - - build - - # UNIT TESTING - # Support PHP Versions: http://php.net/supported-versions.php - - unit_testing_php_74: - filters: - tags: - only: /^(?!canary).*$/ - requires: - - php - - unit_testing_php_80: - filters: - tags: - only: /^(?!canary).*$/ - requires: - - php - - unit_testing_php_81: - filters: - tags: - only: /^(?!canary).*$/ - requires: - - php - - js: - filters: - tags: - only: /^(?!canary).*$/ - requires: - - build - - # END TO END TESTING - - e2e_chrome_wp_latest: - filters: - tags: - only: /^(?!canary).*$/ - requires: - - build - - e2e_firefox_wp_latest: - filters: - tags: - only: /^(?!canary).*$/ - requires: - - build - - e2e_twentytwentythree_chrome_latest: - filters: - tags: - only: /^(?!canary).*$/ - requires: - - build - - - e2e_chrome_wp_php80: - filters: - tags: - only: /^(?!canary).*$/ - requires: - - build - - # A11Y TESTING - - a11y: - filters: - tags: - only: /^(?!canary).*$/ - - # PERF TESTING - - perf_tests_master: - filters: - tags: - only: /^(?!canary).*$/ - - - perf_tests_current: - filters: - tags: - only: /^(?!canary).*$/ - - - aggregate_perf_test_results: - filters: - tags: - only: /^(?!canary).*$/ - requires: - - perf_tests_current - - perf_tests_master - - - canary-release: - filters: - branches: - only: master - requires: - - unit_testing_php_74 - - unit_testing_php_80 - - unit_testing_php_81 - - js - - i18n: - filters: - branches: - only: master - requires: - - unit_testing_php_74 - - unit_testing_php_80 - - unit_testing_php_81 - - js - - - deploy: - requires: - - unit_testing_php_74 - - unit_testing_php_80 - - unit_testing_php_81 - - js - filters: - tags: - only: /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(-(0|[1-9][0-9]*)(\.(0|[1-9][0-9]*))*)?(\+[0-9-]+(\.[0-9]+)*)?/ # Run on semantic version tags only - branches: - ignore: /.*/ - -commands: - - # Find all files with the passed extension that have changed from the base branch. - changed_files_with_extension: - description: "" - parameters: - ext: - type: string - steps: - - run: - name: Get and set base branch env file - command: | - if [ -n "$CIRCLE_PULL_REQUEST" ]; then - GH_API_ENDPOINT="${CIRCLE_PULL_REQUEST/github.com/api.github.com/repos}" - GH_API_ENDPOINT="${GH_API_ENDPOINT/pull/pulls}" - BASE_BRANCH=$(curl -s $GH_API_ENDPOINT | jq -r '.base.ref') - [ "${BASE_BRANCH}" = "null" ] && BASE_BRANCH="master" - else - BASE_BRANCH="master" - fi - - echo "export BASE_BRANCH=$BASE_BRANCH" >> $BASH_ENV - source $BASH_ENV - - run: - name: Set diff files env var - command: | - FILES=$(git diff $(git merge-base HEAD $BASE_BRANCH) --name-only --diff-filter=MAd "*<< parameters.ext >>") - echo "export FILES='$FILES'" >> $BASH_ENV - source $BASH_ENV - - # Install and configure WordPress for end-to-end tests. - install_wordpress_with_coblocks: - description: "" - parameters: - wpversion: - type: string - default: latest - theme: - type: string - default: go - steps: - - run: - name: Update hosts - command: echo 127.0.0.1 coblocks.test | sudo tee -a /etc/hosts - - jq/install - - run: - name: 'Determine which version to install' - command: | - WPVERSION=<< parameters.wpversion >> - if [ "$WPVERSION" == "previous_major" ]; then - WPVERSION=$(curl -s http://api.wordpress.org/core/stable-check/1.0/ | jq 'keys' | jq -r 'map(select(. | test("^[\\d]+.[\\d]+$")))' | jq .[-2]) - fi - echo "export WPVERSION=$WPVERSION" >> $BASH_ENV - source $BASH_ENV - - run: - name: Install WordPress - command: | - sudo apt-get update --allow-releaseinfo-change && sudo apt-get install -y subversion default-mysql-client - mkdir -p /tmp/wordpress - ./vendor/bin/wp core download --version=$WPVERSION --path=/tmp/wordpress - ./vendor/bin/wp config create --dbhost=127.0.0.1 --dbname=coblocks --dbuser=root --dbpass='' --path=/tmp/wordpress - ./vendor/bin/wp db create --path=/tmp/wordpress - ./vendor/bin/wp core install --url="http://coblocks.test" --title=CoBlocks --admin_user=admin --admin_password=password --admin_email=test@admin.com --skip-email --path=/tmp/wordpress - ./vendor/bin/wp post generate --count=5 --path=/tmp/wordpress - - run: - name: Install Theme - command: | - ./vendor/bin/wp theme install << parameters.theme >> --activate --path=/tmp/wordpress - - run: - name: Create custom icon - command: | - mkdir -p /tmp/wordpress/wp-content/themes/go/coblocks/icons - echo '' >> /tmp/wordpress/wp-content/themes/go/coblocks/icons/custom.svg - - run: - name: Activate CoBlocks - command: | - npx grunt build - mv ./build/coblocks /tmp/wordpress/wp-content/plugins/coblocks - ./vendor/bin/wp plugin activate coblocks --path=/tmp/wordpress - - # Enable debug mode for use in E2E tests. - enable_debug_mode_for_e2e: - steps: - - run: - name: Enable Debug Mode - command: ./vendor/bin/wp config set WP_DEBUG true --path=/tmp/wordpress - - # Disable the xdebug PHP extension. - disable_xdebug_php_extension: - description: "" - steps: - - run: - name: Disable xdebug PHP extension - command: | - sudo rm -f /etc/php/*/mods-available/xdebug.ini - sudo rm -f /etc/php/*/mods-enabled/xdebug.ini - sudo rm -f /etc/php/*/conf.d/*xdebug.ini - sudo rm -f /usr/local/etc/php/conf.d/*xdebug.ini - - restore_composer_cache: - steps: - - restore_cache: - keys: - - composer-deps-{{ .Environment.CACHE_VERSION }} - - restore_yarn_cache: - steps: - - restore_cache: - keys: - - yarn-deps-{{ .Environment.CACHE_VERSION }} - - run: - name: Install dependencies missing from cache - command: | - PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true - yarn install --frozen-lockfile - - restore_update_cypress_cache: - steps: - - restore_cache: - keys: - - cypress-deps-{{ .Environment.CACHE_VERSION }} - - run: - name: Install CyPress Binaries - command: ./node_modules/.bin/cypress install - - save_cache: - key: cypress-deps-{{ .Environment.CACHE_VERSION }} - paths: - - ~/.cache/Cypress - - run_e2e_tests: - parameters: - browser: - type: string - wpversion: - type: string - default: latest - theme: - type: string - default: go - steps: - - browser-tools/install-browser-tools - - checkout - - setup_e2e_env_var - - changed_files_with_extension: - ext: ".js" - - disable_xdebug_php_extension - - attach_workspace: - at: ~/project - - restore_yarn_cache - - restore_update_cypress_cache - - restore_composer_cache - - wait_for_mysql - - install_wordpress_with_coblocks: - wpversion: "<< parameters.wpversion >>" - theme: "<< parameters.theme >>" - - enable_debug_mode_for_e2e - - install_mailhog_plugin - - start_wpcli_server - - run: - name: Run end to end tests (Cypress.io) - << parameters.browser >> - command: | - touch cypress.env.json - echo '{"wpUsername":"admin","wpPassword":"password","testURL":"http://coblocks.test"}' | jq . > cypress.env.json - ./node_modules/.bin/cypress verify - ./node_modules/.bin/cypress run --browser << parameters.browser >> --record --parallel --group e2e-<< parameters.browser >>-wp-<< parameters.wpversion >> --headed - - run_a11y_tests: - parameters: - theme: - type: string - default: twentytwentythree - steps: - - browser-tools/install-browser-tools - - checkout - - disable_xdebug_php_extension - - restore_yarn_cache - - restore_composer_cache - - wait_for_mysql - - install_wordpress_with_coblocks: - theme: "<< parameters.theme >>" - - run: - name: Setup pa11y Test Database - command: | - ./vendor/bin/wp db reset --yes --path=/tmp/wordpress - ./vendor/bin/wp db import .dev/tests/a11y/coblocks_pa11y.sql --path=/tmp/wordpress - ./vendor/bin/wp search-replace https://coblocks-pa11y.test http://coblocks.test --path=/tmp/wordpress - rm -rf /tmp/wordpress/wp-content/uploads/2022 - mv .dev/tests/a11y/media/2022 /tmp/wordpress/wp-content/uploads/ - - start_wpcli_server - - run: - name: Run a11y tests - command: | - RESULTS=$(yarn test:a11y) - echo "$RESULTS" - if [[ $RESULTS != *"All accessibility tests have passed"* ]]; then - exit 1 - fi - - store_artifacts: - path: ~/project/.dev/tests/a11y/pa11y-homepage.png - - setup_perf_tests: - steps: - - setup_e2e_env_var - - changed_files_with_extension: - ext: ".js" - - setup_spec_files_diff_tree - - disable_xdebug_php_extension - - attach_workspace: - at: ~/project - - restore_yarn_cache - - wait_for_mysql - - run: - name: Install Composer dependencies - command: | - sudo composer self-update --1 - composer validate --strict - composer install - - run: - name: Prepare MySQL for local testing - command: | - echo 127.0.0.1 localhost | sudo tee -a /etc/hosts - sudo apt-get update --allow-releaseinfo-change && sudo apt-get install -y subversion default-mysql-client - sudo mkdir /conf.d/ - - run_perf_tests: - parameters: - branch: - description: Branch to run performance tests against - type: string - steps: - - run: - name: Run performance tests - command: | - if [ "$CIRCLE_BRANCH" == "master" ] || [ "$CIRCLE_BRANCH" == "develop" ]; then - echo "Changes do not require testing." - circleci-agent step halt - else - ~/project/.dev/performance/cli.js perf --ci << parameters.branch >> - fi - - start_wpcli_server: - steps: - - run: - name: Start WPCLI Server - command: sudo ./vendor/bin/wp server --host=0.0.0.0 --port=80 --allow-root --path=/tmp/wordpress - background: true - - wait_for_mysql: - steps: - - run: - name: Waiting for MySQL to be ready - command: | - for i in `seq 1 10`; - do - nc -z 127.0.0.1 3306 && echo Success && exit 0 - echo -n . - sleep 1 - done - echo Failed waiting for MySQL && exit 1 - - setup_e2e_env_var: - steps: - - run: - name: Setup Environment Variables - command: | - echo "export PATH=/home/linuxbrew/.linuxbrew/bin:$PATH" >> $BASH_ENV - source /home/circleci/.bashrc - - install_mailhog_plugin: - steps: - - run: - name: "Install Mailhog WP Plugin" - command: | - mkdir /tmp/wordpress/wp-content/mu-plugins - cp /home/circleci/project/.dev/mailhog.php /tmp/wordpress/wp-content/mu-plugins/mailhog.php - - setup_spec_files_diff_tree: - steps: - - run: - name: Setup spec files to run based on git diff-tree - command: | - if [[ "$CIRCLE_BRANCH" != "master" && "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != *"run-all-tests"* ]]; then - bash .dev/bin/setup-test-specs.sh $FILES - fi - - run_phpunit_singlesite_with_coverage_reports: - steps: - - run: - name: "Run PHPUnit - Single Site - Generate Coverage Reports" - command: composer run test -- --coverage-html=/tmp/artifacts/code-coverage/phpunit/html --log-junit=/tmp/artifacts/code-coverage/phpunit/results.xml - working_directory: /tmp/wordpress/wp-content/plugins/coblocks - - run_phpunit: - parameters: - multisite: - type: integer - default: 0 - steps: - - run: echo "0 Single mode, 1 Multiside mode. Current mode = << parameters.multisite >>" - - run: - name: "Run PHPUnit" - command: WP_MULTISITE=<< parameters.multisite >> composer run test - working_directory: /tmp/wordpress/wp-content/plugins/coblocks - - install_wordpress_testing_suite: - steps: - - run: - name: "Install WordPress Testing Suite" - command: | - bash .dev/bin/install-dependencies.sh - cp -a $HOME/project /tmp/wordpress/wp-content/plugins/coblocks - - run_php_unit_tests: - parameters: - reportCoverage: - type: boolean - default: true - newPhpUnit: - type: boolean - default: false - steps: - - checkout - - node/install: - node-version: '16.14' - - attach_workspace: - at: ~/project - - restore_yarn_cache - - restore_composer_cache - - wait_for_mysql - - when: - condition: << parameters.newPhpUnit >> - steps: - - run: composer config platform.php "7.4" && composer require phpunit/phpunit:^9.5 -W --dev - - install_wordpress_testing_suite - - when: - condition: << parameters.reportCoverage >> - steps: - - run_phpunit_singlesite_with_coverage_reports - - store_artifacts: - path: /tmp/artifacts/code-coverage/ - destination: phpunit-coverage - - store_test_results: - path: /tmp/artifacts/code-coverage/ - - unless: - condition: << parameters.reportCoverage >> - steps: - - run_phpunit - - run_phpunit: - multisite: 1 - -jobs: - - # 1. Download and cache node and composer dependencies. - # 2. Build deployable plugin folder. - # 3. Persist project folder to workspace for other jobs. - build: - docker: - - image: cimg/php:7.4-node - auth: - username: $DOCKERHUB_USERNAME - password: $DOCKERHUB_PASSWORD - steps: - - checkout - - disable_xdebug_php_extension - - restore_yarn_cache - - run: - name: Store the build number - command: | - echo ${CIRCLE_BUILD_NUM} > build-num.txt - - run: - name: Install Node dependencies - command: | - PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true - yarn install --frozen-lockfile - - save_cache: - key: yarn-deps-{{ .Environment.CACHE_VERSION }} - paths: - - ~/project/node_modules - - ~/.cache/yarn - - restore_composer_cache - - run: - name: Install Composer dependencies - command: | - sudo composer self-update --1 - composer validate --strict - composer install - - save_cache: - key: composer-deps-{{ .Environment.CACHE_VERSION }} - paths: - - ~/project/vendor - - run: - name: Build the plugin - command: | - mkdir -p /tmp/artifacts - yarn build - npx grunt clean:build copy:build - COBLOCKS_VERSION_LINE=$(awk '/\* Version:/' ./build/coblocks/class-coblocks.php) - VER_NUMBER=$(echo "$COBLOCKS_VERSION_LINE" | tr -dc '0-9.') - if [ "$CIRCLE_BRANCH" != 'master' ]; then - COBLOCKS_COMMIT_HASH=$(git rev-parse --verify HEAD | head -c 7) - sed -i -e "s/${VER_NUMBER}/${VER_NUMBER}-${CIRCLE_PULL_REQUEST##*/}+${COBLOCKS_COMMIT_HASH}/g" build/coblocks/class-coblocks.php - fi - cd build - if [ "$CIRCLE_BRANCH" == 'master' ]; then - zip -r "coblocks-v${VER_NUMBER}.zip" coblocks - else - zip -r "coblocks-${CIRCLE_PULL_REQUEST##*/}.zip" coblocks - fi - mv ~/project/build/*.zip /tmp/artifacts - - store_artifacts: - path: /tmp/artifacts - - persist_to_workspace: - root: ~/project - paths: - - build - - dist - - build-num.txt - - pr_artifact_comment: - docker: - - image: cimg/php:7.4-node - auth: - username: $DOCKERHUB_USERNAME - password: $DOCKERHUB_PASSWORD - steps: - - checkout - - attach_workspace: - at: ~/project - - run: - name: Send Comment - command: bash .dev/bin/comment-on-pr.sh - - # -------------------------------------------------- - # Code Quality Checks - # -------------------------------------------------- - - php: - executor: php_74_node - steps: - - checkout - - attach_workspace: - at: ~/project - - restore_composer_cache - - run: - name: Install Composer v1 - command: sudo composer self-update --1 - - restore_cache: - key: phpcs-coblocks-cache - - run: - name: "Linting PHP" - command: composer run lint - - save_cache: - key: phpcs-coblocks-cache - paths: - - /tmp/phpcs-coblocks-cache - - css: - executor: node_latest - steps: - - checkout - - attach_workspace: - at: ~/project - - restore_yarn_cache - - run: - name: "Linting CSS" - command: yarn lint:css - - # -------------------------------------------------- - # Unit Testing - # -------------------------------------------------- - - unit_testing_php_74: - executor: php_74_mysql - steps: - - run_php_unit_tests - - unit_testing_php_80: - executor: php_80_mysql - steps: - - run_php_unit_tests - - unit_testing_php_81: - executor: php_81_mysql - steps: - - run_php_unit_tests: - newPhpUnit: true - reportCoverage: false # we are currently using an incompatible phpunit library for coverage reporting in PHP 8 - - js: - executor: node_latest - steps: - - checkout - - attach_workspace: - at: ~/project - - restore_yarn_cache - - run: - name: "Linting JS" - command: | - yarn lint:js - - run: - name: "Test JS and Collect Coverage" - command: | - yarn test:js:coverage --maxWorkers=2 --reporters=default --reporters=jest-junit - environment: - JEST_JUNIT_OUTPUT_DIR: /tmp/artifacts/tests-results/jest - - store_artifacts: - path: coverage - destination: coverage - - store_test_results: - path: /tmp/artifacts/tests-results/jest - - run: - name: Post coverage comment to GitHub - command: | - if [ -n "$CIRCLE_PULL_REQUEST" ]; then - npx @godaddy-wordpress/circleci-coverage-github-reporter - else - exit 0 - fi - - # -------------------------------------------------- - # End to End Testing - # -------------------------------------------------- - - e2e_chrome_wp_latest: - executor: php_74_browsers_mysql_mailhog - parallelism: 11 - steps: - - run_e2e_tests: - browser: chrome - - e2e_firefox_wp_latest: - executor: php_74_browsers_mysql_mailhog - parallelism: 11 - steps: - - run_e2e_tests: - browser: firefox - - e2e_chrome_wp_previous_major: - executor: php_74_browsers_mysql_mailhog - parallelism: 11 - steps: - - run_e2e_tests: - browser: chrome - wpversion: previous_major - - e2e_twentytwentythree_chrome_latest: - executor: php_74_browsers_mysql_mailhog - parallelism: 11 - steps: - - run_e2e_tests: - browser: chrome - theme: twentytwentythree - - e2e_chrome_wp_php80: - executor: php_80_browsers_mysql_mailhog - parallelism: 11 - steps: - - run_e2e_tests: - browser: chrome - theme: twentytwentythree - - a11y: - executor: php_74_browsers_mysql_mailhog - steps: - - run_a11y_tests: - theme: twentytwentythree - - perf_tests_master: - executor: php_74_browsers_mysql - steps: - - checkout - - setup_perf_tests - - run_perf_tests: - branch: master - - run: - name: Stop Server on Failure - when: on_fail - command: sudo kill $(ps ax | pgrep -f "server") > /dev/null 2>&1 & - - persist_to_workspace: - root: ~/ - paths: - - ./*-median-results.json - - perf_tests_current: - executor: php_74_browsers_mysql - steps: - - checkout - - setup_perf_tests - - run_perf_tests: - branch: ${CIRCLE_BRANCH} - - run: - name: Stop Server on Failure - when: on_fail - command: sudo kill $(ps ax | pgrep -f "server") > /dev/null 2>&1 & - - persist_to_workspace: - root: ~/ - paths: - - ./*-median-results.json - - aggregate_perf_test_results: - executor: php_74_browsers_mysql - steps: - - run: - name: Check branch - command: | - if [ "$CIRCLE_BRANCH" == "master" ] || [ "$CIRCLE_BRANCH" == "develop" ]; then - echo "Performance tests are not run on this branch." - circleci-agent step halt - fi - - checkout - - attach_workspace: - at: ~/project - - run: - name: Check for performance test result files. - command: | - if [ ! -f "./master-median-results.json" ] || [ ! -f "./$CIRCLE_BRANCH-median-results.json" ]; then - echo "Performance tests results not found." - circleci-agent step halt - fi - - changed_files_with_extension: - ext: ".js" - - setup_spec_files_diff_tree - - restore_yarn_cache - - run: - name: Install Node dependencies - command: | - PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true - yarn install --frozen-lockfile - - run: - name: Aggregate performance test results - command: .dev/performance/cli-results.js get-test-results "${CIRCLE_BRANCH}" - - run: - name: Comment Performance Test Results on PR - command: bash .dev/bin/comment-perf-results-on-pr.sh - - # -------------------------------------------------- - # Internationalization Processes - # -------------------------------------------------- - i18n: - executor: php_74_node - steps: - - add_ssh_keys: - fingerprints: - - "14:ee:bc:31:0f:50:7e:fe:8b:56:87:f8:56:db:48:5b" - - checkout - - attach_workspace: - at: ~/project - - restore_yarn_cache - - restore_composer_cache - - disable_xdebug_php_extension - - run: - name: Generate the translations - command: | - npx grunt update-pot - - run: - name: Deploy coblocks.pot/coblocks.json back to GitHub - command: | - export GIT_COMMIT_DESC=$(git log --format=oneline -n 1 $CIRCLE_SHA1) - if [[ $GIT_COMMIT_DESC != *"skip i18n"* ]]; then - git config --global user.email "plugins@godaddy.com" - git config --global user.name "GoDaddy Translator Bot" - git checkout HEAD -- composer.lock - git checkout HEAD -- yarn.lock - git add languages/coblocks.json - git add languages/coblocks.pot - git status - git commit -m "[skip ci] Update coblocks.pot/coblocks.json files" - git reset --hard - git pull --rebase - git push origin master --quiet - fi - - canary-release: - executor: go_browsers - steps: - - checkout - - attach_workspace: - at: ~/project - - restore_yarn_cache - - restore_composer_cache - - run: - name: Install PHP - command: sudo apt update && sudo apt-get install php libapache2-mod-php php-mbstring php-xml php-curl - - run: - name: Install gettext - command: sudo apt-get install gettext - - disable_xdebug_php_extension - - run: - name: Install Composer - command: | - wget https://raw.githubusercontent.com/composer/getcomposer.org/master/web/installer -O composer-setup.php - php composer-setup.php --version=1.10.16 - php -r "unlink('composer-setup.php');" - sudo mv composer.phar /usr/local/bin/composer - - run: - name: Install ghr - command: | - go install github.com/tcnksm/ghr@latest - - run: - name: Build the plugin - command: | - mkdir -p /tmp/artifacts - npx grunt build - COBLOCKS_VERSION_LINE=$(awk '/\* Version:/' ./build/coblocks/class-coblocks.php) - VER_NUMBER=$(echo "$COBLOCKS_VERSION_LINE" | tr -dc '0-9.') - COBLOCKS_COMMIT_HASH=$(git rev-parse --verify HEAD | head -c 7) - sed -i -e "s/${VER_NUMBER}/${VER_NUMBER}-canary+${COBLOCKS_COMMIT_HASH}/g" build/coblocks/class-coblocks.php - npm run json2po - npm run po2mo - npm run po2jed - rm -f languages/*.po languages/*.pot languages/coblocks.json - find languages/ -type f ! -name 'coblocks*' -exec rm {} \; - cp -r languages/ build/coblocks/languages/ - cd build && zip -r coblocks-canary.zip coblocks - mv coblocks-canary.zip /tmp/artifacts/coblocks-canary.zip - - run: - name: Create a canary release on GitHub - command: ghr -t ${GH_AUTH_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -b "Latest build of the master branch. This bleeding edge version is for testing purposes only and should not be used in production." -delete -prerelease -replace canary /tmp/artifacts/coblocks-canary.zip - - deploy: - name: Deploy CoBlocks canary to the WPNUX site - command: | - curl https://wpnux.godaddy.com/v2/webhook-install-canary.php \ - -H 'Content-Type: application/json' \ - -H "X-Authorization: Bearer ${WPNUX_SITE_X_AUTHORIZATION}" \ - -d '[ "coblocks" ]' - - # -------------------------------------------------- - # Plugin Deployment to WordPress.org - # -------------------------------------------------- - deploy: - executor: go_browsers - steps: - - checkout - - attach_workspace: - at: ~/project - - restore_yarn_cache - - restore_composer_cache - - run: - name: Install SVN - command: sudo apt-get update && sudo apt-get install subversion - - run: - name: Install PHP - command: sudo apt update && sudo apt-get install php libapache2-mod-php php-mbstring php-xml php-curl - - disable_xdebug_php_extension - - run: - name: Install Composer - command: | - wget https://raw.githubusercontent.com/composer/getcomposer.org/master/web/installer -O composer-setup.php - php composer-setup.php --version=1.10.16 - php -r "unlink('composer-setup.php');" - sudo mv composer.phar /usr/local/bin/composer - - run: - name: Install ghr - command: | - go install github.com/tcnksm/ghr@latest - - run: - name: Build the plugin - command: | - mkdir -p /tmp/artifacts - npx grunt build - npx grunt compress - mv build/*.zip /tmp/artifacts - - deploy: - name: Deploy the plugin - command: bash .dev/bin/deploy-plugin.sh - - store_artifacts: - path: /tmp/artifacts From c146b24c18e642e91e56b107db5b873c262906a7 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Wed, 23 Nov 2022 19:32:20 -0600 Subject: [PATCH 02/65] Cleanup current actions. --- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/labeler.yml | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index c0646ba638c..9d8752ed77a 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -9,7 +9,7 @@ # the `language` matrix defined below to confirm you have the correct set of # supported CodeQL languages. # -name: "CodeQL" +name: 'Github / CodeQL' on: push: diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 0bbb1c88589..fd593132655 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -1,10 +1,13 @@ -name: Labeler +name: 'Github / Labeler' -on: push +on: + push: + paths: + - '.github/labels.yml' jobs: labeler: - + name: Label runs-on: ubuntu-latest steps: From a3581067952bdcf276f1186824bf8746e1067b72 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Wed, 23 Nov 2022 19:32:45 -0600 Subject: [PATCH 03/65] Rename old actions. --- .../workflows/{codeql-analysis.yml => github-codeql-analysis.yml} | 0 .github/workflows/{labeler.yml => github-labeler.yml} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{codeql-analysis.yml => github-codeql-analysis.yml} (100%) rename .github/workflows/{labeler.yml => github-labeler.yml} (100%) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/github-codeql-analysis.yml similarity index 100% rename from .github/workflows/codeql-analysis.yml rename to .github/workflows/github-codeql-analysis.yml diff --git a/.github/workflows/labeler.yml b/.github/workflows/github-labeler.yml similarity index 100% rename from .github/workflows/labeler.yml rename to .github/workflows/github-labeler.yml From 890d4cb81f7a43e06257d58e3e8124a30d50ef61 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Wed, 23 Nov 2022 19:41:18 -0600 Subject: [PATCH 04/65] Add .nvmrc file. --- .nvmrc | 1 + 1 file changed, 1 insertion(+) create mode 100644 .nvmrc diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 00000000000..b6a7d89c68e --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +16 From 9cdaa83673619de4b958ceae7966e7fc4c1af1b2 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Wed, 23 Nov 2022 19:41:31 -0600 Subject: [PATCH 05/65] Add localization workflow. --- .github/workflows/compliance-localization.yml | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/compliance-localization.yml diff --git a/.github/workflows/compliance-localization.yml b/.github/workflows/compliance-localization.yml new file mode 100644 index 00000000000..edfc641b99d --- /dev/null +++ b/.github/workflows/compliance-localization.yml @@ -0,0 +1,54 @@ +name: 'Compliance / Translations' + +on: + pull_request: + branches: + - master + +jobs: + update: + name: Localize + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup GoDaddy Git User + uses: godaddy-wordpress/setup-godaddy-git-user@v1 + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version-file: '.nvmrc' + cache: 'yarn' + + - name: Setup WP-CLI + uses: godaddy-wordpress/setup-wp-cli@main + + # Yarn is still required on this project, so we need to make sure it is + # installed globally. + - name: Install yarn + run: | + npm i -g yarn + + - name: Install dependencies + run: | + composer install --prefer-dist --optimize-autoloader + yarn install --immutable + + - name: Create translations + run: | + yarn makepot + + - name: Commit changes + shell: bash + run: | + if [ ! -z "$(git status languages/go.json --porcelain)" ]; then + git add languages/go.json + git add languages/go.pot + git commit -m "[BOT] Update language translations" --no-verify + git reset --hard + git push --quiet + else + echo "No language translations to update." + fi From e75dce41c6cee3945bbfd5c613790396158e63b2 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Wed, 23 Nov 2022 20:10:34 -0600 Subject: [PATCH 06/65] Add create artifact workflow, and initial release workflow. --- .distinclude | 17 ++++++ .github/workflows/deploy-create-artifact.yml | 62 ++++++++++++++++++++ .github/workflows/deploy-create-release.yml | 17 ++++++ 3 files changed, 96 insertions(+) create mode 100644 .distinclude create mode 100644 .github/workflows/deploy-create-artifact.yml create mode 100644 .github/workflows/deploy-create-release.yml diff --git a/.distinclude b/.distinclude new file mode 100644 index 00000000000..1cc11ccf7f0 --- /dev/null +++ b/.distinclude @@ -0,0 +1,17 @@ +# List all files and directories to be deployed with the Go thene. +# Use the rsync syntax https://linux.die.net/man/1/rsync + ++ /assets/ ++ /includes/ ++ /dist/ ++ /languages/ ++ /src/blocks/ ++ /src/components/ ++ /src/extensions/ ++ /LICENSE ++ /readme.txt ++ /class-coblocks.php ++ /uninstall.php + +# Exclude everything else +- /* diff --git a/.github/workflows/deploy-create-artifact.yml b/.github/workflows/deploy-create-artifact.yml new file mode 100644 index 00000000000..b742d710b2d --- /dev/null +++ b/.github/workflows/deploy-create-artifact.yml @@ -0,0 +1,62 @@ +name: 'Deploy / Create Artifact' + +on: + workflow_call: + inputs: + retention-days: + required: false + type: number + default: 1 + +env: + ARTIFACT_NAME: 'coblocks-plugin' + ARTIFACT_PATH: 'coblocks' + ARTIFACT_ZIP: 'coblocks.zip' + +# First build our plugin, then create and store the artifact. +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ref: ${{ github.event.repository.default_branch }} + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version-file: '.nvmrc' + cache: 'yarn' + + - name: Setup WP-CLI + uses: godaddy-wordpress/setup-wp-cli@main + + # Yarn is still required on this project, so we need to make sure it is + # installed globally. + - name: Install yarn + run: | + npm i -g yarn + + - name: Install dependencies + run: | + composer install --no-dev --prefer-dist --optimize-autoloader + yarn install --immutable + + - name: Build plugin + run: | + yarn build + + - name: Create distribution artifact + run: | + rsync --archive --recursive --filter='protect .git' --delete --prune-empty-dirs --include-from="$GITHUB_WORKSPACE/.distinclude" "$GITHUB_WORKSPACE/" "$GITHUB_WORKSPACE/$ARTIFACT_PATH/" + zip -r $ARTIFACT_ZIP $ARTIFACT_PATH + + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: ${{ env.ARTIFACT_NAME }} + path: ${{ env.ARTIFACT_ZIP }} + if-no-files-found: error + retention-days: ${{ inputs.retention-days }} diff --git a/.github/workflows/deploy-create-release.yml b/.github/workflows/deploy-create-release.yml new file mode 100644 index 00000000000..30bbe945686 --- /dev/null +++ b/.github/workflows/deploy-create-release.yml @@ -0,0 +1,17 @@ +name: 'Deploy / Create Release' + +on: + pull_request: + branches: + - master + milestone: + types: [ closed ] + +env: + ARTIFACT_NAME: 'coblocks-plugin' + ARTIFACT_ZIP: 'coblocks.zip' + +jobs: + build: + name: Build + uses: ./.github/workflows/deploy-create-artifact.yml From 337339e90ba30b1c10fd4bdd955aa1675798de07 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Wed, 23 Nov 2022 20:12:30 -0600 Subject: [PATCH 07/65] Comment out default branch code until ready. --- .github/workflows/deploy-create-artifact.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-create-artifact.yml b/.github/workflows/deploy-create-artifact.yml index b742d710b2d..49ca5f664b8 100644 --- a/.github/workflows/deploy-create-artifact.yml +++ b/.github/workflows/deploy-create-artifact.yml @@ -21,8 +21,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - with: - ref: ${{ github.event.repository.default_branch }} + # with: + # ref: ${{ github.event.repository.default_branch }} - name: Setup Node uses: actions/setup-node@v3 From 6bab74d50eb32cfa42283bc056d83f0e833a18b2 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Wed, 23 Nov 2022 20:14:00 -0600 Subject: [PATCH 08/65] Install dev on artifact. --- .github/workflows/deploy-create-artifact.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-create-artifact.yml b/.github/workflows/deploy-create-artifact.yml index 49ca5f664b8..35e7ce8ac0d 100644 --- a/.github/workflows/deploy-create-artifact.yml +++ b/.github/workflows/deploy-create-artifact.yml @@ -41,7 +41,7 @@ jobs: - name: Install dependencies run: | - composer install --no-dev --prefer-dist --optimize-autoloader + composer install --prefer-dist --optimize-autoloader yarn install --immutable - name: Build plugin From 9093d2cd7536ae2c0d7a88e0a8bb69b8fe45e52b Mon Sep 17 00:00:00 2001 From: Evan Herman Date: Fri, 2 Dec 2022 11:37:13 -0500 Subject: [PATCH 09/65] Introduce validation-coding-standards.yml (#2452) * Introduce validation-coding-standards.yml * Change branch for testing * Remove branch * Add - * Re-add branch * update * Yarn install before phpcs * Composer install * Composer lint * Refactor composer install * Tweak * Tweak * Test remove composer install * Remove Install Composer steps * Switch action trigger to pull_request * yarn install --immutable * actions/checkout@v3 * Updates --- .../workflows/validation-coding-standards.yml | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .github/workflows/validation-coding-standards.yml diff --git a/.github/workflows/validation-coding-standards.yml b/.github/workflows/validation-coding-standards.yml new file mode 100644 index 00000000000..a713361bc70 --- /dev/null +++ b/.github/workflows/validation-coding-standards.yml @@ -0,0 +1,58 @@ +name: 'Validation / Coding Standards' + +on: + pull_request: + branches: + - master + +jobs: + php: + runs-on: ubuntu-latest + name: PHP + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Composer Install + run: composer install --prefer-dist --optimize-autoloader + + - name: Install dependencies + run: composer lint + + css: + runs-on: ubuntu-latest + name: CSS + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version-file: '.nvmrc' + cache: 'yarn' + + - name: Install dependencies + run: yarn install --immutable + + - name: Run lint + run: yarn lint:css + + js: + runs-on: ubuntu-latest + name: JS + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version-file: '.nvmrc' + cache: 'yarn' + + - name: Install dependencies + run: yarn install --immutable + + - name: Run lint + run: yarn lint:js From c1bc713d2550af06a90ea120a59748ea9cc87a70 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Tue, 6 Dec 2022 11:55:37 -0600 Subject: [PATCH 10/65] GitHub Actions Migration - Add Initial Tests (#2457) --- .dev/tests/cypress/helpers.js | 6 +- .dev/tests/cypress/readme.md | 2 +- .dev/tests/cypress/support/commands.js | 14 --- .github/workflows/deploy-create-release.yml | 103 +++++++++++++++++- .github/workflows/test-accessibility.yml | 53 +++++++++ .github/workflows/test-e2e-cypress.yml | 97 +++++++++++++++++ .github/workflows/test-e2e.yml | 19 ++++ .github/workflows/test-javascript.yml | 27 +++++ .github/workflows/test-php-unit.yml | 47 ++++++++ .github/workflows/test-php.yml | 25 +++++ ...ation.yml => translation-localization.yml} | 4 +- cypress.config.js | 3 +- package.json | 2 +- src/blocks/alert/test/alert.cypress.js | 2 + src/blocks/author/test/author.cypress.js | 16 +++ 15 files changed, 396 insertions(+), 24 deletions(-) create mode 100644 .github/workflows/test-accessibility.yml create mode 100644 .github/workflows/test-e2e-cypress.yml create mode 100644 .github/workflows/test-e2e.yml create mode 100644 .github/workflows/test-javascript.yml create mode 100644 .github/workflows/test-php-unit.yml create mode 100644 .github/workflows/test-php.yml rename .github/workflows/{compliance-localization.yml => translation-localization.yml} (96%) diff --git a/.dev/tests/cypress/helpers.js b/.dev/tests/cypress/helpers.js index f04fa9fc137..eef7b2c4db5 100644 --- a/.dev/tests/cypress/helpers.js +++ b/.dev/tests/cypress/helpers.js @@ -175,8 +175,6 @@ export function savePage() { */ export function checkForBlockErrors( blockName ) { - disableGutenbergFeatures(); - cy.get( '.block-editor-warning' ).should( 'not.exist' ); cy.get( 'body.php-error' ).should( 'not.exist' ); @@ -230,6 +228,10 @@ export function clearBlocks() { safeWin.wp.data.dispatch( 'core/block-editor' ).removeBlocks( safeWin.wp.data.select( 'core/block-editor' ).getBlocks().map( ( block ) => block.clientId ) ); + + if ( safeWin.wp.data.select( 'core/edit-post' ).isFeatureActive( 'welcomeGuide' ) ) { + safeWin.wp.data.dispatch( 'core/edit-post' ).toggleFeature( 'welcomeGuide' ); + } } ); } diff --git a/.dev/tests/cypress/readme.md b/.dev/tests/cypress/readme.md index 18b4f0a3e23..2f8730ca984 100644 --- a/.dev/tests/cypress/readme.md +++ b/.dev/tests/cypress/readme.md @@ -9,7 +9,7 @@ Welcome to our end-to-end testing suite for CoBlocks blocks! There are a number ### Add your local test credentials ```bash $ echo '{ - "testURL": "https://coblocks.test", + "testURL": "https://localhost:8889", "wpUsername": "admin", "wpPassword": "password", }' > cypress.env.json diff --git a/.dev/tests/cypress/support/commands.js b/.dev/tests/cypress/support/commands.js index 49187c233a0..71b0d4e8611 100644 --- a/.dev/tests/cypress/support/commands.js +++ b/.dev/tests/cypress/support/commands.js @@ -1,17 +1,3 @@ -import { disableGutenbergFeatures, isNotWPLocalEnv, loginToSite } from '../helpers'; - -before( function() { - loginToSite().then( () => { - if ( isNotWPLocalEnv() ) { - // Waiting to see if the Welcome Guide will show up. Could probably be improved, but - // for the moment, it seems hard to tie the wait to something else - cy.wait( 10000 ); - } - - disableGutenbergFeatures(); - } ); -} ); - // Maintain WordPress logged in state Cypress.Cookies.defaults( { preserve: /wordpress_.*/, diff --git a/.github/workflows/deploy-create-release.yml b/.github/workflows/deploy-create-release.yml index 30bbe945686..1a4e1b5a4fc 100644 --- a/.github/workflows/deploy-create-release.yml +++ b/.github/workflows/deploy-create-release.yml @@ -1,9 +1,6 @@ name: 'Deploy / Create Release' on: - pull_request: - branches: - - master milestone: types: [ closed ] @@ -12,6 +9,106 @@ env: ARTIFACT_ZIP: 'coblocks.zip' jobs: + update: + name: Update version + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version-file: '.nvmrc' + cache: 'yarn' + + - name: Setup git user + uses: godaddy-wordpress/setup-godaddy-git-user@v1 + + # Yarn is still required on this project, so we need to make sure it is + # installed globally. + - name: Install yarn + run: npm i -g yarn + + - name: Set version + run: | + echo "NEW_TAG_VERSION=${{ github.event.milestone.title }}" >> $GITHUB_ENV + + - name: Validate tag version + run: | + MATCH='^([0-9]+\.){2}(\*|[0-9]+)(-.*)?$' + if ! [[ $NEW_TAG_VERSION =~ $MATCH ]]; then + echo "::error::Milestone title does not match semver format: '$NEW_TAG_VERSION'" + exit 1 + fi + + - name: Install dependencies + run: | + yarn install --immutable + + - name: Run version update + run: yarn version --new-version $NEW_TAG_VERSION + + - name: Push changes + run: | + git add . + git commit -m "Updating to version $NEW_TAG_VERSION" --no-verify + git push + build: name: Build uses: ./.github/workflows/deploy-create-artifact.yml + needs: update + + tag: + runs-on: ubuntu-latest + name: Tag new version + needs: update + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ref: ${{ github.event.repository.default_branch }} + + - name: Setup git user + uses: godaddy-wordpress/setup-godaddy-git-user@v1 + + - name: Set version + run: | + echo "NEW_TAG_VERSION=${{ github.event.milestone.title }}" >> $GITHUB_ENV + + - name: Publish new tag + run: | + git tag $NEW_TAG_VERSION + git push origin $NEW_TAG_VERSION + + release: + runs-on: ubuntu-latest + name: Create new release + needs: [ build, tag ] + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ref: ${{ github.event.repository.default_branch }} + + - name: Set release version + run: | + echo "RELEASE_VERSION=${{ github.event.milestone.title }}" >> $GITHUB_ENV + + - name: Create release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release create $RELEASE_VERSION -n "${{ github.event.milestone.description }}" -t "$RELEASE_VERSION" + + - name: Download theme + uses: actions/download-artifact@v3 + with: + name: ${{ env.ARTIFACT_NAME }} + + - name: Upload asset to release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release upload $RELEASE_VERSION ${{ env.ARTIFACT_ZIP }} diff --git a/.github/workflows/test-accessibility.yml b/.github/workflows/test-accessibility.yml new file mode 100644 index 00000000000..d4d68cec51d --- /dev/null +++ b/.github/workflows/test-accessibility.yml @@ -0,0 +1,53 @@ +name: WIP Test / Accessibility + +on: + pull_request: + branches: + - master + +jobs: + pa11y: + name: Pa11y + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup wp-env + uses: godaddy-wordpress/setup-wp-env@v1 + with: + core: 'WordPress/WordPress#6.1' + phpVersion: '7.4' + plugins: '[".","https://downloads.wordpress.org/plugin/woocommerce.zip"]' + themes: '["https://downloads.wordpress.org/theme/go.zip"]' + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version-file: '.nvmrc' + cache: 'yarn' + + - name: Setup WP-CLI + uses: godaddy-wordpress/setup-wp-cli@1 + + - name: Install dependencies + run: | + npm i -g yarn + composer install + yarn install --immutable + + - name: Build plugin + run: | + yarn build + + - name: Prepare tests + run: | + wp-env run cli "wp db import wp-content/plugins/coblocks/.dev/tests/a11y/coblocks_pa11y.sql" + + - name: Run tests + run: | + A11Y=$(yarn test:a11y) + echo "$A11Y" + if [[ $A11Y != *"All accessibility tests have passed"* ]]; then + exit 1 + fi diff --git a/.github/workflows/test-e2e-cypress.yml b/.github/workflows/test-e2e-cypress.yml new file mode 100644 index 00000000000..6e17ff3c09c --- /dev/null +++ b/.github/workflows/test-e2e-cypress.yml @@ -0,0 +1,97 @@ +name: WIP Test / E2E + +on: + workflow_call: + inputs: + browser: + required: false + type: string + default: chrome + theme: + required: false + type: string + default: go + wpVersion: + required: false + type: string + default: "" + phpVersion: + required: false + type: string + default: "8.1" + secrets: + record-key: + description: 'Record key for Cypress Dashboard' + required: true + +jobs: + test_cypress_e2e: + name: E2E Test + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + spec: + - alert.cypress.js + - author.cypress.js + + 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: Setup WP-CLI + uses: godaddy-wordpress/setup-wp-cli@1 + + - name: Install dependencies + run: | + composer install --prefer-dist --optimize-autoloader & + yarn install --immutable + + - name: Build plugin + run: | + yarn build + + - name: Prepare Go + if: ${{ inputs.theme == 'go' }} + run: | + cd $(wp-env install-path)/go + 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 cli "wp post generate --count=5" + wp-env run cli "wp theme activate ${{ inputs.theme }}" + wp-env run cli "wp option update permalink_structure '/%postname%'" + + - 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 $CYPRESS_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 + diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml new file mode 100644 index 00000000000..e8a1c9dd3db --- /dev/null +++ b/.github/workflows/test-e2e.yml @@ -0,0 +1,19 @@ +name: WIP Test / E2E + +on: + pull_request: + branches: + - master + +jobs: + chrome_e2e: + name: Chrome + uses: ./.github/workflows/test-e2e-cypress.yml + secrets: + record-key: ${{ secrets.CYPRESS_RECORD_KEY }} + + # firefox_e2e: + # name: Firefox + # uses: ./.github/workflows/test-e2e-cypress.yml + # with: + # browser: firefox diff --git a/.github/workflows/test-javascript.yml b/.github/workflows/test-javascript.yml new file mode 100644 index 00000000000..fda84b28fce --- /dev/null +++ b/.github/workflows/test-javascript.yml @@ -0,0 +1,27 @@ +name: WIP Test / JS + +on: + pull_request: + branches: + - master + +jobs: + + js_unit: + name: Unit + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version-file: '.nvmrc' + cache: 'yarn' + + - name: Install dependencies + run: yarn install --immutable + + - name: Run tests + run: yarn run test:js diff --git a/.github/workflows/test-php-unit.yml b/.github/workflows/test-php-unit.yml new file mode 100644 index 00000000000..65b7e9bfcec --- /dev/null +++ b/.github/workflows/test-php-unit.yml @@ -0,0 +1,47 @@ +name: WIP Test / PHP + +on: + workflow_call: + inputs: + phpVersion: + required: false + type: string + default: 8.1 + +jobs: + php_unit: + name: Unit Test + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version-file: '.nvmrc' + cache: 'yarn' + + - name: Setup WP-CLI + uses: godaddy-wordpress/setup-wp-cli@1 + + - name: Install dependencies + run: | + npm i -g yarn + composer install --prefer-dist --optimize-autoloader & + yarn install --immutable + + - name: Build plugin + run: | + yarn build + + - name: Setup wp-env + uses: godaddy-wordpress/setup-wp-env@v1 + with: + phpVersion: ${{ inputs.phpVersion }} + plugins: '[".","https://downloads.wordpress.org/plugin/woocommerce.zip"]' + themes: '["https://downloads.wordpress.org/theme/go.zip"]' + + - name: Run tests + run: | + wp-env run phpunit 'phpunit -c /var/www/html/wp-content/plugins/coblocks/phpunit.xml.dist --verbose' diff --git a/.github/workflows/test-php.yml b/.github/workflows/test-php.yml new file mode 100644 index 00000000000..826bee672b2 --- /dev/null +++ b/.github/workflows/test-php.yml @@ -0,0 +1,25 @@ +name: WIP Test / PHP + +on: + pull_request: + branches: + - master + +jobs: + php_unit_74: + name: PHP 7.4 + uses: ./.github/workflows/test-php-unit.yml + with: + phpVersion: '7.4' + + php_unit_80: + name: PHP 8.0 + uses: ./.github/workflows/test-php-unit.yml + with: + phpVersion: '8.0' + + php_unit_81: + name: PHP 8.1 + uses: ./.github/workflows/test-php-unit.yml + with: + phpVersion: '8.1' diff --git a/.github/workflows/compliance-localization.yml b/.github/workflows/translation-localization.yml similarity index 96% rename from .github/workflows/compliance-localization.yml rename to .github/workflows/translation-localization.yml index edfc641b99d..7957d279f87 100644 --- a/.github/workflows/compliance-localization.yml +++ b/.github/workflows/translation-localization.yml @@ -1,4 +1,4 @@ -name: 'Compliance / Translations' +name: 'Translation' on: pull_request: @@ -7,7 +7,7 @@ on: jobs: update: - name: Localize + name: Localization runs-on: ubuntu-latest steps: - name: Checkout diff --git a/cypress.config.js b/cypress.config.js index 67b516a48ab..187cfefbea0 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -2,7 +2,7 @@ const { defineConfig } = require( 'cypress' ); module.exports = defineConfig( { chromeWebSecurity: false, - defaultCommandTimeout: 120000, + defaultCommandTimeout: 20000, e2e: { setupNodeEvents( on, config ) { return require( './.dev/tests/cypress/plugins/index.js' )( on, config ); @@ -23,6 +23,7 @@ module.exports = defineConfig( { runMode: 0, }, screenshotsFolder: '.dev/tests/cypress/screenshots', + videosFolder: '.dev/tests/cypress/videos', viewportHeight: 1440, viewportWidth: 2560, } ); diff --git a/package.json b/package.json index 09b22cd5c6c..eddcd72d053 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ ], "testing": { "urls": { - "local": "http://coblocks.test", + "local": "http://localhost:8889", "staging": "", "production": "" }, diff --git a/src/blocks/alert/test/alert.cypress.js b/src/blocks/alert/test/alert.cypress.js index 20089328cc0..0449e711254 100644 --- a/src/blocks/alert/test/alert.cypress.js +++ b/src/blocks/alert/test/alert.cypress.js @@ -15,6 +15,8 @@ describe( 'Test CoBlocks Alert Block', function() { helpers.savePage(); + helpers.disableGutenbergFeatures(); + helpers.checkForBlockErrors( 'coblocks/alert' ); } ); diff --git a/src/blocks/author/test/author.cypress.js b/src/blocks/author/test/author.cypress.js index 84915c9a6a0..761c8b1a578 100644 --- a/src/blocks/author/test/author.cypress.js +++ b/src/blocks/author/test/author.cypress.js @@ -4,6 +4,22 @@ import * as helpers from '../../../../.dev/tests/cypress/helpers'; describe( 'Test CoBlocks Author Block', function() { + before( () => { + helpers.loginToSite().then( () => { + if ( helpers.isNotWPLocalEnv() ) { + cy.wait( 10000 ); + } + + helpers.disableGutenbergFeatures(); + } ); + } ); + + beforeEach( () => { + if ( wp.data.select( 'core/edit-post' ).isFeatureActive( 'welcomeGuide' ) ) { + wp.data.dispatch( 'core/edit-post' ).toggleFeature( 'welcomeGuide' ); + } + } ); + /** * Test that we can add a author block to the content, not add any text or * alter any settings, and are able to successfully save the block without errors. From e931b80db825bf9b5415853542a46bec06c91c34 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Tue, 6 Dec 2022 13:53:09 -0600 Subject: [PATCH 11/65] Try running close in beforeEach.cy.visit.onLoad() --- .dev/tests/cypress/helpers.js | 9 --------- .dev/tests/cypress/support/commands.js | 8 ++++++++ .github/workflows/test-e2e.yml | 3 +++ src/blocks/alert/test/alert.cypress.js | 10 ++++++++++ src/blocks/author/test/author.cypress.js | 20 +++++++------------- 5 files changed, 28 insertions(+), 22 deletions(-) diff --git a/.dev/tests/cypress/helpers.js b/.dev/tests/cypress/helpers.js index eef7b2c4db5..558bba7d135 100644 --- a/.dev/tests/cypress/helpers.js +++ b/.dev/tests/cypress/helpers.js @@ -92,11 +92,6 @@ export function disableGutenbergFeatures() { safeWin.wp.data.dispatch( 'core/edit-post' ).toggleFeature( 'fixedToolbar' ); } - if ( safeWin.wp.data.select( 'core/edit-post' ).isFeatureActive( 'welcomeGuide' ) ) { - safeWin.wp.data.dispatch( 'core/edit-post' ).toggleFeature( 'welcomeGuide' ); - } else { - } - safeWin.wp.data.dispatch( 'core/editor' ).disablePublishSidebar(); } ); } @@ -228,10 +223,6 @@ export function clearBlocks() { safeWin.wp.data.dispatch( 'core/block-editor' ).removeBlocks( safeWin.wp.data.select( 'core/block-editor' ).getBlocks().map( ( block ) => block.clientId ) ); - - if ( safeWin.wp.data.select( 'core/edit-post' ).isFeatureActive( 'welcomeGuide' ) ) { - safeWin.wp.data.dispatch( 'core/edit-post' ).toggleFeature( 'welcomeGuide' ); - } } ); } diff --git a/.dev/tests/cypress/support/commands.js b/.dev/tests/cypress/support/commands.js index 71b0d4e8611..ba5988e8c38 100644 --- a/.dev/tests/cypress/support/commands.js +++ b/.dev/tests/cypress/support/commands.js @@ -1,3 +1,11 @@ +import { disableGutenbergFeatures, loginToSite } from '../helpers'; + +before( function() { + loginToSite().then( () => { + disableGutenbergFeatures(); + } ); +} ); + // Maintain WordPress logged in state Cypress.Cookies.defaults( { preserve: /wordpress_.*/, diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index e8a1c9dd3db..a1bc71688ca 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -4,6 +4,9 @@ on: pull_request: branches: - master + push: + branches: + - feature/github-actions-migration-WPEX-2662 jobs: chrome_e2e: diff --git a/src/blocks/alert/test/alert.cypress.js b/src/blocks/alert/test/alert.cypress.js index 0449e711254..1723a351ede 100644 --- a/src/blocks/alert/test/alert.cypress.js +++ b/src/blocks/alert/test/alert.cypress.js @@ -4,6 +4,16 @@ import * as helpers from '../../../../.dev/tests/cypress/helpers'; describe( 'Test CoBlocks Alert Block', function() { + beforeEach( () => { + cy.visit( Cypress.env( 'testURL' ) + '/wp-admin/post-new.php?post_type=post', { + onLoad: ( contentWindow ) => { + if ( !! contentWindow.wp.data.select( 'core/edit-post' ).isFeatureActive( 'welcomeGuide' ) ) { + contentWindow.wp.data.dispatch( 'core/edit-post' ).toggleFeature( 'welcomeGuide' ); + } + }, + } ); + } ); + /** * Test that we can add a alert block to the content, not add any text or * alter any settings, and are able to successfully save the block without errors. diff --git a/src/blocks/author/test/author.cypress.js b/src/blocks/author/test/author.cypress.js index 761c8b1a578..dfa1e8d3d83 100644 --- a/src/blocks/author/test/author.cypress.js +++ b/src/blocks/author/test/author.cypress.js @@ -4,20 +4,14 @@ import * as helpers from '../../../../.dev/tests/cypress/helpers'; describe( 'Test CoBlocks Author Block', function() { - before( () => { - helpers.loginToSite().then( () => { - if ( helpers.isNotWPLocalEnv() ) { - cy.wait( 10000 ); - } - - helpers.disableGutenbergFeatures(); - } ); - } ); - beforeEach( () => { - if ( wp.data.select( 'core/edit-post' ).isFeatureActive( 'welcomeGuide' ) ) { - wp.data.dispatch( 'core/edit-post' ).toggleFeature( 'welcomeGuide' ); - } + cy.visit( Cypress.env( 'testURL' ) + '/wp-admin/post-new.php?post_type=post', { + onLoad: ( contentWindow ) => { + if ( !! contentWindow.wp.data.select( 'core/edit-post' ).isFeatureActive( 'welcomeGuide' ) ) { + contentWindow.wp.data.dispatch( 'core/edit-post' ).toggleFeature( 'welcomeGuide' ); + } + }, + } ); } ); /** From 3df550d97378c1bb3e40d7aa4d9f46be0cdd8967 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Tue, 6 Dec 2022 14:06:14 -0600 Subject: [PATCH 12/65] Add accordion test. --- .github/workflows/test-e2e-cypress.yml | 1 + src/blocks/accordion/test/accordion.cypress.js | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/.github/workflows/test-e2e-cypress.yml b/.github/workflows/test-e2e-cypress.yml index 6e17ff3c09c..a16c2eb9520 100644 --- a/.github/workflows/test-e2e-cypress.yml +++ b/.github/workflows/test-e2e-cypress.yml @@ -32,6 +32,7 @@ jobs: fail-fast: false matrix: spec: + - accordion.cypress.js - alert.cypress.js - author.cypress.js diff --git a/src/blocks/accordion/test/accordion.cypress.js b/src/blocks/accordion/test/accordion.cypress.js index ecbcbe4ed94..e10574efc96 100644 --- a/src/blocks/accordion/test/accordion.cypress.js +++ b/src/blocks/accordion/test/accordion.cypress.js @@ -5,6 +5,14 @@ import * as helpers from '../../../../.dev/tests/cypress/helpers'; describe( 'Block: Accordion', () => { beforeEach( () => { + cy.visit( Cypress.env( 'testURL' ) + '/wp-admin/post-new.php?post_type=post', { + onLoad: ( contentWindow ) => { + if ( !! contentWindow.wp.data.select( 'core/edit-post' ).isFeatureActive( 'welcomeGuide' ) ) { + contentWindow.wp.data.dispatch( 'core/edit-post' ).toggleFeature( 'welcomeGuide' ); + } + }, + } ); + helpers.addBlockToPost( 'coblocks/accordion', true ); } ); From b5694386ed9c709af040d516e7cb94711824c17a Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Tue, 6 Dec 2022 14:20:27 -0600 Subject: [PATCH 13/65] Try just alert block. --- .github/workflows/test-e2e-cypress.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/test-e2e-cypress.yml b/.github/workflows/test-e2e-cypress.yml index a16c2eb9520..c461fe2fb87 100644 --- a/.github/workflows/test-e2e-cypress.yml +++ b/.github/workflows/test-e2e-cypress.yml @@ -32,9 +32,7 @@ jobs: fail-fast: false matrix: spec: - - accordion.cypress.js - alert.cypress.js - - author.cypress.js steps: - name: Checkout From 3be783138f91162016333f3ea340193001e20054 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Tue, 6 Dec 2022 14:26:52 -0600 Subject: [PATCH 14/65] Run with author. --- .github/workflows/test-e2e-cypress.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-e2e-cypress.yml b/.github/workflows/test-e2e-cypress.yml index c461fe2fb87..6e17ff3c09c 100644 --- a/.github/workflows/test-e2e-cypress.yml +++ b/.github/workflows/test-e2e-cypress.yml @@ -33,6 +33,7 @@ jobs: matrix: spec: - alert.cypress.js + - author.cypress.js steps: - name: Checkout From ca50f25fd82ad17c63e1f99e5b7be981dcb83cab Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Tue, 6 Dec 2022 16:01:52 -0600 Subject: [PATCH 15/65] Fix toolbar options not showing. --- src/blocks/author/test/author.cypress.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/blocks/author/test/author.cypress.js b/src/blocks/author/test/author.cypress.js index dfa1e8d3d83..2d3b885a724 100644 --- a/src/blocks/author/test/author.cypress.js +++ b/src/blocks/author/test/author.cypress.js @@ -88,7 +88,10 @@ describe( 'Test CoBlocks Author Block', function() { cy.get( '.wp-block-coblocks-author' ).then( ( author ) => { if ( ! author.prop( 'outerHTML' ).includes( 'editor-url-input' ) ) { // wp 5.4 - cy.get( author ).find( '.wp-block-button__link' ).click(); + cy.get( '.wp-block-coblocks-author__name' ).click(); + cy.get( '.wp-block-coblocks-author .wp-block-button__link' ).click(); + cy.get( '.wp-block-coblocks-author__name' ).click(); + cy.get( '.wp-block-coblocks-author .wp-block-button__link' ).click(); cy.get( '.block-editor-block-toolbar' ) .find( 'button.components-button[aria-label="Link"]' ) .click(); From e9e10dcab7df3cc620645a6a019566e7278356aa Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Tue, 6 Dec 2022 16:18:23 -0600 Subject: [PATCH 16/65] Change when the save is reloaded. --- .dev/tests/cypress/helpers.js | 5 +++-- src/blocks/alert/test/alert.cypress.js | 2 -- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.dev/tests/cypress/helpers.js b/.dev/tests/cypress/helpers.js index 558bba7d135..869c2bcaec3 100644 --- a/.dev/tests/cypress/helpers.js +++ b/.dev/tests/cypress/helpers.js @@ -154,9 +154,10 @@ export function addNewGroupToPost() { * From inside the WordPress editor open the CoBlocks Gutenberg editor panel */ export function savePage() { - cy.get( '.edit-post-header__settings button.is-primary' ).click(); + cy.get( '.editor-post-publish-button__button[aria-disabled="false"]' ).click(); - cy.get( '.components-editor-notices__snackbar', { timeout: 120000 } ).should( 'not.be.empty' ); + cy.get( '.editor-post-publish-button__button[aria-disabled="true"]' ).should( 'exist' ); + cy.wait( 2000 ); // Reload the page to ensure that we're not hitting any block errors cy.reload(); diff --git a/src/blocks/alert/test/alert.cypress.js b/src/blocks/alert/test/alert.cypress.js index 1723a351ede..79c5d7196bb 100644 --- a/src/blocks/alert/test/alert.cypress.js +++ b/src/blocks/alert/test/alert.cypress.js @@ -25,8 +25,6 @@ describe( 'Test CoBlocks Alert Block', function() { helpers.savePage(); - helpers.disableGutenbergFeatures(); - helpers.checkForBlockErrors( 'coblocks/alert' ); } ); From 7694be0be59450162a37e10198d264187683ea58 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Tue, 6 Dec 2022 16:45:36 -0600 Subject: [PATCH 17/65] Try waiting 5 seconds. --- .dev/tests/cypress/helpers.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.dev/tests/cypress/helpers.js b/.dev/tests/cypress/helpers.js index 869c2bcaec3..57b78e7ea89 100644 --- a/.dev/tests/cypress/helpers.js +++ b/.dev/tests/cypress/helpers.js @@ -156,8 +156,7 @@ export function addNewGroupToPost() { export function savePage() { cy.get( '.editor-post-publish-button__button[aria-disabled="false"]' ).click(); - cy.get( '.editor-post-publish-button__button[aria-disabled="true"]' ).should( 'exist' ); - cy.wait( 2000 ); + cy.wait( 5000 ); // Reload the page to ensure that we're not hitting any block errors cy.reload(); From 47bc557921353aef85eb00ed767d128705a6633e Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Tue, 6 Dec 2022 16:58:14 -0600 Subject: [PATCH 18/65] Run headed. --- .dev/tests/cypress/helpers.js | 2 +- .github/workflows/test-e2e-cypress.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.dev/tests/cypress/helpers.js b/.dev/tests/cypress/helpers.js index 57b78e7ea89..ee310315e92 100644 --- a/.dev/tests/cypress/helpers.js +++ b/.dev/tests/cypress/helpers.js @@ -154,7 +154,7 @@ export function addNewGroupToPost() { * From inside the WordPress editor open the CoBlocks Gutenberg editor panel */ export function savePage() { - cy.get( '.editor-post-publish-button__button[aria-disabled="false"]' ).click(); + cy.get( '.editor-post-publish-button__button' ).click(); cy.wait( 5000 ); diff --git a/.github/workflows/test-e2e-cypress.yml b/.github/workflows/test-e2e-cypress.yml index 6e17ff3c09c..a2fb636adbc 100644 --- a/.github/workflows/test-e2e-cypress.yml +++ b/.github/workflows/test-e2e-cypress.yml @@ -85,7 +85,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 $CYPRESS_SPEC + ./node_modules/.bin/cypress run --browser ${{ inputs.browser }} --spec $CYPRESS_SPEC --headed - name: Upload failure video if: ${{ failure() }} From f1099c52a1747e743d0310b663bc5166f4e7916e Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Tue, 6 Dec 2022 17:11:41 -0600 Subject: [PATCH 19/65] Switch back to old method --- .dev/tests/cypress/helpers.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.dev/tests/cypress/helpers.js b/.dev/tests/cypress/helpers.js index ee310315e92..558bba7d135 100644 --- a/.dev/tests/cypress/helpers.js +++ b/.dev/tests/cypress/helpers.js @@ -154,9 +154,9 @@ export function addNewGroupToPost() { * From inside the WordPress editor open the CoBlocks Gutenberg editor panel */ export function savePage() { - cy.get( '.editor-post-publish-button__button' ).click(); + cy.get( '.edit-post-header__settings button.is-primary' ).click(); - cy.wait( 5000 ); + cy.get( '.components-editor-notices__snackbar', { timeout: 120000 } ).should( 'not.be.empty' ); // Reload the page to ensure that we're not hitting any block errors cy.reload(); From ff884b954dbec8843c97c976c0789e02af33306d Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Fri, 20 Jan 2023 07:15:16 -0500 Subject: [PATCH 20/65] Add Playwright. --- package.json | 1 + yarn.lock | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/package.json b/package.json index eddcd72d053..6f8db85dd13 100644 --- a/package.json +++ b/package.json @@ -91,6 +91,7 @@ "@godaddy-wordpress/eslint-config": "^0.6.0", "@godaddy-wordpress/stylelint-config": "^0.6.0", "@jest/core": "^27.4.5", + "@playwright/test": "^1.28.1", "@react-google-maps/api": "^2.7.0", "@testing-library/jest-dom": "^5.16.1", "@testing-library/react-hooks": "^7.0.2", diff --git a/yarn.lock b/yarn.lock index e3506ced24a..2c89379b933 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1562,6 +1562,14 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" +"@playwright/test@^1.28.1": + version "1.28.1" + resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.28.1.tgz#e5be297e024a3256610cac2baaa9347fd57c7860" + integrity sha512-xN6spdqrNlwSn9KabIhqfZR7IWjPpFK1835tFNgjrlysaSezuX8PYUwaz38V/yI8TJLG9PkAMEXoHRXYXlpTPQ== + dependencies: + "@types/node" "*" + playwright-core "1.28.1" + "@pmmmwh/react-refresh-webpack-plugin@^0.5.2": version "0.5.6" resolved "https://registry.npmjs.org/@pmmmwh/react-refresh-webpack-plugin/-/react-refresh-webpack-plugin-0.5.6.tgz" @@ -10477,6 +10485,11 @@ pkg-dir@4.2.0, pkg-dir@^4.1.0, pkg-dir@^4.2.0: dependencies: find-up "^4.0.0" +playwright-core@1.28.1: + version "1.28.1" + resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.28.1.tgz#8400be9f4a8d1c0489abdb9e75a4cc0ffc3c00cb" + integrity sha512-3PixLnGPno0E8rSBJjtwqTwJe3Yw72QwBBBxNoukIj3lEeBNXwbNiKrNuB1oyQgTBw5QHUhNO3SteEtHaMK6ag== + plur@^4.0.0: version "4.0.0" resolved "https://registry.npmjs.org/plur/-/plur-4.0.0.tgz" From 1ab174e210f61a4f8a4e2ccd1832da1e975c3feb Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Fri, 20 Jan 2023 07:17:11 -0500 Subject: [PATCH 21/65] Ignore playwright files. --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 6d14888dde0..3b00f38e154 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,7 @@ languages/*.po cypress.env.json .wp-env.json .wp-env.override.json +/test-results/ +/playwright-report/ +/playwright/.cache/ +.dev/tests/playwright/storage-state.json From 769ce499bdf83c24dbd29835aed11dff5528c8cc Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Fri, 20 Jan 2023 07:20:22 -0500 Subject: [PATCH 22/65] Add Playwright config. --- playwright.config.js | 64 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 playwright.config.js diff --git a/playwright.config.js b/playwright.config.js new file mode 100644 index 00000000000..2a42cc327cb --- /dev/null +++ b/playwright.config.js @@ -0,0 +1,64 @@ +// @ts-check +const { devices } = require( '@playwright/test' ); + +const config = { + expect: { + timeout: 5000, + }, + forbidOnly: !! process.env.CI, + fullyParallel: true, + globalSetup: require.resolve( './.dev/tests/playwright/global-setup' ), + outputDir: './.dev/tests/playwright/test-results/', + projects: [ + { + name: 'chromium', + use: { + ...devices[ 'Desktop Chrome' ], + }, + }, + + { + name: 'firefox', + use: { + ...devices[ 'Desktop Firefox' ], + }, + }, + + { + name: 'webkit', + use: { + ...devices[ 'Desktop Safari' ], + }, + }, + + /* Test against mobile viewports. */ + { + name: 'Mobile Chrome', + use: { + ...devices[ 'Pixel 5' ], + }, + }, + { + name: 'Mobile Safari', + use: { + ...devices[ 'iPhone 12' ], + }, + }, + ], + + reporter: process.env.CI ? 'dot' : [ [ 'html', { open: 'never' } ] ], + retries: process.env.CI ? 2 : 0, + testDir: './src', + testMatch: '**/src/**/**/*.playwright.spec.js', + timeout: 30 * 1000, + use: { + actionTimeout: 0, + baseURL: 'http://localhost:8889', + headless: true, + storageState: './.dev/tests/playwright/storage-state.json', + trace: 'on-first-retry', + video: 'on-first-retry', + }, +}; + +module.exports = config; From 8679ebeb68e3eab0fe70879186d1cd2c9f9668c6 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Fri, 20 Jan 2023 07:22:07 -0500 Subject: [PATCH 23/65] Add playwright global setup. --- .dev/tests/playwright/global-setup.js | 37 +++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .dev/tests/playwright/global-setup.js diff --git a/.dev/tests/playwright/global-setup.js b/.dev/tests/playwright/global-setup.js new file mode 100644 index 00000000000..cda20cc862e --- /dev/null +++ b/.dev/tests/playwright/global-setup.js @@ -0,0 +1,37 @@ +/** + * Global setup file for Playwright tests, and is executed once before all tests + * are run. + */ +const { chromium, expect } = require( '@playwright/test' ); + +module.exports = async () => { + const browser = await chromium.launch(); + const page = await browser.newPage( { + baseURL: 'http://localhost:8889', + } ); + + // Log in to WordPress. + await page.goto( '/wp-login.php' ); + await page.fill( '#user_login', 'admin' ); + await page.fill( '#user_pass', 'password' ); + await page.click( '#wp-submit' ); + await page.goto( '/wp-admin/post-new.php?post_type=post' ); + + // Wait for wp.data to be available. + await page.waitForFunction( () => window.wp.data !== undefined ); + + // Ensure the Welcome Guide is disabled. + if ( await page.evaluate( "wp.data.select( 'core/edit-post' ).isFeatureActive( 'welcomeGuide' )" ) ) { + await page.evaluate( "wp.data.dispatch( 'core/edit-post' ).toggleFeature( 'welcomeGuide' )" ); + } + + await page.goto( '/wp-admin' ); + await page.goto( '/wp-admin/post-new.php?post_type=post' ); + + // Expect the Welcome Guide to be hidden. + await expect( page.locator( '.edit-post-welcome-guide' ) ).toBeHidden(); + + // Save signed-in state to 'storageState.json'. + await page.context().storageState( { path: '.dev/tests/playwright/storage-state.json' } ); + await browser.close(); +}; From 152e0471fd90d1d328439a724b406106e6df476e Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Fri, 20 Jan 2023 07:26:15 -0500 Subject: [PATCH 24/65] Change testMatch and add alert test. --- playwright.config.js | 2 +- src/blocks/alert/test/alert.playwright.js | 39 +++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 src/blocks/alert/test/alert.playwright.js diff --git a/playwright.config.js b/playwright.config.js index 2a42cc327cb..a45c2ae991d 100644 --- a/playwright.config.js +++ b/playwright.config.js @@ -49,7 +49,7 @@ const config = { reporter: process.env.CI ? 'dot' : [ [ 'html', { open: 'never' } ] ], retries: process.env.CI ? 2 : 0, testDir: './src', - testMatch: '**/src/**/**/*.playwright.spec.js', + testMatch: '**/src/**/**/*.playwright.js', timeout: 30 * 1000, use: { actionTimeout: 0, diff --git a/src/blocks/alert/test/alert.playwright.js b/src/blocks/alert/test/alert.playwright.js new file mode 100644 index 00000000000..a3dd9647ca4 --- /dev/null +++ b/src/blocks/alert/test/alert.playwright.js @@ -0,0 +1,39 @@ +import { test, expect } from '@playwright/test'; + +const blockName = 'coblocks/alert'; + +test.beforeEach( async ( { page, browserName }, info ) => { + await page.goto( '/wp-admin/post-new.php?post_type=post' ); + + await page.waitForFunction( () => window.wp.data !== undefined ); + + await page.evaluate( `wp.data.dispatch( 'core/editor' ).editPost( { title: '${ browserName } - ${ info.title }' } )` ); + await page.evaluate( `wp.data.dispatch( 'core/editor' ).insertBlocks( wp.blocks.createBlock( '${ blockName }' ) )` ); + await page.evaluate( `wp.data.dispatch( 'core/editor' ).savePost()` ); +} ); + +test( 'Alert block saves with no title or text', async ( { page } ) => { + await expect( page.locator( `[data-type="${ blockName }"]` ) ).toBeVisible(); + await page.reload(); + await expect( page.locator( `[data-type="${ blockName }"]` ) ).toBeVisible(); +} ); + +test( 'Alert block saves with custom title and text', async ( { page } ) => { + const alertTitle = 'GoDaddy'; + const alertText = 'Domain Names, Websites, Hosting & Online Marketing Tools'; + + await page.type( '.wp-block-coblocks-alert__title', alertTitle ); + await page.type( '.wp-block-coblocks-alert__text', alertText ); + + await expect( page.locator( `.wp-block-coblocks-alert__title` ) ).not.toBeEmpty(); + await expect( page.locator( `.wp-block-coblocks-alert__text` ) ).not.toBeEmpty(); + + await expect( page.locator( `.wp-block-coblocks-alert__title` ) ).toContainText( alertTitle ); + await expect( page.locator( `.wp-block-coblocks-alert__text` ) ).toContainText( alertText ); + + await page.evaluate( `wp.data.dispatch( 'core/editor' ).savePost()` ); + await page.reload(); + + await expect( page.locator( `.wp-block-coblocks-alert__title` ) ).toContainText( alertTitle ); + await expect( page.locator( `.wp-block-coblocks-alert__text` ) ).toContainText( alertText ); +} ); From 0b21f5ddfcb1c7ad83d0fe574763501c93a9f8bd Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Fri, 20 Jan 2023 18:41:10 -0500 Subject: [PATCH 25/65] Fix global setup to use correct context. --- .dev/tests/playwright/global-setup.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.dev/tests/playwright/global-setup.js b/.dev/tests/playwright/global-setup.js index cda20cc862e..cff12ba3696 100644 --- a/.dev/tests/playwright/global-setup.js +++ b/.dev/tests/playwright/global-setup.js @@ -6,10 +6,15 @@ const { chromium, expect } = require( '@playwright/test' ); module.exports = async () => { const browser = await chromium.launch(); - const page = await browser.newPage( { + const context = await browser.newContext( { baseURL: 'http://localhost:8889', + recordVideo: { + dir: '.dev/tests/playwright/videos', + }, } ); + const page = await context.newPage(); + // Log in to WordPress. await page.goto( '/wp-login.php' ); await page.fill( '#user_login', 'admin' ); @@ -21,17 +26,17 @@ module.exports = async () => { await page.waitForFunction( () => window.wp.data !== undefined ); // Ensure the Welcome Guide is disabled. - if ( await page.evaluate( "wp.data.select( 'core/edit-post' ).isFeatureActive( 'welcomeGuide' )" ) ) { - await page.evaluate( "wp.data.dispatch( 'core/edit-post' ).toggleFeature( 'welcomeGuide' )" ); + if ( await page.evaluate( `wp.data.select( 'core/edit-post' ).isFeatureActive( 'welcomeGuide' )` ) ) { + await page.evaluate( `wp.data.dispatch( 'core/edit-post' ).toggleFeature( 'welcomeGuide' )` ); } - await page.goto( '/wp-admin' ); - await page.goto( '/wp-admin/post-new.php?post_type=post' ); + await page.reload(); // Expect the Welcome Guide to be hidden. await expect( page.locator( '.edit-post-welcome-guide' ) ).toBeHidden(); // Save signed-in state to 'storageState.json'. await page.context().storageState( { path: '.dev/tests/playwright/storage-state.json' } ); + await context.close(); await browser.close(); }; From b6f87d425a370421ca95f64937f8f9827706053b Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Fri, 20 Jan 2023 18:42:11 -0500 Subject: [PATCH 26/65] Ignore recoreded videos from Playwright. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 3b00f38e154..3e40ce30797 100644 --- a/.gitignore +++ b/.gitignore @@ -29,4 +29,5 @@ cypress.env.json /test-results/ /playwright-report/ /playwright/.cache/ +.dev/tests/playwright/videos/ .dev/tests/playwright/storage-state.json From 2815122908ed298dd61bc5f8ae09196cc8606312 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Fri, 20 Jan 2023 18:42:25 -0500 Subject: [PATCH 27/65] Update Playwright. --- package.json | 2 +- yarn.lock | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 45b867744c7..26e52732955 100644 --- a/package.json +++ b/package.json @@ -91,7 +91,7 @@ "@godaddy-wordpress/eslint-config": "^0.6.0", "@godaddy-wordpress/stylelint-config": "^0.6.0", "@jest/core": "^27.4.5", - "@playwright/test": "^1.28.1", + "@playwright/test": "^1.29.2", "@react-google-maps/api": "^2.7.0", "@testing-library/jest-dom": "^5.16.1", "@testing-library/react-hooks": "^7.0.2", diff --git a/yarn.lock b/yarn.lock index 8980cabfa83..5ff31e70c4d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1562,13 +1562,13 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" -"@playwright/test@^1.28.1": - version "1.28.1" - resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.28.1.tgz#e5be297e024a3256610cac2baaa9347fd57c7860" - integrity sha512-xN6spdqrNlwSn9KabIhqfZR7IWjPpFK1835tFNgjrlysaSezuX8PYUwaz38V/yI8TJLG9PkAMEXoHRXYXlpTPQ== +"@playwright/test@^1.29.2": + version "1.29.2" + resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.29.2.tgz#c48184721d0f0b7627a886e2ec42f1efb2be339d" + integrity sha512-+3/GPwOgcoF0xLz/opTnahel1/y42PdcgZ4hs+BZGIUjtmEFSXGg+nFoaH3NSmuc7a6GSFwXDJ5L7VXpqzigNg== dependencies: "@types/node" "*" - playwright-core "1.28.1" + playwright-core "1.29.2" "@pmmmwh/react-refresh-webpack-plugin@^0.5.2": version "0.5.6" @@ -2138,9 +2138,9 @@ integrity sha512-HUAiN65VsRXyFCTicolwb5+I7FM6f72zjMWr+ajGk+YTvzBgXqa2A5U7d+rtsouAkunJ5U4Sb5lNJjo9w+nmXg== "@types/node@*": - version "17.0.33" - resolved "https://registry.npmjs.org/@types/node/-/node-17.0.33.tgz" - integrity sha512-miWq2m2FiQZmaHfdZNcbpp9PuXg34W5JZ5CrJ/BaS70VuhoJENBEQybeiYSaPBRNq6KQGnjfEnc/F3PN++D+XQ== + version "18.11.18" + resolved "https://registry.yarnpkg.com/@types/node/-/node-18.11.18.tgz#8dfb97f0da23c2293e554c5a50d61ef134d7697f" + integrity sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA== "@types/node@^14.14.31": version "14.18.18" @@ -10478,10 +10478,10 @@ pkg-dir@4.2.0, pkg-dir@^4.1.0, pkg-dir@^4.2.0: dependencies: find-up "^4.0.0" -playwright-core@1.28.1: - version "1.28.1" - resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.28.1.tgz#8400be9f4a8d1c0489abdb9e75a4cc0ffc3c00cb" - integrity sha512-3PixLnGPno0E8rSBJjtwqTwJe3Yw72QwBBBxNoukIj3lEeBNXwbNiKrNuB1oyQgTBw5QHUhNO3SteEtHaMK6ag== +playwright-core@1.29.2: + version "1.29.2" + resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.29.2.tgz#2e8347e7e8522409f22b244e600e703b64022406" + integrity sha512-94QXm4PMgFoHAhlCuoWyaBYKb92yOcGVHdQLoxQ7Wjlc7Flg4aC/jbFW7xMR52OfXMVkWicue4WXE7QEegbIRA== plur@^4.0.0: version "4.0.0" From 9d276ca9779c277429963926707df961b0dda50d Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Fri, 20 Jan 2023 18:50:44 -0500 Subject: [PATCH 28/65] Update config. --- playwright.config.js | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/playwright.config.js b/playwright.config.js index a45c2ae991d..476ffe896dd 100644 --- a/playwright.config.js +++ b/playwright.config.js @@ -24,26 +24,18 @@ const config = { }, }, - { - name: 'webkit', - use: { - ...devices[ 'Desktop Safari' ], - }, - }, - - /* Test against mobile viewports. */ - { - name: 'Mobile Chrome', - use: { - ...devices[ 'Pixel 5' ], - }, - }, - { - name: 'Mobile Safari', - use: { - ...devices[ 'iPhone 12' ], - }, - }, + /** + * WordPress version 6.1+ throws and error with the version of Webkit + * that Playwright currently utilizes. Likely this will be resolved when + * Gutenberg finishes migrating to Playwright, and then we can use the + * wordpress/e2e-test-utils-playwright package from Core. + */ + // { + // name: 'webkit', + // use: { + // ...devices[ 'Desktop Safari' ], + // }, + // }, ], reporter: process.env.CI ? 'dot' : [ [ 'html', { open: 'never' } ] ], From 1a730bd48f401aacc268702413ddd6b44c11d746 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Fri, 20 Jan 2023 18:51:59 -0500 Subject: [PATCH 29/65] Group test and run in parallel. --- src/blocks/alert/test/alert.playwright.js | 53 ++++++++++++----------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/src/blocks/alert/test/alert.playwright.js b/src/blocks/alert/test/alert.playwright.js index a3dd9647ca4..1e3e80fcf6c 100644 --- a/src/blocks/alert/test/alert.playwright.js +++ b/src/blocks/alert/test/alert.playwright.js @@ -2,38 +2,41 @@ import { test, expect } from '@playwright/test'; const blockName = 'coblocks/alert'; -test.beforeEach( async ( { page, browserName }, info ) => { - await page.goto( '/wp-admin/post-new.php?post_type=post' ); +test.describe.parallel( 'Alert', () => { + test.beforeEach( async ( { page, browserName }, info ) => { + await page.goto( '/wp-admin/post-new.php?post_type=post' ); - await page.waitForFunction( () => window.wp.data !== undefined ); + await page.waitForFunction( () => window.wp.data !== undefined ); - await page.evaluate( `wp.data.dispatch( 'core/editor' ).editPost( { title: '${ browserName } - ${ info.title }' } )` ); - await page.evaluate( `wp.data.dispatch( 'core/editor' ).insertBlocks( wp.blocks.createBlock( '${ blockName }' ) )` ); - await page.evaluate( `wp.data.dispatch( 'core/editor' ).savePost()` ); -} ); + await page.evaluate( `wp.data.dispatch( 'core/editor' ).editPost( { title: '${ browserName } - ${ blockName } - ${ info.title }' } )` ); + await page.evaluate( `wp.data.dispatch( 'core/block-editor' ).insertBlocks( wp.blocks.createBlock( '${ blockName }' ) )` ); + await page.evaluate( `wp.data.dispatch( 'core/editor' ).savePost()` ); + } ); -test( 'Alert block saves with no title or text', async ( { page } ) => { - await expect( page.locator( `[data-type="${ blockName }"]` ) ).toBeVisible(); - await page.reload(); - await expect( page.locator( `[data-type="${ blockName }"]` ) ).toBeVisible(); -} ); + test( 'saves with no title or text', async ( { page } ) => { + await expect( page.locator( `[data-type="${ blockName }"]` ) ).toBeVisible(); + await page.reload(); + await expect( page.locator( `[data-type="${ blockName }"]` ) ).toBeVisible(); + } ); + + test( 'saves with custom title and text', async ( { page } ) => { + const alertTitle = 'GoDaddy'; + const alertText = 'Domain Names, Websites, Hosting & Online Marketing Tools'; -test( 'Alert block saves with custom title and text', async ( { page } ) => { - const alertTitle = 'GoDaddy'; - const alertText = 'Domain Names, Websites, Hosting & Online Marketing Tools'; + await page.type( '.wp-block-coblocks-alert__title', alertTitle ); + await page.type( '.wp-block-coblocks-alert__text', alertText ); - await page.type( '.wp-block-coblocks-alert__title', alertTitle ); - await page.type( '.wp-block-coblocks-alert__text', alertText ); + await expect( page.locator( `.wp-block-coblocks-alert__title` ) ).not.toBeEmpty(); + await expect( page.locator( `.wp-block-coblocks-alert__text` ) ).not.toBeEmpty(); - await expect( page.locator( `.wp-block-coblocks-alert__title` ) ).not.toBeEmpty(); - await expect( page.locator( `.wp-block-coblocks-alert__text` ) ).not.toBeEmpty(); + await expect( page.locator( `.wp-block-coblocks-alert__title` ) ).toContainText( alertTitle ); + await expect( page.locator( `.wp-block-coblocks-alert__text` ) ).toContainText( alertText ); - await expect( page.locator( `.wp-block-coblocks-alert__title` ) ).toContainText( alertTitle ); - await expect( page.locator( `.wp-block-coblocks-alert__text` ) ).toContainText( alertText ); + await page.evaluate( `wp.data.dispatch( 'core/editor' ).savePost()` ); + await page.reload(); - await page.evaluate( `wp.data.dispatch( 'core/editor' ).savePost()` ); - await page.reload(); + await expect( page.locator( `.wp-block-coblocks-alert__title` ) ).toContainText( alertTitle ); + await expect( page.locator( `.wp-block-coblocks-alert__text` ) ).toContainText( alertText ); + } ); - await expect( page.locator( `.wp-block-coblocks-alert__title` ) ).toContainText( alertTitle ); - await expect( page.locator( `.wp-block-coblocks-alert__text` ) ).toContainText( alertText ); } ); From c98554f44e12650ec0d0637150975c1420fcacd4 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Mon, 23 Jan 2023 09:10:50 -0500 Subject: [PATCH 30/65] Finish up accordion e2e test. --- .../accordion/test/accordion.playwright.js | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 src/blocks/accordion/test/accordion.playwright.js diff --git a/src/blocks/accordion/test/accordion.playwright.js b/src/blocks/accordion/test/accordion.playwright.js new file mode 100644 index 00000000000..2787b9efbb3 --- /dev/null +++ b/src/blocks/accordion/test/accordion.playwright.js @@ -0,0 +1,74 @@ +import { test, expect } from '@playwright/test'; + +const blockName = 'coblocks/accordion'; + +test.describe.parallel( 'Accordion', () => { + test.beforeEach( async ( { page, browserName }, info ) => { + await page.goto( '/wp-admin/post-new.php?post_type=post' ); + + await page.waitForFunction( () => window.wp.data !== undefined ); + + await page.evaluate( `wp.data.dispatch( 'core/editor' ).editPost( { title: '${ browserName } - ${ info.title }' } )` ); + await page.evaluate( `wp.data.dispatch( 'core/block-editor' ).insertBlock( wp.blocks.createBlock( '${ blockName }' ) )` ); + await page.evaluate( `wp.data.dispatch( 'core/editor' ).savePost()` ); + } ); + + test( 'saves with no title or content', async ( { page } ) => { + await expect( page.locator( `[data-type="${ blockName }"]` ) ).toBeVisible(); + await page.reload(); + await expect( page.locator( `[data-type="${ blockName }"]` ) ).toBeVisible(); + } ); + + test( 'saves with custom title', async ( { page } ) => { + const title = 'GoDaddy'; + const titleLocator = '.wp-block-coblocks-accordion-item__title'; + + await page.type( titleLocator, title ); + + await expect( page.locator( titleLocator ) ).not.toBeEmpty(); + + await expect( page.locator( titleLocator ) ).toContainText( title ); + + await page.evaluate( `wp.data.dispatch( 'core/editor' ).savePost()` ); + await page.reload(); + + await expect( page.locator( titleLocator ) ).toContainText( title ); + } ); + + test( 'saves with custom content', async ( { page } ) => { + const clientId = await page.evaluate( `wp.data.select( 'core/block-editor' ).getBlocks().shift().innerBlocks.shift().clientId` ); + const contentLocator = '.wp-block-coblocks-accordion-item__content .wp-block-paragraph:first-child'; + const contentText = 'Domain Names, Websites, Hosting & Online Marketing Tools'; + + await page.type( '.wp-block-coblocks-accordion-item__title', 'GoDaddy' ); + await page.evaluate( `wp.data.dispatch( 'core/block-editor' ).insertBlocks( wp.blocks.createBlock( 'core/paragraph', { content: '${ contentText }' } ), 0, '${ clientId }' )` ); + + await expect( page.locator( contentLocator ) ).toBeVisible(); + await expect( page.locator( contentLocator ) ).not.toBeEmpty(); + + await expect( page.locator( contentLocator ) ).toContainText( contentText ); + + await page.evaluate( `wp.data.dispatch( 'core/editor' ).savePost()` ); + await page.reload(); + + await page.locator( '.wp-block-coblocks-accordion-item__title' ).focus(); + await expect( page.locator( contentLocator ) ).toContainText( contentText ); + } ); + + test( 'appends additional accordion item', async ( { page } ) => { + const accordionItemsLocator = '.wp-block-coblocks-accordion [data-type="coblocks/accordion-item"]'; + await expect( page.locator( '.coblocks-block-appender' ) ).toBeVisible(); + + await page.locator( '.coblocks-block-appender' ).click(); + + let accordionItems = await page.locator( accordionItemsLocator ); + await expect( accordionItems ).toHaveCount( 2 ); + + await page.evaluate( `wp.data.dispatch( 'core/editor' ).savePost()` ); + await page.reload(); + + accordionItems = await page.locator( accordionItemsLocator ); + await expect( accordionItems ).toHaveCount( 2 ); + } ); +} ); + From bcd2baaa6d7c6304f12e4cc91e9357b01956d019 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Mon, 23 Jan 2023 15:14:00 -0500 Subject: [PATCH 31/65] Add click-to-tweet test. --- .../test/click-to-tweet.playwright.js | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/blocks/click-to-tweet/test/click-to-tweet.playwright.js diff --git a/src/blocks/click-to-tweet/test/click-to-tweet.playwright.js b/src/blocks/click-to-tweet/test/click-to-tweet.playwright.js new file mode 100644 index 00000000000..cf6d35437c7 --- /dev/null +++ b/src/blocks/click-to-tweet/test/click-to-tweet.playwright.js @@ -0,0 +1,55 @@ +import { test, expect } from '@playwright/test'; + +const blockName = 'coblocks/click-to-tweet'; + +test.describe.parallel( 'Click to Tweet', () => { + test.beforeEach( async ( { page, browserName }, info ) => { + await page.goto( '/wp-admin/post-new.php?post_type=post' ); + + await page.waitForFunction( () => window.wp.data !== undefined ); + + await page.evaluate( `wp.data.dispatch( 'core/editor' ).editPost( { title: '${ browserName } - ${ info.title }' } )` ); + await page.evaluate( `wp.data.dispatch( 'core/block-editor' ).insertBlock( wp.blocks.createBlock( '${ blockName }' ) )` ); + await page.evaluate( `wp.data.dispatch( 'core/editor' ).savePost()` ); + } ); + + test( 'saves with no content', async ( { page } ) => { + await expect( page.locator( `[data-type="${ blockName }"]` ) ).toBeVisible(); + await page.reload(); + await expect( page.locator( `[data-type="${ blockName }"]` ) ).toBeVisible(); + } ); + + test( 'saves with custom content', async ( { page } ) => { + const text = 'GoDaddy - Domain Names, Websites, Hosting & Online Marketing Tools'; + const textLocator = '.wp-block-coblocks-click-to-tweet__text'; + + await page.type( textLocator, text ); + + await expect( page.locator( textLocator ) ).not.toBeEmpty(); + + await expect( page.locator( textLocator ) ).toContainText( text ); + + await page.evaluate( `wp.data.dispatch( 'core/editor' ).savePost()` ); + await page.reload(); + + await expect( page.locator( textLocator ) ).toContainText( text ); + } ); + + test( 'can add tweet via', async ( { page } ) => { + const via = 'godaddy'; + const viaLocator = '.wp-block-coblocks-click-to-tweet__via'; + + await page.type( viaLocator, via ); + + await expect( page.locator( viaLocator ) ).not.toBeEmpty(); + + await expect( page.locator( viaLocator ) ).toHaveValue( via ); + + await page.evaluate( `wp.data.dispatch( 'core/editor' ).savePost()` ); + await page.reload(); + + await page.locator( '.wp-block-coblocks-click-to-tweet__text' ).focus(); + await expect( page.locator( viaLocator ) ).toHaveValue( via ); + } ); +} ); + From 585b3d8d265b465313e2f526b4f96d9621287ab7 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Mon, 23 Jan 2023 15:56:27 -0500 Subject: [PATCH 32/65] Revert changes for Cypress. --- .dev/tests/cypress/helpers.js | 4 ---- .dev/tests/cypress/support/commands.js | 14 ++++++++++++++ src/blocks/alert/test/alert.cypress.js | 2 -- src/blocks/author/test/author.cypress.js | 16 ---------------- 4 files changed, 14 insertions(+), 22 deletions(-) diff --git a/.dev/tests/cypress/helpers.js b/.dev/tests/cypress/helpers.js index eef7b2c4db5..1ca1cfd8c86 100644 --- a/.dev/tests/cypress/helpers.js +++ b/.dev/tests/cypress/helpers.js @@ -228,10 +228,6 @@ export function clearBlocks() { safeWin.wp.data.dispatch( 'core/block-editor' ).removeBlocks( safeWin.wp.data.select( 'core/block-editor' ).getBlocks().map( ( block ) => block.clientId ) ); - - if ( safeWin.wp.data.select( 'core/edit-post' ).isFeatureActive( 'welcomeGuide' ) ) { - safeWin.wp.data.dispatch( 'core/edit-post' ).toggleFeature( 'welcomeGuide' ); - } } ); } diff --git a/.dev/tests/cypress/support/commands.js b/.dev/tests/cypress/support/commands.js index 71b0d4e8611..49187c233a0 100644 --- a/.dev/tests/cypress/support/commands.js +++ b/.dev/tests/cypress/support/commands.js @@ -1,3 +1,17 @@ +import { disableGutenbergFeatures, isNotWPLocalEnv, loginToSite } from '../helpers'; + +before( function() { + loginToSite().then( () => { + if ( isNotWPLocalEnv() ) { + // Waiting to see if the Welcome Guide will show up. Could probably be improved, but + // for the moment, it seems hard to tie the wait to something else + cy.wait( 10000 ); + } + + disableGutenbergFeatures(); + } ); +} ); + // Maintain WordPress logged in state Cypress.Cookies.defaults( { preserve: /wordpress_.*/, diff --git a/src/blocks/alert/test/alert.cypress.js b/src/blocks/alert/test/alert.cypress.js index 0449e711254..20089328cc0 100644 --- a/src/blocks/alert/test/alert.cypress.js +++ b/src/blocks/alert/test/alert.cypress.js @@ -15,8 +15,6 @@ describe( 'Test CoBlocks Alert Block', function() { helpers.savePage(); - helpers.disableGutenbergFeatures(); - helpers.checkForBlockErrors( 'coblocks/alert' ); } ); diff --git a/src/blocks/author/test/author.cypress.js b/src/blocks/author/test/author.cypress.js index 761c8b1a578..84915c9a6a0 100644 --- a/src/blocks/author/test/author.cypress.js +++ b/src/blocks/author/test/author.cypress.js @@ -4,22 +4,6 @@ import * as helpers from '../../../../.dev/tests/cypress/helpers'; describe( 'Test CoBlocks Author Block', function() { - before( () => { - helpers.loginToSite().then( () => { - if ( helpers.isNotWPLocalEnv() ) { - cy.wait( 10000 ); - } - - helpers.disableGutenbergFeatures(); - } ); - } ); - - beforeEach( () => { - if ( wp.data.select( 'core/edit-post' ).isFeatureActive( 'welcomeGuide' ) ) { - wp.data.dispatch( 'core/edit-post' ).toggleFeature( 'welcomeGuide' ); - } - } ); - /** * Test that we can add a author block to the content, not add any text or * alter any settings, and are able to successfully save the block without errors. From 37a2a09a5411d978017e9d44982fa4c2d5aec3eb Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Mon, 23 Jan 2023 15:57:09 -0500 Subject: [PATCH 33/65] Only run the alert test for now. --- .github/workflows/test-e2e-cypress.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test-e2e-cypress.yml b/.github/workflows/test-e2e-cypress.yml index 6e17ff3c09c..c461fe2fb87 100644 --- a/.github/workflows/test-e2e-cypress.yml +++ b/.github/workflows/test-e2e-cypress.yml @@ -33,7 +33,6 @@ jobs: matrix: spec: - alert.cypress.js - - author.cypress.js steps: - name: Checkout From f1f0f87e4e0a95536f08336f965da3b9c4db06fa Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Mon, 23 Jan 2023 15:58:24 -0500 Subject: [PATCH 34/65] Readd to block check in Cypress. --- .dev/tests/cypress/helpers.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.dev/tests/cypress/helpers.js b/.dev/tests/cypress/helpers.js index 1ca1cfd8c86..f04fa9fc137 100644 --- a/.dev/tests/cypress/helpers.js +++ b/.dev/tests/cypress/helpers.js @@ -175,6 +175,8 @@ export function savePage() { */ export function checkForBlockErrors( blockName ) { + disableGutenbergFeatures(); + cy.get( '.block-editor-warning' ).should( 'not.exist' ); cy.get( 'body.php-error' ).should( 'not.exist' ); From abc35d80499bfc5140a3b41b018b288b6f1b65db Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Mon, 23 Jan 2023 18:49:08 -0500 Subject: [PATCH 35/65] Wait for wp.data to exist. --- .dev/tests/cypress/helpers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.dev/tests/cypress/helpers.js b/.dev/tests/cypress/helpers.js index f04fa9fc137..3d476d62d92 100644 --- a/.dev/tests/cypress/helpers.js +++ b/.dev/tests/cypress/helpers.js @@ -67,7 +67,7 @@ export function goTo( path = '/wp-admin' ) { */ export function getWindowObject() { const editorUrlStrings = [ 'post-new.php', 'action=edit' ]; - return cy.window().then( ( win ) => { + return cy.window().its( 'wp.data' ).should( 'exist' ).then( ( win ) => { const isEditorPage = editorUrlStrings.filter( ( str ) => win.location.href.includes( str ) ); if ( isEditorPage.length === 0 ) { From 68668aeb18e1851aa9b37bacb721af593d83393a Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Mon, 23 Jan 2023 18:58:35 -0500 Subject: [PATCH 36/65] Lets try calling here. --- .dev/tests/cypress/helpers.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.dev/tests/cypress/helpers.js b/.dev/tests/cypress/helpers.js index 3d476d62d92..bf699fcb543 100644 --- a/.dev/tests/cypress/helpers.js +++ b/.dev/tests/cypress/helpers.js @@ -67,7 +67,7 @@ export function goTo( path = '/wp-admin' ) { */ export function getWindowObject() { const editorUrlStrings = [ 'post-new.php', 'action=edit' ]; - return cy.window().its( 'wp.data' ).should( 'exist' ).then( ( win ) => { + return cy.window().then( ( win ) => { const isEditorPage = editorUrlStrings.filter( ( str ) => win.location.href.includes( str ) ); if ( isEditorPage.length === 0 ) { @@ -86,7 +86,7 @@ export function getWindowObject() { * Disable Gutenberg Tips */ export function disableGutenbergFeatures() { - return getWindowObject().then( ( safeWin ) => { + return cy.window().its( 'wp.data' ).should( 'exist' ).then( ( safeWin ) => { // Enable "Top Toolbar" if ( ! safeWin.wp.data.select( 'core/edit-post' ).isFeatureActive( 'fixedToolbar' ) ) { safeWin.wp.data.dispatch( 'core/edit-post' ).toggleFeature( 'fixedToolbar' ); @@ -94,7 +94,6 @@ export function disableGutenbergFeatures() { if ( safeWin.wp.data.select( 'core/edit-post' ).isFeatureActive( 'welcomeGuide' ) ) { safeWin.wp.data.dispatch( 'core/edit-post' ).toggleFeature( 'welcomeGuide' ); - } else { } safeWin.wp.data.dispatch( 'core/editor' ).disablePublishSidebar(); From b8f33a44db8614db1e4d6f72d67556fd8b7c76e2 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Mon, 23 Jan 2023 19:51:06 -0500 Subject: [PATCH 37/65] Revert "Lets try calling here." This reverts commit 68668aeb18e1851aa9b37bacb721af593d83393a. --- .dev/tests/cypress/helpers.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.dev/tests/cypress/helpers.js b/.dev/tests/cypress/helpers.js index bf699fcb543..3d476d62d92 100644 --- a/.dev/tests/cypress/helpers.js +++ b/.dev/tests/cypress/helpers.js @@ -67,7 +67,7 @@ export function goTo( path = '/wp-admin' ) { */ export function getWindowObject() { const editorUrlStrings = [ 'post-new.php', 'action=edit' ]; - return cy.window().then( ( win ) => { + return cy.window().its( 'wp.data' ).should( 'exist' ).then( ( win ) => { const isEditorPage = editorUrlStrings.filter( ( str ) => win.location.href.includes( str ) ); if ( isEditorPage.length === 0 ) { @@ -86,7 +86,7 @@ export function getWindowObject() { * Disable Gutenberg Tips */ export function disableGutenbergFeatures() { - return cy.window().its( 'wp.data' ).should( 'exist' ).then( ( safeWin ) => { + return getWindowObject().then( ( safeWin ) => { // Enable "Top Toolbar" if ( ! safeWin.wp.data.select( 'core/edit-post' ).isFeatureActive( 'fixedToolbar' ) ) { safeWin.wp.data.dispatch( 'core/edit-post' ).toggleFeature( 'fixedToolbar' ); @@ -94,6 +94,7 @@ export function disableGutenbergFeatures() { if ( safeWin.wp.data.select( 'core/edit-post' ).isFeatureActive( 'welcomeGuide' ) ) { safeWin.wp.data.dispatch( 'core/edit-post' ).toggleFeature( 'welcomeGuide' ); + } else { } safeWin.wp.data.dispatch( 'core/editor' ).disablePublishSidebar(); From 29992f18e4f692299dbd602ed7e66e8b8be8c547 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Mon, 23 Jan 2023 19:52:03 -0500 Subject: [PATCH 38/65] Revert "Wait for wp.data to exist." This reverts commit abc35d80499bfc5140a3b41b018b288b6f1b65db. --- .dev/tests/cypress/helpers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.dev/tests/cypress/helpers.js b/.dev/tests/cypress/helpers.js index 3d476d62d92..f04fa9fc137 100644 --- a/.dev/tests/cypress/helpers.js +++ b/.dev/tests/cypress/helpers.js @@ -67,7 +67,7 @@ export function goTo( path = '/wp-admin' ) { */ export function getWindowObject() { const editorUrlStrings = [ 'post-new.php', 'action=edit' ]; - return cy.window().its( 'wp.data' ).should( 'exist' ).then( ( win ) => { + return cy.window().then( ( win ) => { const isEditorPage = editorUrlStrings.filter( ( str ) => win.location.href.includes( str ) ); if ( isEditorPage.length === 0 ) { From 491207b85c6ede6106f0b244a780d1cb223dd502 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Mon, 23 Jan 2023 20:05:33 -0500 Subject: [PATCH 39/65] Add check for login for goTo() --- .dev/tests/cypress/helpers.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.dev/tests/cypress/helpers.js b/.dev/tests/cypress/helpers.js index f04fa9fc137..edbbfa39b79 100644 --- a/.dev/tests/cypress/helpers.js +++ b/.dev/tests/cypress/helpers.js @@ -35,7 +35,7 @@ export function addFormChild( name ) { * Login to our test WordPress site */ export function loginToSite() { - return goTo( '/wp-admin/post-new.php?post_type=post' ) + return goTo( '/wp-admin/post-new.php?post_type=post', true ) .then( ( window ) => { if ( window.location.pathname === '/wp-login.php' ) { // WordPress has a wp_attempt_focus() function that fires 200ms after the wp-login.php page loads. @@ -53,11 +53,14 @@ export function loginToSite() { /** * Go to a specific URI. * - * @param {string} path The URI path to go to. + * @param {string} path The URI path to go to. + * @param {boolean} login If this is a login page. */ -export function goTo( path = '/wp-admin' ) { +export function goTo( path = '/wp-admin', login = false ) { return cy.visit( Cypress.env( 'testURL' ) + path ).then( () => { - return getWindowObject(); + return login ? cy.window().then( ( win ) => { + return win; + } ) : getWindowObject(); } ); } From 35a77fd0286d26c494a0d2a749c66f4c6f4778a1 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Wed, 25 Jan 2023 15:04:24 -0500 Subject: [PATCH 40/65] Use wp.data object instead of window. This allows us to wait until the data object is ready. --- .dev/tests/cypress/helpers.js | 38 +++++++------------ .../test/media-filter-control.cypress.js | 6 +-- .../test/settings-modal-control.cypress.js | 4 +- .../test/settings-modal-control.cypress.js | 6 +-- .../test/layout-selector.cypress.js | 8 ++-- .../test/settings-modal-control.cypress.js | 4 +- 6 files changed, 27 insertions(+), 39 deletions(-) diff --git a/.dev/tests/cypress/helpers.js b/.dev/tests/cypress/helpers.js index edbbfa39b79..2b21e76345c 100644 --- a/.dev/tests/cypress/helpers.js +++ b/.dev/tests/cypress/helpers.js @@ -60,7 +60,7 @@ export function goTo( path = '/wp-admin', login = false ) { return cy.visit( Cypress.env( 'testURL' ) + path ).then( () => { return login ? cy.window().then( ( win ) => { return win; - } ) : getWindowObject(); + } ) : getWPDataObject(); } ); } @@ -68,20 +68,9 @@ export function goTo( path = '/wp-admin', login = false ) { * Safely obtain the window object or error * when the window object is not available. */ -export function getWindowObject() { - const editorUrlStrings = [ 'post-new.php', 'action=edit' ]; - return cy.window().then( ( win ) => { - const isEditorPage = editorUrlStrings.filter( ( str ) => win.location.href.includes( str ) ); - - if ( isEditorPage.length === 0 ) { - throw new Error( 'Check the previous test, window property was invoked outside of Editor.' ); - } - - if ( ! win?.wp ) { - throw new Error( 'Window property was invoked within Editor but `win.wp` is not defined.' ); - } - - return win; +export function getWPDataObject() { + return cy.window().its( 'wp.data' ).then( ( data ) => { + return data; } ); } @@ -89,18 +78,17 @@ export function getWindowObject() { * Disable Gutenberg Tips */ export function disableGutenbergFeatures() { - return getWindowObject().then( ( safeWin ) => { + return getWPDataObject().then( ( data ) => { // Enable "Top Toolbar" - if ( ! safeWin.wp.data.select( 'core/edit-post' ).isFeatureActive( 'fixedToolbar' ) ) { - safeWin.wp.data.dispatch( 'core/edit-post' ).toggleFeature( 'fixedToolbar' ); + if ( ! data.select( 'core/edit-post' ).isFeatureActive( 'fixedToolbar' ) ) { + data.dispatch( 'core/edit-post' ).toggleFeature( 'fixedToolbar' ); } - if ( safeWin.wp.data.select( 'core/edit-post' ).isFeatureActive( 'welcomeGuide' ) ) { - safeWin.wp.data.dispatch( 'core/edit-post' ).toggleFeature( 'welcomeGuide' ); - } else { + if ( data.select( 'core/edit-post' ).isFeatureActive( 'welcomeGuide' ) ) { + data.dispatch( 'core/edit-post' ).toggleFeature( 'welcomeGuide' ); } - safeWin.wp.data.dispatch( 'core/editor' ).disablePublishSidebar(); + data.dispatch( 'core/editor' ).disablePublishSidebar(); } ); } @@ -229,9 +217,9 @@ export function editPage() { * Clear all blocks from the editor */ export function clearBlocks() { - getWindowObject().then( ( safeWin ) => { - safeWin.wp.data.dispatch( 'core/block-editor' ).removeBlocks( - safeWin.wp.data.select( 'core/block-editor' ).getBlocks().map( ( block ) => block.clientId ) + getWPDataObject().then( ( data ) => { + data.dispatch( 'core/block-editor' ).removeBlocks( + data.select( 'core/block-editor' ).getBlocks().map( ( block ) => block.clientId ) ); } ); } 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 7afeae1eb30..f08904c6717 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,7 +2,7 @@ * Include our constants */ import * as helpers from '../../../../.dev/tests/cypress/helpers'; -import { getWindowObject } from '../../../../.dev/tests/cypress/helpers'; +import { getWPDataObject } from '../../../../.dev/tests/cypress/helpers'; const filters = [ 'Original', @@ -93,8 +93,8 @@ describe( 'Test CoBlocks Media Filter Control component', function() { */ it( 'Test core/gallery block extends with Media Filter Control component.', function() { // Remove the fixed toolbar that sometime causes a detached element of the DOM - getWindowObject().then( ( safeWin ) => { - safeWin.wp.data.dispatch( 'core/edit-post' ).toggleFeature( 'fixedToolbar' ); + getWPDataObject().then( ( data ) => { + data.dispatch( 'core/edit-post' ).toggleFeature( 'fixedToolbar' ); } ); helpers.addBlockToPost( 'core/gallery', true ); diff --git a/src/extensions/animation/test/settings-modal-control.cypress.js b/src/extensions/animation/test/settings-modal-control.cypress.js index 056a1157c53..a919b44b05a 100644 --- a/src/extensions/animation/test/settings-modal-control.cypress.js +++ b/src/extensions/animation/test/settings-modal-control.cypress.js @@ -11,8 +11,8 @@ before( () => { describe( 'Settings Modal: Animation feature', () => { beforeEach( () => { // Reset settings. - helpers.getWindowObject().then( ( win ) => { - win.wp.data.dispatch( 'core' ).saveEntityRecord( 'root', 'site', { + helpers.getWPDataObject().then( ( data ) => { + data.dispatch( 'core' ).saveEntityRecord( 'root', 'site', { [ ANIMATION_FEATURE_ENABLED_KEY ]: true, } ); } ); diff --git a/src/extensions/colors/test/settings-modal-control.cypress.js b/src/extensions/colors/test/settings-modal-control.cypress.js index 6e61e3331d4..d8ee8799cfc 100644 --- a/src/extensions/colors/test/settings-modal-control.cypress.js +++ b/src/extensions/colors/test/settings-modal-control.cypress.js @@ -14,14 +14,14 @@ describe( 'Settings Modal: Colors feature', () => { beforeEach( () => { if ( ! helpers.isWP61AtLeast() ) { // Reset settings. - helpers.getWindowObject().then( ( win ) => { - win.wp.data.dispatch( 'core' ).saveEntityRecord( 'root', 'site', { + helpers.getWPDataObject().then( ( data ) => { + data.dispatch( 'core' ).saveEntityRecord( 'root', 'site', { [ COLORS_CUSTOM_FEATURE_ENABLED_KEY ]: true, [ COLORS_FEATURE_ENABLED_KEY ]: true, [ COLORS_GRADIENT_FEATURE_ENABLED_KEY ]: true, } ); - win.wp.data.dispatch( 'core/block-editor' ).updateSettings( { + data.dispatch( 'core/block-editor' ).updateSettings( { colors: [ { color: 'rgb(255,255,255)', diff --git a/src/extensions/layout-selector/test/layout-selector.cypress.js b/src/extensions/layout-selector/test/layout-selector.cypress.js index c280cc62529..18f941c777a 100644 --- a/src/extensions/layout-selector/test/layout-selector.cypress.js +++ b/src/extensions/layout-selector/test/layout-selector.cypress.js @@ -14,19 +14,19 @@ describe( 'Extension: Layout Selector', () => { helpers.disableGutenbergFeatures(); // Reset settings. - helpers.getWindowObject().then( ( win ) => { - win.wp.data.dispatch( 'core' ).saveEntityRecord( 'root', 'site', { + helpers.getWPDataObject().then( ( data ) => { + data.dispatch( 'core' ).saveEntityRecord( 'root', 'site', { [ LAYOUT_SELECTOR_FEATURE_ENABLED_KEY ]: true, } ); - win.wp.data.dispatch( 'coblocks/template-selector' ).updateCategories( + data.dispatch( 'coblocks/template-selector' ).updateCategories( [ { slug: 'test-one', title: 'Test One' }, { slug: 'test-two', title: 'Test Two' }, ] ); - win.wp.data.dispatch( 'coblocks/template-selector' ).updateLayouts( + data.dispatch( 'coblocks/template-selector' ).updateLayouts( [ { blocks: [ [ 'core/paragraph', { content: 'Test One paragraph.' }, [] ] ], diff --git a/src/extensions/typography/test/settings-modal-control.cypress.js b/src/extensions/typography/test/settings-modal-control.cypress.js index e2af7d5d0c5..0de337c8bea 100644 --- a/src/extensions/typography/test/settings-modal-control.cypress.js +++ b/src/extensions/typography/test/settings-modal-control.cypress.js @@ -11,8 +11,8 @@ before( () => { describe( 'Settings Modal: Typography feature', () => { beforeEach( () => { // Reset settings. - helpers.getWindowObject().then( ( win ) => { - win.wp.data.dispatch( 'core' ).saveEntityRecord( 'root', 'site', { + helpers.getWPDataObject().then( ( data ) => { + data.dispatch( 'core' ).saveEntityRecord( 'root', 'site', { [ TYPOGRAPHY_FEATURE_ENABLED_KEY ]: true, } ); } ); From bccff1d16f846f37077bce9f5f4177699a813ea9 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Wed, 25 Jan 2023 15:23:49 -0500 Subject: [PATCH 41/65] Run test using yarn. --- .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 c461fe2fb87..0cc69477b1b 100644 --- a/.github/workflows/test-e2e-cypress.yml +++ b/.github/workflows/test-e2e-cypress.yml @@ -84,7 +84,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 $CYPRESS_SPEC + yarn test:e2e --spec $CYPRESS_SPEC - name: Upload failure video if: ${{ failure() }} From 858b4b9c6b74bf41f63764c3a715395797f3b24e Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Wed, 25 Jan 2023 15:35:43 -0500 Subject: [PATCH 42/65] Try with one retry. --- cypress.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress.config.js b/cypress.config.js index 187cfefbea0..82fa1289184 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -20,7 +20,7 @@ module.exports = defineConfig( { projectId: 'sovnn2', retries: { openMode: 0, - runMode: 0, + runMode: 1, }, screenshotsFolder: '.dev/tests/cypress/screenshots', videosFolder: '.dev/tests/cypress/videos', From 283b3eb88a59888d5eb18c7096d7df6f0c063f45 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Wed, 25 Jan 2023 18:59:09 -0500 Subject: [PATCH 43/65] Add accordion spec. --- .github/workflows/test-e2e-cypress.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-e2e-cypress.yml b/.github/workflows/test-e2e-cypress.yml index 0cc69477b1b..3532cccb7d0 100644 --- a/.github/workflows/test-e2e-cypress.yml +++ b/.github/workflows/test-e2e-cypress.yml @@ -32,6 +32,7 @@ jobs: fail-fast: false matrix: spec: + - accordion.cypress.js - alert.cypress.js steps: From a04f1ad06a58b3466e319411c80c7024ba263dbc Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Wed, 25 Jan 2023 19:10:51 -0500 Subject: [PATCH 44/65] Import data on tests-cli. --- .github/workflows/test-accessibility.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-accessibility.yml b/.github/workflows/test-accessibility.yml index d4d68cec51d..3172cab54c7 100644 --- a/.github/workflows/test-accessibility.yml +++ b/.github/workflows/test-accessibility.yml @@ -42,7 +42,7 @@ jobs: - name: Prepare tests run: | - wp-env run cli "wp db import wp-content/plugins/coblocks/.dev/tests/a11y/coblocks_pa11y.sql" + wp-env run tests-cli "wp db import wp-content/plugins/coblocks/.dev/tests/a11y/coblocks_pa11y.sql" - name: Run tests run: | From 2d5ad31c781b53989c7e178a0e9fc76ab8575cd3 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Wed, 25 Jan 2023 19:18:26 -0500 Subject: [PATCH 45/65] Run from bin. --- .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 3532cccb7d0..cea64186afc 100644 --- a/.github/workflows/test-e2e-cypress.yml +++ b/.github/workflows/test-e2e-cypress.yml @@ -85,7 +85,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 - yarn test:e2e --spec $CYPRESS_SPEC + ./node_modules/.bin/cypress run --browser ${{ inputs.browser }} --spec $CYPRESS_SPEC - name: Upload failure video if: ${{ failure() }} From 25dd479c3000678331e6e9a6f66593306ef60095 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Wed, 25 Jan 2023 19:18:57 -0500 Subject: [PATCH 46/65] Reverse order. --- .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 cea64186afc..848da183db7 100644 --- a/.github/workflows/test-e2e-cypress.yml +++ b/.github/workflows/test-e2e-cypress.yml @@ -32,8 +32,8 @@ jobs: fail-fast: false matrix: spec: - - accordion.cypress.js - alert.cypress.js + - accordion.cypress.js steps: - name: Checkout From a9ff56273287a389660ad7deb8f9d652a55db6ee Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Wed, 25 Jan 2023 19:50:07 -0500 Subject: [PATCH 47/65] =?UTF-8?q?Let=E2=80=99s=20try=20this.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dev/tests/cypress/helpers.js | 21 ++++++++------------- .dev/tests/cypress/support/commands.js | 13 +++++-------- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/.dev/tests/cypress/helpers.js b/.dev/tests/cypress/helpers.js index 2b21e76345c..61948f39146 100644 --- a/.dev/tests/cypress/helpers.js +++ b/.dev/tests/cypress/helpers.js @@ -35,19 +35,14 @@ export function addFormChild( name ) { * Login to our test WordPress site */ export function loginToSite() { - return goTo( '/wp-admin/post-new.php?post_type=post', true ) - .then( ( window ) => { - if ( window.location.pathname === '/wp-login.php' ) { - // WordPress has a wp_attempt_focus() function that fires 200ms after the wp-login.php page loads. - // We need to wait a short time before trying to login. - cy.wait( 250 ); - - cy.get( '#user_login' ).type( Cypress.env( 'wpUsername' ) ); - cy.get( '#user_pass' ).type( Cypress.env( 'wpPassword' ) ); - cy.get( '#wp-submit' ).click(); - } - } ) - .get( '.wp-block-post-title' ).should( 'exist' ); + return goTo( '/wp-login.php', true ) + .then( () => { + cy.wait( 250 ); + + cy.get( '#user_login' ).type( Cypress.env( 'wpUsername' ) ); + cy.get( '#user_pass' ).type( Cypress.env( 'wpPassword' ) ); + cy.get( '#wp-submit' ).click(); + } ); } /** diff --git a/.dev/tests/cypress/support/commands.js b/.dev/tests/cypress/support/commands.js index 49187c233a0..1546f3641aa 100644 --- a/.dev/tests/cypress/support/commands.js +++ b/.dev/tests/cypress/support/commands.js @@ -1,14 +1,11 @@ -import { disableGutenbergFeatures, isNotWPLocalEnv, loginToSite } from '../helpers'; +import { disableGutenbergFeatures, goTo, loginToSite } from '../helpers'; before( function() { loginToSite().then( () => { - if ( isNotWPLocalEnv() ) { - // Waiting to see if the Welcome Guide will show up. Could probably be improved, but - // for the moment, it seems hard to tie the wait to something else - cy.wait( 10000 ); - } - - disableGutenbergFeatures(); + goTo( '/wp-admin/post-new.php?post_type=post' ).then( () => { + cy.wait( 2000 ); + disableGutenbergFeatures(); + } ); } ); } ); From b26b56fafb73abc17c32247dc989042c785a42cf Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Wed, 25 Jan 2023 19:57:55 -0500 Subject: [PATCH 48/65] Add another test. --- .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 848da183db7..926d404cc77 100644 --- a/.github/workflows/test-e2e-cypress.yml +++ b/.github/workflows/test-e2e-cypress.yml @@ -32,8 +32,9 @@ jobs: fail-fast: false matrix: spec: - - alert.cypress.js - accordion.cypress.js + - alert.cypress.js + - click-to-tweet.cypress.js steps: - name: Checkout From 26e7a19e7783f4d12af1bf69ddc71942d2a4db37 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Wed, 25 Jan 2023 20:13:45 -0500 Subject: [PATCH 49/65] Try with all tests. --- .github/workflows/test-e2e-cypress.yml | 46 ++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/.github/workflows/test-e2e-cypress.yml b/.github/workflows/test-e2e-cypress.yml index 926d404cc77..1768fb9e3cf 100644 --- a/.github/workflows/test-e2e-cypress.yml +++ b/.github/workflows/test-e2e-cypress.yml @@ -35,6 +35,52 @@ jobs: - accordion.cypress.js - alert.cypress.js - click-to-tweet.cypress.js + - counter.cypress.js + # - dynamic-separator.cypress.js + - event-item.cypress.js + - events.cypress.js + - faq.cypress.js + - feature.cypress.js + - features.cypress.js + - food-item.cypress.js + - food-and-drinks.cypress.js + - form.cypress.js + - gallery-carousel.cypress.js + - gallery-collage.cypress.js + - gallery-masonry.cypress.js + - gallery-offset.cypress.js + - gallery-stacked.cypress.js + - gif.cypress.js + - gist.cypress.js + - hero.cypress.js + - highlight.cypress.js + - icon.cypress.js + - logos.cypress.js + - map.cypress.js + - media-card.cypress.js + # - opentable.cypress.js + - post-carousel.cypress.js + - posts.cypress.js + - pricing-table-item.cypress.js + - pricing-table.cypress.js + - column.cypress.js + - row.cypress.js + - service.cypress.js + - services.cypress.js + - shape-divider.cypress.js + - social-profiles.cypress.js + - modal.cypress.js + - media-filter-control.cypress.js + - settings-modal-control.cypress.js + - coblocks-labs.cypress.js + - settings-modal-control.cypress.js + - layout-selector.cypress.js + - lightbox-controls-gallery.cypress.js + - lightbox-controls-image.cypress.js + - media-text-styles.cypress.js + - padding-controls.cypress.js + - settings-modal-control.cypress.js + steps: - name: Checkout From 73d9e8e1b1dab6e296a3654554579b145a6e99e3 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Wed, 25 Jan 2023 20:42:07 -0500 Subject: [PATCH 50/65] Add additional tests. --- .github/workflows/test-e2e-cypress.yml | 4 ++-- .github/workflows/test-e2e.yml | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test-e2e-cypress.yml b/.github/workflows/test-e2e-cypress.yml index 1768fb9e3cf..42b52e375f6 100644 --- a/.github/workflows/test-e2e-cypress.yml +++ b/.github/workflows/test-e2e-cypress.yml @@ -36,7 +36,7 @@ jobs: - alert.cypress.js - click-to-tweet.cypress.js - counter.cypress.js - # - dynamic-separator.cypress.js + - dynamic-separator.cypress.js - event-item.cypress.js - events.cypress.js - faq.cypress.js @@ -58,7 +58,7 @@ jobs: - logos.cypress.js - map.cypress.js - media-card.cypress.js - # - opentable.cypress.js + - opentable.cypress.js - post-carousel.cypress.js - posts.cypress.js - pricing-table-item.cypress.js diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index e8a1c9dd3db..19d6d7b9617 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -12,8 +12,16 @@ jobs: secrets: record-key: ${{ secrets.CYPRESS_RECORD_KEY }} - # firefox_e2e: - # name: Firefox - # uses: ./.github/workflows/test-e2e-cypress.yml - # with: - # browser: firefox + firefox_e2e: + name: Firefox + uses: ./.github/workflows/test-e2e-cypress.yml + with: + browser: firefox + + chrome_e2e_wp_60: + name: Chrome / WP 6.0 + uses: ./.github/workflows/test-e2e-cypress.yml + secrets: + record-key: ${{ secrets.CYPRESS_RECORD_KEY }} + with: + wpVersion: "6.0" From c3f80df07ad9f92fde8075b2c6229e8f90f4eda2 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Wed, 25 Jan 2023 20:42:38 -0500 Subject: [PATCH 51/65] Remove record key. --- .github/workflows/test-e2e.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index 19d6d7b9617..7e13d138643 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -9,8 +9,6 @@ jobs: chrome_e2e: name: Chrome uses: ./.github/workflows/test-e2e-cypress.yml - secrets: - record-key: ${{ secrets.CYPRESS_RECORD_KEY }} firefox_e2e: name: Firefox @@ -21,7 +19,5 @@ jobs: chrome_e2e_wp_60: name: Chrome / WP 6.0 uses: ./.github/workflows/test-e2e-cypress.yml - secrets: - record-key: ${{ secrets.CYPRESS_RECORD_KEY }} with: wpVersion: "6.0" From 831bef0410a64595d10a12c4d17a9e23b6cca370 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Wed, 25 Jan 2023 20:43:48 -0500 Subject: [PATCH 52/65] Go back to 0 retries. --- cypress.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress.config.js b/cypress.config.js index 82fa1289184..187cfefbea0 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -20,7 +20,7 @@ module.exports = defineConfig( { projectId: 'sovnn2', retries: { openMode: 0, - runMode: 1, + runMode: 0, }, screenshotsFolder: '.dev/tests/cypress/screenshots', videosFolder: '.dev/tests/cypress/videos', From b02da251ac435621cba3886926418f3adbe11373 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Wed, 25 Jan 2023 20:47:27 -0500 Subject: [PATCH 53/65] Make record key not required. --- .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 42b52e375f6..1587b4cf15b 100644 --- a/.github/workflows/test-e2e-cypress.yml +++ b/.github/workflows/test-e2e-cypress.yml @@ -22,7 +22,7 @@ on: secrets: record-key: description: 'Record key for Cypress Dashboard' - required: true + required: false jobs: test_cypress_e2e: From 1e28717eb9f02e9948a507ab6d710d7e2dbe6b39 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Wed, 25 Jan 2023 21:26:28 -0500 Subject: [PATCH 54/65] WP version. --- .github/workflows/test-e2e.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index 7e13d138643..94dbf6be17f 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -10,14 +10,14 @@ jobs: name: Chrome uses: ./.github/workflows/test-e2e-cypress.yml - firefox_e2e: - name: Firefox - uses: ./.github/workflows/test-e2e-cypress.yml - with: - browser: firefox - chrome_e2e_wp_60: - name: Chrome / WP 6.0 + name: "Chrome / WP 6" uses: ./.github/workflows/test-e2e-cypress.yml with: - wpVersion: "6.0" + wpVersion: "6" + + # firefox_e2e: + # name: Firefox + # uses: ./.github/workflows/test-e2e-cypress.yml + # with: + # browser: firefox From 20f0c85b9e9fdfac62aefb58a4185cfa7295c61e Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Wed, 25 Jan 2023 21:33:51 -0500 Subject: [PATCH 55/65] Change name. --- .github/workflows/test-e2e.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index 94dbf6be17f..5ee366554b5 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -11,7 +11,7 @@ jobs: uses: ./.github/workflows/test-e2e-cypress.yml chrome_e2e_wp_60: - name: "Chrome / WP 6" + name: "Chrome - WP 6" uses: ./.github/workflows/test-e2e-cypress.yml with: wpVersion: "6" From 9d0f4b8d9cf0713c4a4991b55f197b4ec02a80e4 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Wed, 25 Jan 2023 22:02:59 -0500 Subject: [PATCH 56/65] Set wp version. --- .github/workflows/test-e2e.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index 5ee366554b5..4992ab3d278 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -14,7 +14,7 @@ jobs: name: "Chrome - WP 6" uses: ./.github/workflows/test-e2e-cypress.yml with: - wpVersion: "6" + wpVersion: "WordPress/WordPress#6.0.3" # firefox_e2e: # name: Firefox From 0e76fd3141c29c4e046e366671986819010a8981 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Thu, 26 Jan 2023 13:07:29 -0500 Subject: [PATCH 57/65] Does it pass on 5.9? --- .github/workflows/test-e2e.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index 4992ab3d278..ae4f520720e 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -6,15 +6,15 @@ on: - master jobs: - chrome_e2e: - name: Chrome - uses: ./.github/workflows/test-e2e-cypress.yml + # chrome_e2e: + # name: Chrome + # uses: ./.github/workflows/test-e2e-cypress.yml - chrome_e2e_wp_60: - name: "Chrome - WP 6" + chrome_e2e_wp_59: + name: "Chrome - WP5.9" uses: ./.github/workflows/test-e2e-cypress.yml with: - wpVersion: "WordPress/WordPress#6.0.3" + wpVersion: "WordPress/WordPress#5.9" # firefox_e2e: # name: Firefox From 7bcf93ea3ed9135c2e1ec5927cc3b4df7cd56d43 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Thu, 26 Jan 2023 13:12:52 -0500 Subject: [PATCH 58/65] Input on tests-cli. --- .github/workflows/test-e2e-cypress.yml | 6 +++--- .github/workflows/test-e2e.yml | 10 ++-------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test-e2e-cypress.yml b/.github/workflows/test-e2e-cypress.yml index 1587b4cf15b..dbe19205070 100644 --- a/.github/workflows/test-e2e-cypress.yml +++ b/.github/workflows/test-e2e-cypress.yml @@ -123,9 +123,9 @@ jobs: run: | WP_CORE_VERSION=$(wp-env run cli "wp core version") echo "WP_CORE_VERSION=${WP_CORE_VERSION}" >> $GITHUB_ENV - wp-env run cli "wp post generate --count=5" - wp-env run cli "wp theme activate ${{ inputs.theme }}" - wp-env run cli "wp option update permalink_structure '/%postname%'" + wp-env run tests-cli "wp post generate --count=5" + wp-env run tests-cli "wp theme activate ${{ inputs.theme }}" + wp-env run tests-cli "wp option update permalink_structure '/%postname%'" - name: Run tests run: | diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index ae4f520720e..e542f58fa65 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -6,15 +6,9 @@ on: - master jobs: - # chrome_e2e: - # name: Chrome - # uses: ./.github/workflows/test-e2e-cypress.yml - - chrome_e2e_wp_59: - name: "Chrome - WP5.9" + chrome_e2e: + name: Chrome uses: ./.github/workflows/test-e2e-cypress.yml - with: - wpVersion: "WordPress/WordPress#5.9" # firefox_e2e: # name: Firefox From 49c088dd2adb1de466e85ff02e7b47ad2f43b799 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Thu, 26 Jan 2023 13:19:57 -0500 Subject: [PATCH 59/65] =?UTF-8?q?Let=E2=80=99s=20fast=20fail.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .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 dbe19205070..a6b139d1a4c 100644 --- a/.github/workflows/test-e2e-cypress.yml +++ b/.github/workflows/test-e2e-cypress.yml @@ -29,7 +29,7 @@ jobs: name: E2E Test runs-on: ubuntu-latest strategy: - fail-fast: false + fail-fast: true matrix: spec: - accordion.cypress.js From b3318c401dfb98cdd4331e9a2603f542c80301a9 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Thu, 26 Jan 2023 13:21:31 -0500 Subject: [PATCH 60/65] Run in non test. --- .github/workflows/test-e2e-cypress.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-e2e-cypress.yml b/.github/workflows/test-e2e-cypress.yml index a6b139d1a4c..e858b578fed 100644 --- a/.github/workflows/test-e2e-cypress.yml +++ b/.github/workflows/test-e2e-cypress.yml @@ -123,14 +123,14 @@ jobs: 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 tests-cli "wp theme activate ${{ inputs.theme }}" - wp-env run tests-cli "wp option update permalink_structure '/%postname%'" + wp-env run cli "wp post generate --count=5" + wp-env run cli "wp theme activate ${{ inputs.theme }}" + wp-env run cli "wp option update permalink_structure '/%postname%'" - 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 + echo '{"wpUsername":"admin","wpPassword":"password","testURL":"http://localhost:8888"}' | jq . > cypress.env.json ./node_modules/.bin/cypress verify ./node_modules/.bin/cypress run --browser ${{ inputs.browser }} --spec $CYPRESS_SPEC From a90d3ed3ef84ff6ed148d55802c06815bc77470c Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Thu, 26 Jan 2023 13:38:25 -0500 Subject: [PATCH 61/65] Remove fast fail. --- .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 e858b578fed..788871d0ff6 100644 --- a/.github/workflows/test-e2e-cypress.yml +++ b/.github/workflows/test-e2e-cypress.yml @@ -29,7 +29,7 @@ jobs: name: E2E Test runs-on: ubuntu-latest strategy: - fail-fast: true + fail-fast: false matrix: spec: - accordion.cypress.js From 74c5545516a28e94528e0b1469b3c622f4f0a8d6 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Thu, 26 Jan 2023 14:37:49 -0500 Subject: [PATCH 62/65] Try this. --- .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 788871d0ff6..c2927700ab4 100644 --- a/.github/workflows/test-e2e-cypress.yml +++ b/.github/workflows/test-e2e-cypress.yml @@ -123,6 +123,7 @@ jobs: 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 theme activate ${{ inputs.theme }}" wp-env run cli "wp option update permalink_structure '/%postname%'" @@ -130,7 +131,7 @@ jobs: - name: Run tests run: | CYPRESS_SPEC=$(find ./src/* -name ${{ matrix.spec }} -type f) - echo '{"wpUsername":"admin","wpPassword":"password","testURL":"http://localhost:8888"}' | jq . > cypress.env.json + 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 $CYPRESS_SPEC From 5b401e50317b36eca1c6dd4ec00d634ccb1cf879 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Thu, 26 Jan 2023 19:30:32 -0500 Subject: [PATCH 63/65] Add firefox. --- .github/workflows/test-e2e.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index e542f58fa65..47038499ab7 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -10,8 +10,8 @@ jobs: name: Chrome uses: ./.github/workflows/test-e2e-cypress.yml - # firefox_e2e: - # name: Firefox - # uses: ./.github/workflows/test-e2e-cypress.yml - # with: - # browser: firefox + firefox_e2e: + name: Firefox + uses: ./.github/workflows/test-e2e-cypress.yml + with: + browser: firefox From 51eca58e3a78723fe2f1f35bdd4f01bc8d98a527 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Fri, 27 Jan 2023 11:48:12 -0500 Subject: [PATCH 64/65] Remove firefox. We need to ship this feature, and will revisit the issue with Firefox. --- .github/workflows/test-e2e.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index 47038499ab7..4865d9d527b 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -9,9 +9,3 @@ jobs: chrome_e2e: name: Chrome uses: ./.github/workflows/test-e2e-cypress.yml - - firefox_e2e: - name: Firefox - uses: ./.github/workflows/test-e2e-cypress.yml - with: - browser: firefox From 86bd6bd021d4f6f3106b48669f738de80e9ec063 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Fri, 27 Jan 2023 16:28:53 -0500 Subject: [PATCH 65/65] Remove superfluous job. --- .github/workflows/test-e2e.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index 90301cad3f2..4865d9d527b 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -4,9 +4,6 @@ on: pull_request: branches: - master - push: - branches: - - feature/github-actions-migration-WPEX-2662 jobs: chrome_e2e: