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

Upgrade Nightwatch and add a test for functional tests #221

Merged
merged 35 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
4054519
Upgrade Nightwatch and add a test for functional tests
justafish Jul 4, 2023
3c03c07
Fix hostname
justafish Jul 5, 2023
5036f5f
Fix chrome database
justafish Jul 5, 2023
22225ad
Switch npm run to npx
justafish Jul 5, 2023
cbc0f48
Export config
justafish Jul 5, 2023
6ec15c6
Debugging
justafish Jul 5, 2023
252fbf1
Disable workers and fix nightwatch a11y commands path
justafish Jul 5, 2023
9a1fa11
Remove debugging
justafish Jul 5, 2023
8a8284c
Split job
justafish Jul 5, 2023
ab93afe
Add job dependency
justafish Jul 5, 2023
9fa7e55
Install DDEV in second job
justafish Jul 5, 2023
edf86c9
Create a zip of the workspace
justafish Jul 5, 2023
eb13954
reorder
justafish Jul 5, 2023
536cc46
file location
justafish Jul 5, 2023
8c0e24e
cd to /
justafish Jul 5, 2023
1809ed9
fix zip
justafish Jul 5, 2023
9674d05
Test yarn classic
justafish Jul 5, 2023
be331ec
Fix package name
justafish Jul 5, 2023
0524011
Test Yarn Berry with the node-modules node linker
justafish Jul 5, 2023
0b8fdd8
Add a test for Yarn Berry
justafish Jul 5, 2023
d1270fc
Remove unecessary ddev restart
justafish Jul 5, 2023
26bfaeb
Fix the Sass compilation
justafish Jul 5, 2023
332b8dd
Fix missing dependency that nightwatch has used
justafish Jul 5, 2023
81f0520
Re-run yarn
justafish Jul 5, 2023
6497c00
Merge branch 'main' into justafish/nightwatch-upgrade
justafish Jul 5, 2023
f0329d6
Add ws
justafish Jul 5, 2023
97ba785
Add ws later
justafish Jul 5, 2023
710f9c2
Merge branch 'main' into justafish/nightwatch-upgrade
justafish Jul 24, 2023
dd8578e
Merge branch 'main' into justafish/nightwatch-upgrade
justafish Jul 24, 2023
5033711
remove wd/hub
justafish Jul 25, 2023
a21b31b
Chrome options
justafish Jul 25, 2023
95f0c4f
try firefox
justafish Jul 25, 2023
c85aa3a
try a fork
justafish Jul 25, 2023
40d7ea1
Downgrade selenium
justafish Jul 26, 2023
4cbe395
Merge branch 'main' into justafish/nightwatch-upgrade
justafish Jul 26, 2023
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
268 changes: 268 additions & 0 deletions .github/workflows/TestFunctional.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,268 @@
name: Test Functional Tests
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
Build:
runs-on: ubuntu-latest
steps:
- name: Create a Drupal project
run: composer create-project drupal/recommended-project . --ignore-platform-req=ext-gd

- uses: actions/checkout@v3
with:
path: drainpipe

- name: Setup drainpipe-dev
run: mv drainpipe/drainpipe-dev .

- uses: ./drainpipe/scaffold/github/actions/common/set-env

- name: Install DDEV
uses: ./drainpipe/scaffold/github/actions/common/ddev
with:
git-name: Drainpipe Bot
git-email: no-reply@example.com

- name: Setup Project
run: |
ddev config --auto
ddev start
ddev composer config extra.drupal-scaffold.gitignore true
ddev composer config --json extra.drupal-scaffold.allowed-packages '["lullabot/drainpipe-dev", "lullabot/drainpipe"]'
ddev composer config --no-plugins allow-plugins.composer/installers true
ddev composer config --no-plugins allow-plugins.drupal/core-composer-scaffold true
ddev composer config --no-plugins allow-plugins.lullabot/drainpipe true
ddev composer config --no-plugins allow-plugins.lullabot/drainpipe-dev true
ddev composer config repositories.drainpipe --json '{"type": "path", "url": "drainpipe", "options": {"symlink": false}}'
ddev composer config repositories.drainpipe-dev --json '{"type": "path", "url": "drainpipe-dev", "options": {"symlink": false}}'
ddev composer config minimum-stability dev
ddev composer require "lullabot/drainpipe @dev" --with-all-dependencies
ddev composer require "lullabot/drainpipe-dev @dev" --dev --with-all-dependencies

- name: Setup Nightwatch
run: |
echo "hooks:" >> .ddev/config.yaml
echo " post-start:" >> .ddev/config.yaml
echo " - exec: mysql -uroot -proot -hdb -e \"CREATE DATABASE IF NOT EXISTS firefox; GRANT ALL ON firefox.* TO 'db'@'%';\"" >> .ddev/config.yaml
echo " - exec: mysql -uroot -proot -hdb -e \"CREATE DATABASE IF NOT EXISTS chrome; GRANT ALL ON chrome.* TO 'db'@'%';\"" >> .ddev/config.yaml
ddev config --web-environment="NIGHTWATCH_DRUPAL_URL_FIREFOX=https://drupal_firefox,NIGHTWATCH_DRUPAL_URL_CHROME=https://drupal_chrome"
ddev config --additional-hostnames="*.drainpipe"

- name: Create Artifact
run: zip -r /tmp/drainpipe.zip ./

- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: test-functional-build
path: /tmp/drainpipe.zip

Test-NPM:
runs-on: ubuntu-latest
needs: Build
steps:
- uses: actions/download-artifact@v3
with:
name: test-functional-build

- name: Restore Workspace
run: |
cd ../
mv ${{ github.workspace }}/drainpipe.zip /tmp/drainpipe.zip
unzip -o /tmp/drainpipe.zip -d ${{ github.workspace }}
cd ${{ github.workspace }}

- uses: ./drainpipe/scaffold/github/actions/common/set-env

- name: Install DDEV
uses: ./drainpipe/scaffold/github/actions/common/ddev
with:
git-name: Drainpipe Bot
git-email: no-reply@example.com#

- name: Start DDEV
run: ddev start

- name: Setup Nightwatch
run: |
ddev npm init -y
ddev npm install nightwatch nightwatch-accessibility @lullabot/nightwatch-drupal-commands --save-dev

- name: Install Drupal
run: |
ddev drush --yes site:install
ddev drush --uri=https://drupal_firefox --yes site:install
ddev drush --uri=https://drupal_chrome --yes site:install
ddev drush config:export --yes

- name: Run Functional Tests
run: ddev task test:functional

- name: Upload test artifacts
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: test_result
path: test_result

Test-Yarn-Classic:
runs-on: ubuntu-latest
needs: Build
steps:
- uses: actions/download-artifact@v3
with:
name: test-functional-build

- name: Restore Workspace
run: |
cd ../
mv ${{ github.workspace }}/drainpipe.zip /tmp/drainpipe.zip
unzip -o /tmp/drainpipe.zip -d ${{ github.workspace }}
cd ${{ github.workspace }}

- uses: ./drainpipe/scaffold/github/actions/common/set-env

- name: Install DDEV
uses: ./drainpipe/scaffold/github/actions/common/ddev
with:
git-name: Drainpipe Bot
git-email: no-reply@example.com#

- name: Start DDEV
run: ddev start

- name: Setup Nightwatch
run: |
ddev yarn set version classic
ddev yarn init -y
ddev yarn add nightwatch nightwatch-accessibility @lullabot/nightwatch-drupal-commands --dev

- name: Install Drupal
run: |
ddev drush --yes site:install
ddev drush --uri=https://drupal_firefox --yes site:install
ddev drush --uri=https://drupal_chrome --yes site:install
ddev drush config:export --yes

- name: Run Functional Tests
run: ddev task test:functional

- name: Upload test artifacts
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: test_result
path: test_result

Test-Yarn-Berry-Node-Linker:
runs-on: ubuntu-latest
needs: Build
steps:
- uses: actions/download-artifact@v3
with:
name: test-functional-build

- name: Restore Workspace
run: |
cd ../
mv ${{ github.workspace }}/drainpipe.zip /tmp/drainpipe.zip
unzip -o /tmp/drainpipe.zip -d ${{ github.workspace }}
cd ${{ github.workspace }}

- uses: ./drainpipe/scaffold/github/actions/common/set-env

- name: Install DDEV
uses: ./drainpipe/scaffold/github/actions/common/ddev
with:
git-name: Drainpipe Bot
git-email: no-reply@example.com#

- name: Start DDEV
run: ddev start

- name: Setup Nightwatch
run: |
ddev yarn set version berry
ddev yarn init -y
yarn config set nodeLinker node-modules
ddev yarn add nightwatch nightwatch-accessibility @lullabot/nightwatch-drupal-commands --dev

- name: Install Drupal
run: |
ddev drush --yes site:install
ddev drush --uri=https://drupal_firefox --yes site:install
ddev drush --uri=https://drupal_chrome --yes site:install
ddev drush config:export --yes

- name: Run Functional Tests
run: ddev task test:functional

- name: Upload test artifacts
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: test_result
path: test_result

Test-Yarn-Berry:
runs-on: ubuntu-latest
needs: Build
steps:
- uses: actions/download-artifact@v3
with:
name: test-functional-build

- name: Restore Workspace
run: |
cd ../
mv ${{ github.workspace }}/drainpipe.zip /tmp/drainpipe.zip
unzip -o /tmp/drainpipe.zip -d ${{ github.workspace }}
cd ${{ github.workspace }}

- uses: ./drainpipe/scaffold/github/actions/common/set-env

- name: Install DDEV
uses: ./drainpipe/scaffold/github/actions/common/ddev
with:
git-name: Drainpipe Bot
git-email: no-reply@example.com#

- name: Start DDEV
run: ddev start

- name: Setup Nightwatch
run: |
ddev yarn set version berry
ddev yarn init -y
echo "packageExtensions:" >> .yarnrc.yml
echo ' "nightwatch@*":' >> .yarnrc.yml
echo ' dependencies:' >> .yarnrc.yml
echo ' ws: "*"' >> .yarnrc.yml
ddev yarn add nightwatch nightwatch-accessibility @lullabot/nightwatch-drupal-commands ws --dev
yarn

- name: Install Drupal
run: |
ddev drush --yes site:install
ddev drush --uri=https://drupal_firefox --yes site:install
ddev drush --uri=https://drupal_chrome --yes site:install
ddev drush config:export --yes

- name: Run Functional Tests
run: ddev task test:functional

- name: Upload test artifacts
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: test_result
path: test_result
File renamed without changes.
87 changes: 44 additions & 43 deletions drainpipe-dev/config/nightwatch.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ try {
drupalCommandsPath = resolveToUnqualified('@lullabot/nightwatch-drupal-commands', __filename).replace(/\/$/, '');
yarn2 = true;
} catch(e) {
a11yPath = './node_modules/nightwatch-accessibility';
a11yPath = './node_modules/nightwatch-accessibility/nightwatch';
drupalCommandsPath = './node_modules/@lullabot/nightwatch-drupal-commands';
}

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;

module.exports = {
// An array of folders (excluding subfolders) where your tests are located;
Expand All @@ -32,50 +34,33 @@ module.exports = {

webdriver: {},

test_workers: {
enabled: false
},

test_settings: {
default: {
filter: '**/*.nightwatch.js',
"screenshots" : {
"enabled" : true,
"on_failure" : true,
"on_error" : false,
"path" : "test_result"
}
},
firefox: {
desiredCapabilities: {
resolution: "1240x4000",
browserName: 'firefox',
acceptInsecureCerts: true,
alwaysMatch: {
'moz:firefoxOptions': {
args: [
//'-headless',
// '-verbose'
]
}
}
},
webdriver: {
start_process: false,
host: 'firefox',
port: 4444,
cli_args: [
// very verbose geckodriver logs
// '-vv'
]
},
globals: {
drupalUrl: 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,
disable_error_log: false,
screenshots: {
enabled: false,
on_failure: true,
on_error: false,
path: 'test_result',
},
},

chrome: {
selenium: {
start_process: false,
host: 'chrome',
port: 4444
},
desiredCapabilities: {
resolution: "1240x4000",
browserName: 'chrome',
esolution: "1240x4000",
'goog:chromeOptions': {
// More info on Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/
//
w3c: true,
args: [
'--no-sandbox',
'--ignore-certificate-errors',
Expand All @@ -84,17 +69,33 @@ module.exports = {
]
}
},
webdriver: {
globals: {
drupalUrl: chromeLaunchUrl,
},
launch_url: chromeLaunchUrl,
},

firefox: {
selenium: {
start_process: false,
host: 'chrome',
port: 4444,
cli_args: [
// --verbose
]
host: 'firefox',
port: 4444
},
desiredCapabilities: {
browserName: 'firefox',
resolution: "1240x4000",
acceptInsecureCerts: true,
'moz:firefoxOptions': {
args: [
// '-headless',
// '-verbose'
]
}
},
globals: {
drupalUrl: 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,
drupalUrl: firefoxLaunchUrl,
},
launch_url: firefoxLaunchUrl,
},
}
};
Loading