2020-12-15 17:54:59 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
#
|
|
|
|
# Run package scripts
|
|
|
|
#
|
|
|
|
|
|
|
|
# Script help
|
|
|
|
usage() {
|
|
|
|
echo 'usage: npx wc-e2e <script>'
|
|
|
|
echo 'scripts:'
|
|
|
|
echo ' docker:up [initialization-script] - boot docker container'
|
|
|
|
echo ' docker:down - shut down docker container'
|
|
|
|
echo ' docker:ssh - open SSH shell into docker container'
|
|
|
|
echo ' docker:clear-all - remove all docker containers'
|
|
|
|
echo ' test:e2e [test-script] - run e2e test suite or specific test-script'
|
|
|
|
echo ' test:e2e-dev [test-script] - run e2e test(s) in non-headless mode'
|
|
|
|
echo ' test:e2e-debug [test-script] - run e2e test(s) in non-headless debug mode'
|
|
|
|
}
|
|
|
|
|
|
|
|
# Parameter check
|
|
|
|
if [ $# -lt 1 ]; then
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Store original path
|
|
|
|
OLDPATH=$(pwd)
|
|
|
|
|
2021-01-26 20:59:40 +00:00
|
|
|
# Return value for CI test runs
|
|
|
|
TESTRESULT=0
|
|
|
|
|
2020-12-15 17:54:59 +00:00
|
|
|
# Use the script symlink to find and change directory to the root of the package
|
|
|
|
SCRIPTPATH=$(dirname "$0")
|
2021-03-08 17:38:41 +00:00
|
|
|
REALPATH=$(readlink "$0")
|
|
|
|
cd "$SCRIPTPATH/$(dirname "$REALPATH")/.."
|
2020-12-15 17:54:59 +00:00
|
|
|
|
2021-11-23 12:56:24 +00:00
|
|
|
# Set a flag to distinguish between the development repo and npm package
|
|
|
|
DEV_PATH=$(echo $0 | rev | cut -f4 -d/ | rev)
|
|
|
|
if [ "$DEV_PATH" != "node_modules" ]; then
|
|
|
|
export WC_E2E_WOOCOMMERCE_DEV='true'
|
|
|
|
export WC_E2E_FOLDER='plugins/woocommerce'
|
|
|
|
else
|
|
|
|
export WC_E2E_WOOCOMMERCE_DEV=''
|
|
|
|
if [ -z $WC_E2E_FOLDER ]; then
|
|
|
|
export WC_E2E_FOLDER=''
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2020-12-15 17:54:59 +00:00
|
|
|
# Run scripts
|
|
|
|
case $1 in
|
|
|
|
'docker:up')
|
|
|
|
./bin/docker-compose.sh up $2
|
|
|
|
;;
|
|
|
|
'docker:down')
|
|
|
|
./bin/docker-compose.sh down
|
|
|
|
;;
|
|
|
|
'docker:ssh')
|
|
|
|
docker exec -it $(node utils/get-app-name.js)_wordpress-www /bin/bash
|
|
|
|
;;
|
|
|
|
'docker:clear-all')
|
|
|
|
docker rmi --force $(docker images -q)
|
|
|
|
;;
|
|
|
|
'test:e2e')
|
|
|
|
./bin/wait-for-build.sh && ./bin/e2e-test-integration.js $2
|
2021-01-26 20:59:40 +00:00
|
|
|
TESTRESULT=$?
|
2020-12-15 17:54:59 +00:00
|
|
|
;;
|
|
|
|
'test:e2e-dev')
|
|
|
|
./bin/wait-for-build.sh && ./bin/e2e-test-integration.js --dev $2
|
2021-01-26 20:59:40 +00:00
|
|
|
TESTRESULT=$?
|
2020-12-15 17:54:59 +00:00
|
|
|
;;
|
|
|
|
'test:e2e-debug')
|
|
|
|
./bin/wait-for-build.sh && ./bin/e2e-test-integration.js --dev --debug $2
|
2021-01-26 20:59:40 +00:00
|
|
|
TESTRESULT=$?
|
2020-12-15 17:54:59 +00:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
usage
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Restore working path
|
2021-03-08 17:38:41 +00:00
|
|
|
cd "$OLDPATH"
|
2021-01-26 20:59:40 +00:00
|
|
|
|
|
|
|
exit $TESTRESULT
|