Skip to content

Commit

Permalink
Merge pull request #30684 from woocommerce/add/api-test-script-schedu…
Browse files Browse the repository at this point in the history
…led-run

Run API tests with regular run and add script
  • Loading branch information
rrennick committed Sep 23, 2021
2 parents 783b962 + e09b43f commit c15bf28
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/smoke-test-daily.yml
Expand Up @@ -41,6 +41,10 @@ jobs:
E2E_SLACK_CHANNEL: ${{ secrets.SMOKE_TEST_SLACK_CHANNEL }}
UPDATE_WC: 1
DEFAULT_TIMEOUT_OVERRIDE: 120000
BASE_URL: ${{ secrets.SMOKE_TEST_URL }}
USER_KEY: ${{ secrets.SMOKE_TEST_ADMIN_USER }}
USER_SECRET: ${{ secrets.SMOKE_TEST_ADMIN_PASSWORD }}
run: |
npx wc-e2e test:e2e ./tests/e2e/specs/smoke-tests/update-woocommerce.js
npx wc-e2e test:e2e
npx wc-api-tests test api
4 changes: 4 additions & 0 deletions .github/workflows/smoke-test-release.yml
Expand Up @@ -42,6 +42,10 @@ jobs:
TEST_RELEASE: 1
UPDATE_WC: 1
DEFAULT_TIMEOUT_OVERRIDE: 120000
BASE_URL: ${{ secrets.RELEASE_TEST_URL }}
USER_KEY: ${{ secrets.RELEASE_TEST_ADMIN_USER }}
USER_SECRET: ${{ secrets.RELEASE_TEST_ADMIN_PASSWORD }}
run: |
npx wc-e2e test:e2e ./tests/e2e/specs/smoke-tests/update-woocommerce.js
npx wc-e2e test:e2e
npx wc-api-tests test api
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -28,7 +28,8 @@
"docker:down": "npx wc-e2e docker:down",
"docker:ssh": "npx wc-e2e docker:ssh",
"docker:up": "npx wc-e2e docker:up",
"test:api": "cd ./tests/e2e/api-core-tests && jest --group=api",
"test:api": "npx wc-api-tests test api",
"make:collection": "npx wc-api-tests make:collection",
"test:e2e": "npx wc-e2e test:e2e",
"test:e2e-debug": "npx wc-e2e test:e2e-debug",
"test:e2e-dev": "npx wc-e2e test:e2e-dev",
Expand Down
49 changes: 49 additions & 0 deletions tests/e2e/api-core-tests/bin/wc-api-tests.sh
@@ -0,0 +1,49 @@
#!/usr/bin/env bash
#
# Run package scripts
#

# Script help
usage() {
echo 'usage: npx wc-api-tests <script>'
echo 'scripts:'
echo ' test <group> - run API tests with the specified group'
echo ' make:collection - build a Postman API Collection'
}

# Parameter check
if [ $# -lt 1 ]; then
usage
exit 1
fi

# Store original path
OLDPATH=$(pwd)

# Return value for CI test runs
TESTRESULT=0

# Use the script symlink to find and change directory to the root of the package
SCRIPTPATH=$(dirname "$0")
REALPATH=$(readlink "$0")
cd "$SCRIPTPATH/$(dirname "$REALPATH")/.."

# Run scripts
case $1 in
'test')
jest --group=$2
TESTRESULT=$?
;;
'make:collection')
node utils/api-collection/build-collection.js $2
TESTRESULT=$?
;;
*)
usage
;;
esac

# Restore working path
cd "$OLDPATH"

exit $TESTRESULT
5 changes: 4 additions & 1 deletion tests/e2e/api-core-tests/package.json
Expand Up @@ -20,9 +20,12 @@
"homepage": "https://github.com/woocommerce/woocommerce#readme",
"dependencies": {
"dotenv": "^10.0.0",
"jest": "^27.0.6",
"jest": "^25.1.0",
"jest-runner-groups": "^2.1.0",
"postman-collection": "^4.1.0",
"supertest": "^6.1.4"
},
"bin": {
"wc-api-tests": "bin/wc-api-tests.sh"
}
}

0 comments on commit c15bf28

Please sign in to comment.