Commit 48e8381f authored by Christian Keuerleber's avatar Christian Keuerleber
Browse files

TASK: run chromedriver and everything regarding acceptance tests in ddev

parent d9fc2bf3
Pipeline #7841 failed with stages
in 20 seconds
version: '3.6'
services:
chromedriver:
container_name: ddev-${DDEV_SITENAME}-chromedriver
image: robcherry/docker-chromedriver
restart: "no"
ports:
- "4444"
environment:
- CHROMEDRIVER_WHITELISTED_IPS=""
external_links:
- "ddev-router:${DDEV_SITENAME}.ddev.site"
......@@ -28,30 +28,17 @@ In `extensions/t3omy_test/Tests/acceptance.suite.yml` the config for the databas
`populate` and `reset` to true, so before running any test and between every test the command given as the config
option `populator` is run. If no `populator` is given, the `dumpFile` is imported.
### Dependencies
* composer
* chrome/chromium
* chromedriver/chromiumdriver (e.g. `brew cask install chromedriver`)
At the moment (Nov 4th 2019) GeckoDriver and FireFox testing is only possible by using the detour via selenium,
and even then it's not really reliable.
### Run codeception tests
#### Start chromedriver
We are running chromedriver in ddev, so if you use ddev everything is just working ;)
In one terminal window, start the chromedriver and leave it running. Port 4444 and url-base `/wd/hub` are taken from
old selenium standards and are default in codeception.
```
chromedriver --url-base=/wd/hub --port=4444
```
### Run codeception tests
#### Run the tests
```
vendor/bin/codecept -c extensions/t3omy_test/Configuration/codeception.yml --steps run acceptance
ddev run --service web vendor/bin/codecept -c extensions/t3omy_test/Configuration/codeception.yml --steps run acceptance
```
With `--steps`, all run steps are outputted to the command line. All errors are reported even if you don't use the
......@@ -65,13 +52,13 @@ a screenshot and the html output of the page the moment a test failed.
To run a single feature just add the path to the feature file to your command, e.g.
```
vendor/bin/codecept -c extensions/t3omy_test/Configuration/codeception.yml --steps run acceptance extensions/t3omy_test/Tests/acceptance/Features/Login.feature
ddev run --service web vendor/bin/codecept -c extensions/t3omy_test/Configuration/codeception.yml --steps run acceptance extensions/t3omy_test/Tests/acceptance/Features/Login.feature
```
You can also run single scenarios by providing line numbers, e.g.
```
vendor/bin/codecept -c extensions/t3omy_test/Configuration/codeception.yml --steps run acceptance extensions/t3omy_test/Tests/acceptance/Features/Login.feature:10
ddev run --service web vendor/bin/codecept -c extensions/t3omy_test/Configuration/codeception.yml --steps run acceptance extensions/t3omy_test/Tests/acceptance/Features/Login.feature:10
```
### Writing tests
......@@ -81,7 +68,7 @@ group your tests.
To get all the available step definitions just run the command
```
vendor/bin/codecept -c extensions/t3omy_test/Configuration/codeception.yml gherkin:steps acceptance
ddev run --service web vendor/bin/codecept -c extensions/t3omy_test/Configuration/codeception.yml gherkin:steps acceptance
```
which outputs the steps added to the project.
......@@ -89,7 +76,7 @@ which outputs the steps added to the project.
To add new steps, just write the new step in your `.feature` file and run
```
vendor/bin/codecept -c extensions/t3omy_test/Configuration/codeception.yml gherkin:snippets acceptance
ddev run --service web vendor/bin/codecept -c extensions/t3omy_test/Configuration/codeception.yml gherkin:snippets acceptance
```
This will output a function stub with the proper step definition phpdoc. Put this in a appropriate `ActorTrait`
......
<?php
namespace Helper;
// here you can define custom actions
// all public methods declared in helper class will be available in $I
use Codeception\Configuration;
use Codeception\Exception\ConfigurationException;
use Codeception\Exception\ModuleException;
use Codeception\Module\Cli;
use Codeception\Module\Filesystem;
use PunktDe\Codeception\Database\Module\Database;
use Neos\Utility\Files;
class Acceptance extends \Codeception\Module
{
/**
* @param string[] $settings
* @throws ConfigurationException
* @throws ModuleException
*/
public function _beforeSuite($settings = []): void
{
$filesystem = $this->getModule('Filesystem');
/** @var Filesystem $filesystem */
$filesystem->cleanDir(Configuration::outputDir());
$cli = $this->getModule('Cli');
/** @var Cli $cli */
$db = $this->getModule(Database::class);
/** @var Database $db */
$this->debug('dumping development database');
$dumpCommand = sprintf(
'mysqldump --host=%s --user=%s --password=%s %s > %s',
$db->_getConfig('user'),
$db->_getConfig('user'),
$db->_getConfig('user'),
$db->_getConfig('user'),
Files::concatenatePaths([Configuration::dataDir(), 'localDatabase.sql'])
);
$cli->runShellCommand($dumpCommand);
}
public function _afterSuite()
{
$cli = $this->getModule('Cli');
/** @var Cli $cli */
$db = $this->getModule(Database::class);
/** @var Database $db */
$dumpfilePath = Files::concatenatePaths([Configuration::dataDir(), 'localDatabase.sql']);
$this->debug('restoring development database');
$restoreCommand = sprintf(
'mysql --host=%s --user=%s --password=%s %s < %s',
$db->_getConfig('user'),
$db->_getConfig('user'),
$db->_getConfig('user'),
$db->_getConfig('user'),
$dumpfilePath
);
$cli->runShellCommand($restoreCommand);
$filesystem = $this->getModule('Filesystem');
/** @var Filesystem $filesystem */
$filesystem->deleteFile($dumpfilePath);
}
}
......@@ -7,6 +7,10 @@
actor: AcceptanceTester
modules:
enabled:
# order matters - \Helper\Acceptance has to be first!
- \Helper\Acceptance
- Filesystem
- Cli
- PunktDe\Codeception\Mailhog\Module\Mailhog:
base_uri: http://my.typo3.org.ddev.site:8025
- WebDriver:
......@@ -14,6 +18,8 @@ modules:
url: https://my.typo3.org.ddev.site
restart: true
window_size: 1920x2080
host: chromedriver
path: /
capabilities:
chromeOptions:
args:
......@@ -22,11 +28,12 @@ modules:
- '--disable-dev-shm-usage'
- '--no-sandbox'
- PunktDe\Codeception\Database\Module\Database:
dsn: 'mysql:host=127.0.0.1;dbname=db;port=32771;charset=UTF8'
dsn: 'mysql:host=db;dbname=db;charset=UTF8'
user: 'db'
password: 'db'
dump: '../Resources/Private/Dumps/Fixture.sql'
host: 'db'
dump: 'extensions/t3omy_test/Resources/Private/Dumps/Fixture.sql'
populate: true
cleanup: true
- \Helper\Acceptance
populator: 'mysql --host=$host --user=$user --password=$password $dbName < $dump'
step_decorators: ~
......@@ -7,7 +7,7 @@ Feature:
Given I clear my inbox
And dataset "../Tests/acceptance/Features/Registration/EmptyFeUsers.yaml" is imported
Scenario: Registration workflow
Scenario: Registration workflow with double confirm
Given I am on "/"
Then I should see "Welcome to my.typo3.org"
And I wait for 1 seconds
......@@ -15,7 +15,7 @@ Feature:
Then I should see "Enter your credentials below to sign in"
#When I click on "Sign up"
When I am on "/?id=2"
And I fill in "Username" with "my_testuser"
And I fill in "Username" with "my_doubleconfirm_user"
And I fill in "Email" with "test@localhost.localdomain"
And I fill in "Full Name" with "Little Miss Sunshine"
And I fill in "Password" with "aaaaaaaaaaaa"
......@@ -29,7 +29,31 @@ Feature:
When I follow "sign-up" in the email
Then I should see "Double confirmation needed"
And the database table "fe_users" should contain
| pid | username | usergroup | disable | name | email | tx_femanager_confirmedbyuser | tx_femanager_confirmedbyadmin |
| 5 | my_testuser | 1 | 1 | Little Miss Sunshine | test@localhost.localdomain | 1 | 0 |
| pid | username | usergroup | disable | name | email | tx_femanager_confirmedbyuser | tx_femanager_confirmedbyadmin |
| 5 | my_doubleconfirm_user | 1 | 1 | Little Miss Sunshine | test@localhost.localdomain | 1 | 0 |
Scenario: Registration workflow without double confirm
Given I am on "/"
Then I should see "Welcome to my.typo3.org"
And I wait for 1 seconds
When I click on "._login > a"
Then I should see "Enter your credentials below to sign in"
#When I click on "Sign up"
When I am on "/?id=2"
And I fill in "Username" with "my_testuser"
And I fill in "Email" with "test@test.de"
And I fill in "Full Name" with "Max Mustermann"
And I fill in "Password" with "123456789012"
And I fill in "Repeat Password" with "123456789012"
And I check option "I accept the terms and conditions"
And I click on "Create Profile Now"
Then I should not see an ".femanager_error" element
And I should not see "Whoops"
And I should see "Thank you for registering at typo3.org."
And the inbox contains 1 mails
When I follow "sign-up" in the email
Then I should see "Double confirmation needed"
And the database table "fe_users" should contain
| pid | username | usergroup | disable | name | email | tx_femanager_confirmedbyuser | tx_femanager_confirmedbyadmin |
| 5 | my_testuser | 1 | 1 | Mx Mustermann | test@test.de | 1 | 0 |
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment