Skip to content

Commit 7a1edf7

Browse files
committed
VAGOV-1326 nightwatch-accessibility implemented with baseline accessibility test and npm install on build.
1 parent eee036b commit 7a1edf7

File tree

7 files changed

+164
-100
lines changed

7 files changed

+164
-100
lines changed

.lando.yml

+12-6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ events:
1313
# Runs composer install after app starts
1414
post-start:
1515
- appserver: cd $LANDO_MOUNT && composer install
16+
# - appserver: cd $LANDO_MOUNT && npm install
1617

1718
# After code changes
1819
post-update:
@@ -24,10 +25,10 @@ services:
2425
run_as_root:
2526
- "apt-get update -y"
2627
- "apt-get install build-essential chrpath libssl-dev libxft-dev libfreetype6-dev libfreetype6 libfontconfig1-dev libfontconfig1 -y"
27-
- "tar xvjf /app/phantomjs-2.1.1-linux-x86_64.tar.bz2 -C /usr/local/share/"
28-
- "mv /usr/local/share/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/bin/"
29-
- "cd /usr/bin"
30-
- "chmod +x phantomjs"
28+
# - "tar xvjf /app/phantomjs-2.1.1-linux-x86_64.tar.bz2 -C /usr/local/share/"
29+
# - "mv /usr/local/share/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/bin/"
30+
# - "cd /usr/bin"
31+
# - "chmod +x phantomjs"
3132
# Uncomment the below `xdebug: true` for Xdebug support
3233
# @todo Change this to pull in a local Lando settings variable and use that boolean variable
3334
# Run `lando rebuild` after uncommenting
@@ -40,7 +41,8 @@ services:
4041
node:
4142
type: node
4243
build:
43-
- "cd $LANDO_MOUNT/docroot/themes/custom/vagov && npm install"
44+
- npm install
45+
# - "cd $LANDO_MOUNT/docroot/themes/custom/vagov && npm install"
4446
overrides:
4547
services:
4648
environment:
@@ -49,7 +51,6 @@ services:
4951
- 3000:3000
5052
- 3001:3001
5153
image: node:10.13-jessie
52-
5354
globals:
5455
gulp-cli: "latest"
5556
tooling:
@@ -69,6 +70,11 @@ tooling:
6970
service: node
7071
node:
7172
service: node
73+
nightwatch:
74+
service: node
75+
description: "Run nightwatch tests locally. Syntax: npm run-script nightwatch."
76+
cmd:
77+
- ./node_modules/.bin/nightwatch --tags accessibility
7278
gulp:
7379
service: node
7480
db-sync-stg:

Gruntfile.js

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
'use strict';
2+
module.exports = function ( grunt ) {
3+
4+
require( 'load-grunt-tasks' )( grunt );
5+
6+
// Project configuration
7+
grunt.initConfig( {
8+
9+
// Configure ESLint task
10+
eslint: {
11+
all: [
12+
'**/*.js',
13+
'!node_modules/**'
14+
]
15+
},
16+
17+
// Configure JSONLint task
18+
jsonlint: {
19+
all: [
20+
'**/*.json',
21+
'!node_modules/**'
22+
]
23+
},
24+
25+
// Configure Nightwatch task
26+
nightwatch: {
27+
options: {
28+
// nightwatch settings
29+
src_folders: [ 'tests' ], // eslint-disable-line camelcase
30+
output_folder: 'report' // eslint-disable-line camelcase
31+
}
32+
}
33+
34+
} );
35+
36+
// Default tasks
37+
grunt.registerTask( 'default', [ 'eslint', 'jsonlint' ] );
38+
39+
};

globalsModule.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'use strict';
2+
var chromedriver = require( 'chromedriver' );
3+
module.exports = {
4+
5+
before: function ( done ) {
6+
chromedriver.start();
7+
8+
done();
9+
},
10+
11+
after: function ( done ) {
12+
chromedriver.stop();
13+
14+
done();
15+
}
16+
};

nightwatch.json

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"src_folders" : ["./tests/nightwatch/features"],
3+
"output_folder" : "./tests/nightwatch/reports",
4+
"custom_commands_path": ["./node_modules/nightwatch-accessibility/commands"],
5+
"custom_assertions_path": ["./node_modules/nightwatch-accessibility/assertions"],
6+
"page_objects_path" : "./tests/nightwatch/pageobjects",
7+
"globals_path" : "globalsModule.js",
8+
9+
"selenium" : {
10+
"start_process" : false,
11+
"server_path" : "",
12+
"log_path" : "",
13+
"port" : 9515,
14+
"cli_args" : {
15+
"webdriver.chrome.driver" : "/usr/local/bin/chromedriver",
16+
"webdriver.gecko.driver" : "",
17+
"webdriver.edge.driver" : ""
18+
}
19+
},
20+
21+
"test_settings" : {
22+
"default" : {
23+
"launch_url" : "http://vagovcms.lndo.site/",
24+
"selenium_port" : 9515,
25+
"selenium_host" : "localhost",
26+
"default_path_prefix" : "",
27+
"silent": true,
28+
"screenshots" : {
29+
"enabled" : false,
30+
"path" : ""
31+
}
32+
},
33+
"desiredCapabilities": {
34+
"browserName": "chrome",
35+
"chromeOptions" : {
36+
"args" : ["headless", "--no-sandbox"]
37+
},
38+
"acceptSslCerts": true
39+
},
40+
"chrome" : {
41+
"desiredCapabilities": {
42+
"browserName": "chrome"
43+
}
44+
}
45+
}
46+
}

package.json

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "vagov",
3+
"version": "1.0.0",
4+
"description": "This is an Aquia Lightning based implementation of Drupal 8 that uses [Lando](https://docs.devwithlando.io/) for local container management.",
5+
"main": "index.js",
6+
"scripts": {
7+
"nightwatch": "./node_modules/.bin/nightwatch --tag accessibility"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "git+https://github.com/department-of-veterans-affairs/va.gov-cms.git"
12+
},
13+
"author": "",
14+
"license": "ISC",
15+
"bugs": {
16+
"url": "https://github.com/department-of-veterans-affairs/va.gov-cms/issues"
17+
},
18+
"homepage": "https://github.com/department-of-veterans-affairs/va.gov-cms#readme",
19+
"devDependencies": {
20+
"chromedriver": "^2.46.0",
21+
"eslint-config-wikimedia": "^0.10.1",
22+
"grunt": "^1.0.3",
23+
"grunt-eslint": "^21.0.0",
24+
"grunt-jsonlint": "^1.1.0",
25+
"grunt-nightwatch": "^0.5.4",
26+
"load-grunt-tasks": "^4.0.0",
27+
"nightwatch": "^1.0.18",
28+
"nightwatch-accessibility": "^1.7.1"
29+
}
30+
}

tests/accessibility/pa11y.js

-94
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* @file Run Axe accessibility tests with Nightwatch.
3+
*/
4+
// import "nightwatch-accessibility";
5+
6+
module.exports = {
7+
'@tags': ['accessibility'],
8+
'Axe Test': function (browser) {
9+
browser
10+
.url('http://vagovcms.lndo.site') // Navigate to the url
11+
.waitForElementVisible('body', 2000) // Wait until you can see the body element.
12+
.initAccessibility()
13+
.assert.accessibility('body', {
14+
verbose: true,
15+
rules: {
16+
'color-contrast': { enabled: false }
17+
}
18+
})
19+
.end()
20+
}
21+
}

0 commit comments

Comments
 (0)