Skip to content

Repository files navigation

Tests

Test setup and configuration

Building package to test

Run composer run build to build both dev and prod dependencies.

Run composer run package to build the tawk.to plugin zip file that will be tested.

Setting up docker environment

Docker-compose is used for test dependency setup and is required to run these tests

Configuring docker environment

Environment variables used in the docker-compose.yml file can be found in .env file.

Environment VariableDescriptionDefault Value
WORDPRESS_DB_HOSTMySQL Service DB Hostdb:3306
WORDPRESS_DB_NAMEMySQL Service DB Namewordpress
WORDPRESS_DB_USERMySQL Service DB Userwordpress
WORDPRESS_DB_PASSWORDMySQL Service DB Passwordwordpress
WORDPRESS_DB_ROOT_PASSWORDMySQL Service DB Root Passwordsomewordpress
WEB_HOSTWordPress Web Hostwordpress
WORDPRESS_DEBUGWordPress Debug Mode1
WORDPRESS_ADMIN_USERWordPress Admin Useradmin
WORDPRESS_ADMIN_PASSWORDWordPress Admin Passwordadmin
WORDPRESS_ADMIN_EMAILWordPress Admin Emailadmin@example.com
SELENIUM_BROWSERSelenium Server Browser Typechrome
SELENIUM_PORTSelenium Server Port4444

Wordpress and WooCommerce setup

Docker environment is setup up to automatically populate test data This is done by wordpress-cli service in compose file

For more details on setup, see setup script

Running the test environment

To run docker environment for testing this repository, start docker compose file found in /tests/docker/docker-compose.yml

Example (assuming from root of repository)

docker-compose -f ./tests/docker/docker-compose.yml up -d

Environment is ready when wordpress-cli successfully exists. To monitor its status, you can tail it's logs using docker logs -f wordpress-cli

Configuring local test environment

These are the environment variables needed to run the selenium tests locally using composer script

Environment VariableDescriptionRequired
TAWK_PROPERTY_IDProperty IdYes
TAWK_WIDGET_IDWidget IdYes
TAWK_USERNAMEtawk.to account usernameYes
TAWK_PASSWORDtawk.to account passwordYes
WEB_HOSTWordpress web hostnameYes
WEB_PORTWordpress web portNo
SELENIUM_BROWSERBrowser type (chrome, firefox, edge)Yes
SELENIUM_HOSTSelenium hostYes
SELENIUM_PORTSelenium portNo

Command Sample

TAWK_PROPERTY_ID=<TAWK_PROPERTY_ID> \
TAWK_WIDGET_ID=<TAWK_WIDGET_ID> \
TAWK_USERNAME=<TAWK_USERNAME> \
TAWK_PASSWORD=<TAWK_PASSWORD> \
WEB_HOST=wordpress \
SELENIUM_BROWSER=chrome \
SELENIUM_HOST=localhost \
SELENIUM_PORT=4444 \
composer run test

Storing local environments in a file for easy reference

To simplify testing, you can place your environment configuration in a .env.local file.

Example contents:

export TAWK_PROPERTY_ID='<TAWK_PROPERTY_ID>'
export TAWK_WIDGET_ID='<TAWK_WIDGET_ID>'
export TAWK_USERNAME='<TAWK_USERNAME>'
export TAWK_PASSWORD='<TAWK_PASSWORD>'
export WEB_HOST='wordpress'
export SELENIUM_BROWSER='chrome'
export SELENIUM_HOST='localhost'
export SELENIUM_PORT='4444'

And simply run

source .env.local && composer run test

Debugging the test environment/Developing

Ensure you have this line in your /etc/hosts

127.0.0.1 <WEB_HOST>

Then go to http://<WEB_HOST>/wp-admin and login with WORDPRESS_ADMIN_USER & WORDPRESS_ADMIN_PASSWORD

Running Tests on Github Actions

This repository is set up to use Github Actions to perform automated testing.

To use actions in this repository, the following secrets need to be configured:

SecretDescription
TAWK_PROPERTY_IDProperty Id
TAWK_WIDGET_IDWidget Id
TAWK_USERNAMEtawk.to account username
TAWK_PASSWORDtawk.to account password

About

No description, website, or topics provided.

Resources

Stars

30 stars

Watchers

8 watching

Forks

Releases

Packages

Used by

Contributors

Languages