* More ignore-patterns in eslint config So we don't have to specify them on the command line when we check codestyle locally. * Test setup for local and CI using containers It uses standalone containers for the greenmail IMAP server and the standalone browser. A testrunner image is built in the CI (for `linux/amd64` only, because Github doesn't support multi-platform building on their default runners and we don't have our own.) This setup helps to run the tests (reproduceably) also locally. Previously, on my machine, they produced varying results. It also reduces the dependencies for running the browser test. Local execution only depends on `docker compose`, no other tools (previously it required `sudo`, `java`, and some more.) The previous solution should still work, if you want it. The scripts are stored in a directory called `.ci` to hide them a little and avoid confusion with the container images from the `roundcubemail-docker` repo. * Fix UI tests by waiting for element before using it This only was a flaky problem only occurring sometimes. * Force a new IMAP connection in plugin tests, too In other code the initial connection is forced. Doing this here, too, fixes occasional problems with lost imap connections. * Make waiting for zipfile's content more robust * CI: Run tests from script on Windows, too * CI: Do start local chrome if no connect URL is given * Move compose.yml to tests/ This way it's less easy mistaken as usable for running Roundcubemail in production. * Move compose.yml to .ci/
In-Browser Tests
The idea of these testing suite is to make it as simple as possible to execute the tests. So, you don't have to run any additional services, nor download and install anything manually.
The tests are using Laravel Dusk and Chrome WebDriver. PHP server is used to serve Roundcube instance on tests run.
INSTALLATION
Installation:
- Install Laravel Dusk with all dependencies.
composer require "laravel/dusk:^7.9"
- Install Chrome WebDriver for the version of Chrome/Chromium in your system. Yes, you have to have Chrome/Chromium installed.
php tests/Browser/install.php [version]
- Configure the test account and Roundcube instance.
Create a config file named config-test.inc.php in the Roundcube config dir.
That file should provide specific db_dsnw and
imap_host values for testing purposes as well as the credentials of a
valid IMAP user account used for running the tests with.
Add these config options used by the Browser tests:
// Unit tests settings
$config['tests_username'] = 'roundcube.test@example.org';
$config['tests_password'] = '<test-account-password>';
WARNING
Please note that the configured IMAP account as well as the Roundcube database
configred in db_dsnw will be wiped and filled with test data in every test
run. Under no circumstances you should use credentials of a production database
or email account!
Please, keep the file as simple as possible, i.e. containing only database and imap/smtp settings needed for the test user authentication. We would want to test default configuration. Especially only Elastic skin is supported.
NOTE: Do not use devel_mode=true (i.e. you should build Elastic styles), it makes chrome-driver to behave weird, timing out when using iframes (which we do a lot).
NOTE: See .ci directory for sample config and scripts we use for in-browser
tests on Travis.
EXECUTING THE TESTS
To run the test suite call phpunit from the tests/Browser directory:
cd <roundcube-dir>/tests/Browser
TESTS_MODE=desktop phpunit
TESTS_MODE=phone phpunit
TESTS_MODE=tablet phpunit