Skip to content

Commit 3388d76

Browse files
Merge pull request #555 from contactashish13/issue-198-pro
integrate cypress
2 parents 56db28a + 8bf74fa commit 3388d76

19 files changed

+780
-1
lines changed

.distignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,8 @@ composer.lock
2020
package-lock.json
2121
key.enc
2222
vendor/phpoffice/phpexcel/Examples
23-
vendor/phpoffice/phpexcel/unitTests
23+
vendor/phpoffice/phpexcel/unitTests
24+
cypress
25+
docker-compose.travis.yml
26+
cypress.env.json.template
27+
cypress.json

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ vendor
77
composer.lock
88
bin/
99
package-lock.json
10+
cypress/integration/examples
11+
cypress/integration/localhost*
12+
cypress/plugins
13+
cypress.env.json

.travis.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
language: php
22
sudo: false
33
dist: trusty
4+
services:
5+
- docker
46
matrix:
57
fast_finish: true
68
include:
@@ -14,6 +16,14 @@ matrix:
1416
before_script: chmod +x bin/wraith.sh
1517
env: TEST_SUITE=Wraith_Visual_Regression_Testing WRAITH_FAIL=5
1618
script: "./bin/wraith.sh"
19+
- name: Cypress
20+
if: branch = development
21+
language: node_js
22+
node_js:
23+
- 10.8
24+
script:
25+
- docker-compose -f docker-compose.travis.yml up -d
26+
- chmod +x ./bin/run-e2e-tests.sh ./bin/wp-init.sh && ./bin/wp-init.sh && ./bin/run-e2e-tests.sh
1727
allow_failures:
1828
- env: TEST_SUITE=Wraith_Visual_Regression_Testing WRAITH_FAIL=5
1929
branches:

Gruntfile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module.exports = function (grunt) {
77
var loader = require( 'load-project-config' ),
88
config = require( 'grunt-plugin-fleet' );
99
config = config();
10+
config.files.js.push( '!cypress/**/*.js' );
1011
// jshint ignore: start
1112
config.taskMap['faq_builder'] = 'grunt-helpscout-faq';
1213
// jshint ignore: end

bin/kill-and-create-all.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# to be executed from the plugin main directory (visualizer-pro)
2+
docker kill $(docker ps -q)
3+
docker system prune -a
4+
5+
windows=`echo $OSTYPE | grep -i -e "win" -e "msys" -e "cygw" | wc -l`
6+
if [[ $windows -gt 0 ]]; then
7+
docker-machine start default
8+
fi
9+
10+
docker-compose -f docker-compose.travis.yml up -d
11+
./bin/wp-init.sh
12+
./bin/run-e2e-tests.sh

bin/mysql/init-db.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
grant all privileges on *.* to 'wordpress'@'%' identified by 'wordpress';

bin/run-e2e-tests.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
3+
if [[ "$TRAVIS" == "true" ]]; then
4+
npm install --only=dev --prefix ./cypress/
5+
composer install --no-dev
6+
fi
7+
8+
wp_host='localhost'
9+
windows=`echo $OSTYPE | grep -i -e "win" -e "msys" -e "cygw" | wc -l`
10+
args='-it';
11+
if [[ $windows -gt 0 ]]; then
12+
wp_host=`docker-machine ip`
13+
args=''
14+
fi
15+
16+
# exit on error
17+
set -e
18+
19+
export CYPRESS_HOST=$wp_host
20+
21+
# test free - lifecycle
22+
export CYPRESS_SPEC_TO_RUN="free-lifecycle.js"
23+
npm run cypress:run
24+
25+
# test free - sources
26+
export CYPRESS_SPEC_TO_RUN="free-sources.js"
27+
npm run cypress:run

bin/wp-init.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env bash
2+
3+
# if on windows, find out the IP using `docker-machine ip` and provide the IP as the host.
4+
wp_host='localhost'
5+
windows=`echo $OSTYPE | grep -i -e "win" -e "msys" -e "cygw" | wc -l`
6+
args='-it';
7+
if [[ $windows -gt 0 ]]; then
8+
wp_host=`docker-machine ip`
9+
args=''
10+
fi
11+
12+
# sleep for sometime till WP initializes successfully
13+
sleep_time=15
14+
if [[ $windows -gt 0 ]]; then
15+
sleep_time=30
16+
fi
17+
echo "Sleeping for $sleep_time..."
18+
sleep $sleep_time
19+
20+
# install WP
21+
docker exec $args visualizer_wordpress wp --quiet core install --url="http://$wp_host:8888/" --admin_user="wordpress" --admin_password="wordpress" --admin_email="[email protected]" --title="test" --skip-email
22+
23+
# install required external plugins
24+
docker exec $args visualizer_wordpress chown -R www-data:www-data /var/www/html/
25+
docker exec $args visualizer_wordpress wp plugin install classic-editor --activate
26+
27+
# so that debug.log is created
28+
docker exec $args visualizer_wordpress chmod 0777 -R /var/www/html/wp-content
29+
30+
# install visualizer free
31+
docker exec $args visualizer_wordpress git clone https://github.com/Codeinwp/visualizer /var/www/html/wp-content/plugins/visualizer
32+
33+
# activate
34+
docker exec $args visualizer_wordpress wp --quiet plugin activate visualizer
35+
36+
# set this constant so that the license is not checked
37+
docker exec $args visualizer_wordpress wp --quiet config set TI_UNIT_TESTING true --raw
38+
39+
# set this constant so that the specific hooks are loaded
40+
docker exec $args visualizer_wordpress wp --quiet config set TI_CYPRESS_TESTING true --raw
41+
42+
# debugging
43+
docker exec $args visualizer_wordpress wp --quiet config set WP_DEBUG true --raw
44+
docker exec $args visualizer_wordpress wp --quiet config set WP_DEBUG_LOG true --raw
45+
docker exec $args visualizer_wordpress wp --quiet config set WP_DEBUG_DISPLAY false --raw
46+

cypress.env.json.template

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"host": "http://localhost:90/",
3+
"wp-admin": "wp-admin/",
4+
"login": "wordpress",
5+
"pass": "wordpress"
6+
}

cypress.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"env": {
3+
"urls" : {
4+
"library": "/admin.php?page=visualizer",
5+
"samples": "https://s3.amazonaws.com/downloads.themeisle.com/samples-visualizer/"
6+
},
7+
"chart_types": {
8+
"free": 9,
9+
"pro": 6
10+
},
11+
"features_locked": {
12+
"free": 7,
13+
"plan1": 5,
14+
"plan2": 0
15+
},
16+
"query": "SELECT post_type, count(*) from wp_posts GROUP by post_type",
17+
"wait": 10000
18+
},
19+
"videoUploadOnPasses": false,
20+
"projectId": "yhx2jj"
21+
}

0 commit comments

Comments
 (0)