Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pre-configuration for Nightwatch VRT #351

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/TestFunctional.yml
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,10 @@ jobs:
echo ' ws: "*"' >> .yarnrc.yml
echo ' lodash: "*"' >> .yarnrc.yml
echo ' rimraf: "*"' >> .yarnrc.yml
ddev yarn add nightwatch nightwatch-axe-verbose @lullabot/nightwatch-drupal-commands --dev
echo ' "@nightwatch/vrt@*":' >> .yarnrc.yml
echo ' dependencies:' >> .yarnrc.yml
echo ' open: "^8"' >> .yarnrc.yml
ddev yarn add nightwatch nightwatch-axe-verbose @nightwatch/vrt @lullabot/nightwatch-drupal-commands --dev
yarn

- name: Install Drupal
Expand Down
1 change: 1 addition & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ build:
- ddev composer require lullabot/drainpipe --with-all-dependencies
- ddev restart
- test -f .gitlab/drainpipe/DDEV.gitlab-ci.yml
- test -f .gitlab/drainpipe/Nightwatch.gitlab-ci.yml
- ddev drush site:install minimal -y
- echo "\$settings['config_sync_directory'] = '../config';" >> web/sites/default/settings.php
- ddev drush config:export -y
Expand Down
18 changes: 18 additions & 0 deletions drainpipe-dev/config/nightwatch.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ const drupalCommandsPath = path.dirname(require.resolve('@lullabot/nightwatch-dr
const firefoxLaunchUrl = process.env.NIGHTWATCH_DRUPAL_URL_FIREFOX && process.env.NIGHTWATCH_DRUPAL_URL_FIREFOX.length ? process.env.NIGHTWATCH_DRUPAL_URL_FIREFOX.replace(/\/$/, '') : process.env.NIGHTWATCH_DRUPAL_URL;
const chromeLaunchUrl = process.env.NIGHTWATCH_DRUPAL_URL_CHROME && process.env.NIGHTWATCH_DRUPAL_URL_CHROME.length ? process.env.NIGHTWATCH_DRUPAL_URL_CHROME.replace(/\/$/, '') : process.env.NIGHTWATCH_DRUPAL_URL;

let nightwatchVRT = true;
try {
require.resolve('@nightwatch/vrt');
} catch(e) {
nightwatchVRT = false;
}

module.exports = {
// An array of folders (excluding subfolders) where your tests are located;
// if this is not specified, the test source must be passed as the second argument to the test runner.
Expand All @@ -23,6 +30,17 @@ module.exports = {
// See https://nightwatchjs.org/guide/#external-globals
globals_path : '',

plugins: nightwatchVRT ? ['@nightwatch/vrt'] : [],

'@nightwatch/vrt': {
latest_screenshots_path: 'test/nightwatch/vrt/latest',
baseline_screenshots_path: 'test/nightwatch/vrt/baseline',
diff_screenshots_path: 'test/nightwatch/vrt/diff',
threshold: 0.00,
prompt: false,
updateScreenshots: false
},

webdriver: {},

test_workers: {
Expand Down
3 changes: 3 additions & 0 deletions scaffold/gitignore/common.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,6 @@ node_modules
#########
test_result
.prettiercache
vrt-report
test/nightwatch/vrt/latest
test/nightwatch/vrt/diff
33 changes: 33 additions & 0 deletions scaffold/gitlab/Nightwatch.gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
report-nightwatch:
stage: report
when: always
needs:
- job: functional
artifacts: true
script:
- echo "Nothing to do"
artifacts:
expose_as: 'Nightwatch Test Report'
paths:
- test_result/nightwatch-html-report/index.html
- test/nightwatch/vrt
- test_result

report-nightwatch-vrt:
stage: report
when: always
script:
- |
if [ -f "vrt-report/index.html" ] && [ $GITLAB_CI = "true" ]; then
cp vrt-report/index.html vrt-report/index-gitlab.html
sed -i "s|\"/test/nightwatch/vrt/|\"../test/nightwatch/vrt/|g" vrt-report/index-gitlab.html
fi
needs:
- job: functional
artifacts: true
artifacts:
expose_as: 'VRT Test Report'
paths:
- vrt-report/index-gitlab.html
- test/nightwatch/vrt
- test_result
5 changes: 3 additions & 2 deletions src/ScaffoldInstallerPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,16 +224,17 @@ private function installCICommands(): void
// GitLab
$fs->removeDirectory('./.drainpipe/gitlab');
if (isset($this->extra['drainpipe']['gitlab']) && is_array($this->extra['drainpipe']['gitlab'])) {
$fs->ensureDirectoryExists('.gitlab/drainpipe');
if (file_exists('./.ddev/config.yaml')) {
$fs->ensureDirectoryExists('.gitlab/drainpipe');
$fs->copy("$scaffoldPath/gitlab/DDEV.gitlab-ci.yml", ".gitlab/drainpipe/DDEV.gitlab-ci.yml");
$this->io->write("🪠 [Drainpipe] .gitlab/drainpipe/DDEV.gitlab-ci.yml installed");
}
else {
$fs->ensureDirectoryExists('./.drainpipe/gitlab');
$fs->copy("$scaffoldPath/gitlab/Common.gitlab-ci.yml", ".drainpipe/gitlab/Common.gitlab-ci.yml");
$this->io->write("🪠 [Drainpipe] .drainpipe/gitlab/Common.gitlab-ci.yml installed");
}
$fs->copy("$scaffoldPath/gitlab/Nightwatch.gitlab-ci.yml", ".drainpipe/gitlab/Nightwatch.gitlab-ci.yml");
$this->io->write("🪠 [Drainpipe] .drainpipe/gitlab/Nightwatch.gitlab-ci.yml installed");
foreach ($this->extra['drainpipe']['gitlab'] as $gitlab) {
$file = "gitlab/$gitlab.gitlab-ci.yml";
if (file_exists("$scaffoldPath/$file")) {
Expand Down
5 changes: 4 additions & 1 deletion tasks/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ tasks:
interactive: true
cmds:
- |
PACKAGES="nightwatch nightwatch-axe-verbose @lullabot/nightwatch-drupal-commands"
PACKAGES="nightwatch nightwatch-axe-verbose @nightwatch/vrt @lullabot/nightwatch-drupal-commands"
if [ ! -f "package.json" ]; then
echo -n "No package.json exists, would you like to use yarn1, npm, or yarn? "
read -r PACKAGE_MANAGER
Expand All @@ -228,6 +228,9 @@ tasks:
echo ' dependencies:' >> .yarnrc.yml
echo ' ws: "*"' >> .yarnrc.yml
echo ' lodash: "*"' >> .yarnrc.yml
echo ' "@nightwatch/vrt@*":' >> .yarnrc.yml
echo ' dependencies:' >> .yarnrc.yml
echo ' open: "^8"' >> .yarnrc.yml
yarn add $PACKAGES --dev
else
echo "Sorry I'm not aware of that package manager. Please first init package.json with it yourself manually."
Expand Down
Loading