Merge remote-tracking branch 'origin/tests' into develop

This commit is contained in:
Leo Germani 2018-03-05 17:47:36 -03:00
commit 3b6c73031a
9 changed files with 106 additions and 47 deletions

1
.gitignore vendored
View File

@ -19,4 +19,3 @@ last-package-build.md5
src/admin/scss/.sass-cache
src/assets/css/tainacan-admin.css
src/assets/css/tainacan-admin.css.map
cypress

View File

@ -1,4 +1,5 @@
# the destination folder, inside the plugins folder of some WordPress installation
destination=~/devel/wordpress/wp-content/plugins/tainacan
wp_base_dir=~/devel/wordpress
wp_url=http://localhost/wp
wp_url=http://localhost/wordpress
wp_plugin_dir=~/devel/wordpress/wp-content/plugins/tainacan

View File

@ -52,10 +52,10 @@ fi
### END npm build ###
echo "Updating files in $destination"
rm -rf $destination
mkdir $destination
cp -R src/* $destination/
rm -rf $destination/scss
echo "Updating files in $wp_plugin_dir"
rm -rf $wp_plugin_dir
mkdir $wp_plugin_dir
cp -R src/* $wp_plugin_dir/
rm -rf $wp_plugin_dir/scss
echo "Build complete!"

View File

@ -1 +1,3 @@
{}
{
"projectId": "tubzok"
}

View File

@ -0,0 +1,7 @@
describe('Tainacan Test', function () {
it('.should() - assert that <title> is correct', function () {
cy.visit('http://localhost/wordpress/wp-admin')
cy.get('log').type('admin').should('have.value', 'amdin')
cy.get('pwd').type('root').should('have.value', 'root')
})
})

17
cypress/plugins/index.js Normal file
View File

@ -0,0 +1,17 @@
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************
// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
}

17
cypress/support/index.js Normal file
View File

@ -0,0 +1,17 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************
// Alternatively you can use CommonJS syntax:
// require('./commands')

49
run-cypress.sh Executable file
View File

@ -0,0 +1,49 @@
#!/bin/bash
if [ $# - lt 2 ]; then
echo "usage: $0 [skip-head]"
exit 1
fi
SKIP_HEAD=${1-1}
source build-config.cfg
./build.sh
plugin_name=`basename $wp_plugin_dir`
test_db_prefix='wptests_'
################## set up cypress environment
# replace table prefix in wp_config
echo "Changing DB prefix in wp_config..."
sed -i s/"require_once(ABSPATH . 'wp-settings.php');"/"\$table_prefix = '$test_db_prefix';\nrequire_once(ABSPATH . 'wp-settings.php');"/ $wp_base_dir/wp-config.php
# install WordPress
cd $wp_base_dir
echo "Installing WordPress..."
wp core install --url=$wp_url --title=Test --admin_user=admin --admin_password=admin --admin_email=admin@admin.com
# Activate Tainacan
wp plugin activate $plugin_name
# back to tainacan dev directory
cd -
# cypress beginning
if [ ${SKIP_HEAD} = "0" ]
then
./node_modules/.bin/cypress run
else
./node_modules/.bin/cypress run --headed
fi
################## teardown cypress environment
# remove WordPress
echo "Removing WordPress..."
cd $wp_base_dir
wp db query "DROP TABLES $(wp db tables | paste -s -d, -);"
# recover table prefix in wp_config
echo "Restoring DB prefix in wp_config..."
sed -i s/"\$table_prefix = '$test_db_prefix';"/""/ $wp_base_dir/wp-config.php

View File

@ -1,41 +1,8 @@
#!/bin/bash
source build-config.cfg
#./build.sh
plugin_name=`basename $destination`
test_db_prefix='wp_tainacan_test_'
################## set up cypress environment
# replace table prefix in wp_config
echo "Changing DB prefix in wp_config..."
sed -i s/"require_once(ABSPATH . 'wp-settings.php');"/"\$table_prefix = '$test_db_prefix';\nrequire_once(ABSPATH . 'wp-settings.php');"/ $wp_base_dir/wp-config.php
# install WordPress
cd $wp_base_dir
echo "Installing WordPress..."
wp core install --url=$wp_url --title=Test --admin_user=admin --admin_password=admin --admin_email=admin@admin.com
# Activate Tainacan
wp plugin activate $plugin_name
# back to tainacan dev directory
cd -
#npx cypress run --env host=$wp_url,baseUrl=$wp_url
################## teardown cypress environment
# remove WordPress
echo "Removing WordPress..."
cd $wp_base_dir
wp db query "DROP TABLES $(wp db tables | paste -s -d, -);"
# recover table prefix in wp_config
echo "Restoring DB prefix in wp_config..."
sed -i s/"\$table_prefix = '$test_db_prefix';"/""/ $wp_base_dir/wp-config.php
echo "Running unit tests in PHPUnit..."
phpunit
echo "Running integration tests headless in Crypess..."
# the value 0 leaves the cypress headless
./run-cypress.sh 0