Skip to content

Commit

Permalink
Merge pull request #35 from Lullabot/justafish/use-composer-scaffold
Browse files Browse the repository at this point in the history
Add helper setup task for Nightwatch
  • Loading branch information
justafish committed Mar 4, 2022
2 parents b2bf4d4 + 48034a1 commit 63ddf91
Show file tree
Hide file tree
Showing 14 changed files with 200 additions and 345 deletions.
36 changes: 34 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,32 @@ This is a composer package containing the testing helpers for Drainpipe i.e.
should be included in `require-dev` and not installed in production
environments.

## Installation

- Your Drupal project must be using `drupal/core-composer-scaffold`
- Run:
```
composer config extra.drupal-scaffold.gitignore true
composer config --json --merge extra.drupal-scaffold.allowed-packages '["lullabot/drainpipe-dev"]'
```
or if using DDEV:
```
ddev composer config extra.drupal-scaffold.gitignore true
ddev composer "config --json extra.drupal-scaffold.allowed-packages '[\"lullabot/drainpipe-dev\"]'"
```
- Ensure your project's `composer.json` now contains the following:
```
"extra": {
"drupal-scaffold": {
"gitignore": true,
"allowed-packages": [
"lullabot/drainpipe-dev"
]
}
}
```
- Run `composer require lullabot/drainpipe-dev --dev`

## Usage

### `test:static`
Expand Down Expand Up @@ -56,8 +82,14 @@ Runs all functional tests i.e. those which require a running Drupal environment.
Verifies that exported configuration matches the current configuration in
Drupal's database.

#### `test:nightwatch:setup`

This will help you setup your project to run Nightwatch tests by installing
the necessary node packages and DDEV configurations.

#### `test:nightwatch`


Runs functional browser tests with [Nightwatch](https://nightwatchjs.org/).

If you are using DDEV, Drainpipe will have created a
Expand All @@ -70,8 +102,8 @@ the test runner.

Whilst tests are running, you can view them in realtime through your browser.

http://localhost:7900 for Chrome
http://localhost:7901 for Firefox
https://<ddev-site-name>:7900 for Chrome
https://<ddev-site-name>:7901 for Firefox

The password for all environments is `secret`.

Expand Down
27 changes: 23 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
"mockery/mockery": "^1.4",
"behat/mink": "^1.8",
"symfony/phpunit-bridge": "^5.3",
"lullabot/drainpipe": "^1.0",
"mglaman/phpstan-drupal": "^1.0.3",
"drush/drush": "^10.5",
"symfony/yaml": "^4",
"lullabot/drainpipe": "^1.0",
"drupal/coder": "^8.3",
"friends-of-behat/mink-browserkit-driver": "^1.5",
"tijsverkoyen/convert-to-junit-xml": "^1.9",
Expand All @@ -37,8 +37,27 @@
],
"extra": {
"class": [
"\\Lullabot\\DrainpipeDev\\DevBinaryInstallerPlugin",
"\\Lullabot\\DrainpipeDev\\DevScaffoldInstallerPlugin"
]
"\\Lullabot\\DrainpipeDev\\DevBinaryInstallerPlugin"
],
"drupal-scaffold": {
"gitignore": true,
"file-mapping": {
"[project-root]/nightwatch.conf.js": "scaffold/nightwatch/nightwatch.conf.js",
"[web-root]/sites/chrome/settings.php": "scaffold/nightwatch/chrome.settings.php",
"[web-root]/sites/firefox/settings.php": "scaffold/nightwatch/firefox.settings.php",
"[web-root]/sites/default/sites.php": "scaffold/nightwatch/sites.php",
"[project-root]/.ddev/docker-compose.selenium.yaml": "scaffold/nightwatch/docker-compose.selenium.yaml",
"[project-root]/test/nightwatch/example.nightwatch.js": "scaffold/nightwatch/example.nightwatch.js",
"[project-root]/phpstan.neon": "scaffold/phpstan.neon",
"[project-root]/phpcs.xml": "scaffold/phpcs.xml"
}
}
},
"config": {
"allow-plugins": {
"composer/package-versions-deprecated": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"lullabot/drainpipe": true
}
}
}
1 change: 0 additions & 1 deletion config/phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
includes:
- ../../../mglaman/phpstan-drupal/extension.neon
- ../../../phpstan/phpstan-deprecation-rules/rules.neon
- ../../../../phpstan.neon

parameters:
excludePaths:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,41 @@ version: '3.6'
services:
chrome:
container_name: ddev-${DDEV_SITENAME}-chrome
image: selenium/standalone-chrome:4.0.0-rc-1-prerelease-20210713
image: selenium/standalone-chrome:4.1.2-20220217
labels:
com.ddev.site-name: ${DDEV_SITENAME}
com.ddev.approot: $DDEV_APPROOT
ports:
- 7900:7900
expose:
- 7900
environment:
- VIRTUAL_HOST=$DDEV_HOSTNAME
- HTTPS_EXPOSE=7900:7900
- HTTP_EXPOSE=7910:7900
links:
- web:web
- web:drupal_chrome
external_links:
- ddev-router:${DDEV_SITENAME}.${DDEV_TLD}
volumes:
- ".:/mnt/ddev_config"

firefox:
container_name: ddev-${DDEV_SITENAME}-firefox
image: selenium/standalone-firefox:4.0.0-rc-1-prerelease-20210713
image: selenium/standalone-firefox:4.1.2-20220217
labels:
com.ddev.site-name: ${DDEV_SITENAME}
com.ddev.approot: $DDEV_APPROOT
ports:
- 7901:7900
expose:
- 7901
environment:
- NO_VNC_PORT=7901
- VIRTUAL_HOST=$DDEV_HOSTNAME
- HTTPS_EXPOSE=7901:7901
- HTTP_EXPOSE=7911:7901
links:
- web:web
- web:drupal_firefox
external_links:
- ddev-router:${DDEV_SITENAME}.${DDEV_TLD}
volumes:
- ".:/mnt/ddev_config"
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 17 additions & 0 deletions scaffold/nightwatch/sites.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

/**
* @file
* Multi-site configuration.
*
* Allows separate installs for Chrome and Firefox Nightwatch testing.
*/

if (getenv('IS_DDEV_PROJECT') == 'true') {
$sites['drupal_chrome'] = 'chrome';
$sites['drupal_firefox'] = 'firefox';
$ddev_sitename = getenv('DDEV_SITENAME');
$ddev_tld = getenv('DDEV_TLD');
$sites["chrome.$ddev_sitename.$ddev_tld"] = 'chrome';
$sites["firefox.$ddev_sitename.$ddev_tld"] = 'firefox';
}
3 changes: 2 additions & 1 deletion scaffold/phpstan.neon
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
parameters:
includes:
- vendor/lullabot/drainpipe-dev/config/phpstan.neon
11 changes: 0 additions & 11 deletions scaffold/sites.php

This file was deleted.

Loading

0 comments on commit 63ddf91

Please sign in to comment.