Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test/2375: Setup Cypress for E2E testing #2446

Merged
merged 106 commits into from
Feb 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
41ca7fe
test: add @wordpress/env package
Sidsector9 Oct 11, 2021
cb3d5a9
test: add "env" script
Sidsector9 Oct 11, 2021
d3496ad
test: add cypress package
Sidsector9 Oct 11, 2021
c754673
test: add test directory for cypress
Sidsector9 Oct 11, 2021
f329809
test: add cypress scripts
Sidsector9 Oct 11, 2021
2bc7932
test: add github workflow for cypress
Sidsector9 Oct 11, 2021
95a9be8
Add standard Cypress tests
felipeelia Nov 16, 2021
f599f75
wp-env tests configuration + plugins and content for test
felipeelia Nov 19, 2021
513b40d
Elasticsearch docker-compose for tests
felipeelia Nov 19, 2021
8845b2a
Setup env for Cypress
felipeelia Nov 19, 2021
0c4252c
rename test file to use .spec.js
felipeelia Nov 19, 2021
49e5ccf
wpCli command for Cypress
felipeelia Nov 19, 2021
19a0dd9
Merge branch 'develop' into test/2375
felipeelia Nov 19, 2021
a63b449
Merge branch 'develop' of github.com:10up/ElasticPress into test/2375
felipeelia Nov 19, 2021
d8d5ed7
fix cypress gh action
felipeelia Nov 19, 2021
96fda55
Beginning of before()
felipeelia Nov 19, 2021
49a25c9
Setup eslint for Cypress tests
felipeelia Nov 27, 2021
3e1f18d
Lint + properly escaped wpCli + updateFeatures
felipeelia Nov 27, 2021
fb36088
General tests stub
felipeelia Nov 27, 2021
d8df2be
lint code
felipeelia Dec 22, 2021
d51ae50
publishPost command and highlight
felipeelia Dec 22, 2021
ce400b2
Merge branch 'develop' into test/2375
felipeelia Dec 22, 2021
5b3ee03
Fix features update
felipeelia Dec 23, 2021
945ff30
Set npm version and add cache
felipeelia Dec 23, 2021
41946d6
Tweak get_docker_cid to use only one ID
felipeelia Dec 23, 2021
0a9fba2
adjust linting
felipeelia Dec 23, 2021
c6c2f92
Adjust description
felipeelia Dec 23, 2021
c2f1cdd
Autosuggest tests
felipeelia Dec 23, 2021
b7b8c04
Basic documentation
felipeelia Dec 23, 2021
21e5919
Add some time to process new posts + log debug bar EP content on fail…
felipeelia Jan 5, 2022
6e969ca
Cypress tests for the Documents feature
felipeelia Jan 5, 2022
8758d60
Cleaner Elasticsearch docker structure
felipeelia Jan 5, 2022
f32f128
Change ES_VERSION to match docker-compose
felipeelia Jan 6, 2022
2f317a9
Finish the migration of the documents tests
felipeelia Jan 6, 2022
a1065d1
Tests for the Protected Content Feature
felipeelia Jan 6, 2022
203e1b5
Tests for the Related Posts feature
felipeelia Jan 10, 2022
33abc90
Merge branch 'develop' into test/2375
felipeelia Jan 10, 2022
f1e718d
Rename to follow the other features pattern
felipeelia Jan 10, 2022
a72b2cb
Mapping dirs doesn't seem to work
felipeelia Jan 10, 2022
4304de8
Tests for the Post Search Feature
felipeelia Jan 10, 2022
b1ff0d8
new npm commands + uploaded artifacts in GH action
felipeelia Jan 11, 2022
8e634d8
Log debug info
felipeelia Jan 11, 2022
f74be20
Wait some time so posts can be processed
felipeelia Jan 11, 2022
88f582c
Start of WooCommerce tests
felipeelia Jan 12, 2022
cfa00a7
Fix cy.activatePlugin
felipeelia Jan 12, 2022
4077e27
Tests for the WooCommerce Feature
felipeelia Jan 12, 2022
4d748fa
Tests for the Users Indexable
felipeelia Jan 12, 2022
e620adc
Search Weighting and start of Dashboard Sync
felipeelia Jan 18, 2022
bed06b6
Merge branch 'develop' into test/2375
felipeelia Jan 18, 2022
572ecd4
Only call ChartJs if the source element exists
felipeelia Jan 18, 2022
d8822fa
built asset
felipeelia Jan 18, 2022
7b89620
Dashboard Sync Tests
felipeelia Jan 18, 2022
9ee06e8
Create a SQL so a env reset can happen faster
felipeelia Jan 20, 2022
50a6090
Fix pdf search after a wp-cli index
felipeelia Jan 20, 2022
836c008
Update cypress
felipeelia Jan 20, 2022
ccbc284
Add bigger timeouts for syncs
felipeelia Jan 21, 2022
4ab5dfb
Allow wp-cli to fail for dashboard sync failing scenario
felipeelia Jan 21, 2022
a51ae6d
Try to deactivate the plugin via dashboard
felipeelia Jan 21, 2022
815edab
Try managing plugin act/deact via dashboard (pt. 2)
felipeelia Jan 21, 2022
09fcaad
Remove unnecessary parameters + docs
felipeelia Jan 21, 2022
eae58f6
Optimize the process by calling npm ci instead of npm install
felipeelia Jan 26, 2022
7adfec4
Merge branch 'develop' into test/2375
felipeelia Jan 26, 2022
d380b0c
Merge branch 'develop' into test/2375
felipeelia Feb 10, 2022
8e57edd
Start of the general tests
felipeelia Feb 10, 2022
f1ec970
Changes needed for WP 5.9
felipeelia Feb 15, 2022
65d2a8f
Use the correct theme + fixes
felipeelia Feb 15, 2022
7fbd66a
Bump index timeout + add retry
felipeelia Feb 15, 2022
bb9bf16
Activate the plugin only in the current site
felipeelia Feb 15, 2022
63f677d
Change bool param to a more descriptive solution
felipeelia Feb 15, 2022
d856280
General tests
felipeelia Feb 15, 2022
a17fc69
Change plugin activation/deactivation method
felipeelia Feb 15, 2022
4a7e349
WP-CLI Tests (index command)
felipeelia Feb 16, 2022
ebfec97
Group multisite tests
felipeelia Feb 16, 2022
6e422a9
Other WP-CLI tests
felipeelia Feb 16, 2022
218fc2c
Improve wpCli usage
felipeelia Feb 16, 2022
0008044
Add option to set EP_HOST, ES_SHIELD, and EP_INDEX_PREFIX
felipeelia Feb 16, 2022
0ef61d6
Use npm --silent and use temp file for wpCliEval
felipeelia Feb 16, 2022
b37cca0
1st attempt to run cypress tests using EP.io
felipeelia Feb 16, 2022
3f2e446
Delete all indexes for EP.io and adjust wpCliEval
felipeelia Feb 16, 2022
43c8b68
EP.io does not need the ES container
felipeelia Feb 16, 2022
edbe4b4
Attempt to capture the error during wpCliEval
felipeelia Feb 17, 2022
3748931
Account for different folder names
felipeelia Feb 17, 2022
95bac72
WP-CLI Command is always "elasticpress" lowercase
felipeelia Feb 17, 2022
aa11d65
Fix plugin name in wp-cli activation
felipeelia Feb 17, 2022
d039cbb
Clear previous stuck syncs
felipeelia Feb 17, 2022
b8ed691
Try avoid setting features for every group tests
felipeelia Feb 17, 2022
c5dc97b
Correctly pass the setup parameters
felipeelia Feb 17, 2022
d634634
Remove unnecessary escape
felipeelia Feb 18, 2022
d680dd4
General optimizations and proper waiting
felipeelia Feb 18, 2022
c42c23d
Only login once, in the beginning of the tests
felipeelia Feb 18, 2022
979793b
Update Cypress
felipeelia Feb 18, 2022
a6ac25c
Update node version
felipeelia Feb 18, 2022
0b368fe
Remove WP Acceptance
felipeelia Feb 18, 2022
fd19505
Run Cypress tests with the same frequency of phpunit
felipeelia Feb 18, 2022
0fc6154
slug will be different only for wp-cli
felipeelia Feb 18, 2022
77c3620
Additional wait for the ajax request
felipeelia Feb 20, 2022
7fceb48
Properly wait for the necessary ajax requests
felipeelia Feb 20, 2022
3a6ef08
remove "only" used locally
felipeelia Feb 20, 2022
c69df5f
Remove WP Acceptance dependency from composer
felipeelia Feb 21, 2022
4e29240
Fix typo
felipeelia Feb 23, 2022
cc2ab88
Deal with ep_bulk_setting more efficiently + wait on sync complete
felipeelia Feb 23, 2022
5495670
Reload the page before checking notice
felipeelia Feb 23, 2022
2d51984
Update features more efficiently
felipeelia Feb 23, 2022
b85ab17
Redirect to the right page
felipeelia Feb 23, 2022
465830f
consider ep_bulk_setting default value as 350
felipeelia Feb 23, 2022
37227cd
Another attempt to clean stuck syncs
felipeelia Feb 23, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 122 additions & 0 deletions .github/workflows/cypress-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: E2E Test

env:
NODE_VERSION: "14"
NODE_CACHE: "${{ github.workspace }}/node_modules_cache"

on:
schedule:
- cron: '0 0 * * *'
push:
branches:
- develop
- master
pull_request:
branches:
- develop

jobs:
cypress_local:
name: Cypress - Local
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Prepare npm cache
uses: actions/cache@v2
with:
path: ${{ env.NODE_CACHE }}
key: npm-${{ env.NODE_VERSION }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
npm-${{ env.NODE_VERSION }}-

- name: "Install node v${{ env.NODE_VERSION }}"
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}

- name: Install dependencies
run: npm ci --include=dev

- name: Set up WP environment with Elasticsearch
run: npm run env:start

- name: Build asset
run: npm run build

- name: Set up database
run: npm run cypress:setup

- name: Test
run: npm run cypress:run

- name: Make artifacts available
uses: actions/upload-artifact@v2
if: failure()
with:
name: cypress-artifact
retention-days: 2
path: |
${{ github.workspace }}/tests/cypress/screenshots/
${{ github.workspace }}/tests/cypress/videos/
${{ github.workspace }}/tests/cypress/logs/

- name: Stop Elasticsearch
if: always()
run: cd bin/es-docker/ && docker-compose down

cypress_epio:
name: Cypress - EP.io
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Prepare npm cache
uses: actions/cache@v2
with:
path: ${{ env.NODE_CACHE }}
key: npm-${{ env.NODE_VERSION }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
npm-${{ env.NODE_VERSION }}-

- name: "Install node v${{ env.NODE_VERSION }}"
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}

- name: Install dependencies
run: npm ci --include=dev

- name: Set up WP environment
run: npm run env start

- name: Build asset
run: npm run build

- name: Set up database
run: npm run cypress:setup -- --ep-host=${{ secrets.EPIO_HOST }} --es-shield='${{ secrets.EPIO_SHIELD }}' --ep-index-prefix=${{ secrets.EPIO_INDEX_PREFIX }}

- name: Test
run: npm run cypress:run

- name: Make artifacts available
uses: actions/upload-artifact@v2
if: failure()
with:
name: cypress-artifact-epio
retention-days: 2
path: |
${{ github.workspace }}/tests/cypress/screenshots/
${{ github.workspace }}/tests/cypress/videos/
${{ github.workspace }}/tests/cypress/logs/

- name: Delete Elasticsearch indices
if: always()
run: |
PLUGIN_NAME=$(basename "$PWD")
npm run env run tests-cli "wp plugin activate ${PLUGIN_NAME} --network"
npm run env run tests-cli "wp elasticpress delete-index --network-wide --yes"
82 changes: 0 additions & 82 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,88 +16,6 @@ on:
- develop

jobs:
wpa_local:
name: WP Acceptance - Local
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set standard 10up cache directories
run: |
composer config -g cache-dir "${{ env.COMPOSER_CACHE }}"

- name: Prepare composer cache
uses: actions/cache@v2
with:
path: ${{ env.COMPOSER_CACHE }}
key: composer-${{ env.COMPOSER_VERSION }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
composer-${{ env.COMPOSER_VERSION }}-

- name: Set PHP version
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
coverage: none
tools: prestissimo, composer:v1
ini-values: memory_limit=3G

- name: Install dependencies
run: composer install

- name: Test Local
run: ./run-wpacceptance.sh -l --attempts=3

- name: Upload error screenshots
uses: actions/upload-artifact@v2
if: failure()
with:
name: wpa-screenshots
path: screenshots/*.jpg

wpa_epio:
name: WP Acceptance - ElasticPress.io
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set standard 10up cache directories
run: |
composer config -g cache-dir "${{ env.COMPOSER_CACHE }}"

- name: Prepare composer cache
uses: actions/cache@v2
with:
path: ${{ env.COMPOSER_CACHE }}
key: composer-${{ env.COMPOSER_VERSION }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
composer-${{ env.COMPOSER_VERSION }}-

- name: Set PHP version
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
coverage: none
tools: prestissimo, composer:v1
ini-values: memory_limit=3G

- name: Install dependencies
run: composer install

- name: Test EP.io
run: ./run-wpacceptance.sh --ep-host=${{ secrets.EPIO_HOST }} --es-shield='${{ secrets.EPIO_SHIELD }}' --ep-index-prefix=${{ secrets.EPIO_INDEX_PREFIX }} --attempts=3

- name: Upload error screenshots
uses: actions/upload-artifact@v2
if: failure()
with:
name: wpa-screenshots
path: screenshots/*.jpg

phpunit:
name: PHP Unit
runs-on: ubuntu-latest
Expand Down
22 changes: 22 additions & 0 deletions .wp-env.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"env": {
"tests": {
"themes": [
"https://downloads.wordpress.org/theme/twentytwentyone.zip"
],
"plugins": [
".",
"https://downloads.wordpress.org/plugin/debug-bar.zip",
"https://downloads.wordpress.org/plugin/debug-bar-elasticpress.zip",
"https://downloads.wordpress.org/plugin/wordpress-importer.zip",
"https://downloads.wordpress.org/plugin/woocommerce.zip"
],
"mappings": {
"wp-content/mu-plugins/unique-index-name.php": "./tests/cypress/wordpress-files/test-mu-plugins/unique-index-name.php",
"wp-content/plugins/fake-new-activation.php": "./tests/cypress/wordpress-files/test-plugins/fake-new-activation.php",
"wp-content/plugins/unsupported-elasticsearch-version.php": "./tests/cypress/wordpress-files/test-plugins/unsupported-elasticsearch-version.php",
"wp-content/uploads/content-example.xml": "./tests/cypress/wordpress-files/test-docs/content-example.xml"
}
}
}
}
Loading