mirror of
https://github.com/pa11y/pa11y-dashboard.git
synced 2025-09-24 14:21:13 +00:00
Tooling update (#184)
* Use a common Makefile/build process * Use ESLint with the pa11y lint config
This commit is contained in:
@@ -1,3 +1,2 @@
|
|||||||
coverage
|
coverage
|
||||||
node_modules
|
|
||||||
public/js
|
public/js
|
3
.eslintrc.js
Normal file
3
.eslintrc.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = require('pa11y-lint-config/eslint/es6');
|
94
.jscsrc
94
.jscsrc
@@ -1,94 +0,0 @@
|
|||||||
{
|
|
||||||
"disallowEmptyBlocks": true,
|
|
||||||
"disallowImplicitTypeConversion": [
|
|
||||||
"binary",
|
|
||||||
"boolean",
|
|
||||||
"numeric",
|
|
||||||
"string"
|
|
||||||
],
|
|
||||||
"disallowKeywordsOnNewLine": [
|
|
||||||
"catch",
|
|
||||||
"else"
|
|
||||||
],
|
|
||||||
"disallowMixedSpacesAndTabs": true,
|
|
||||||
"disallowMultipleSpaces": true,
|
|
||||||
"disallowMultipleVarDecl": true,
|
|
||||||
"disallowNewlineBeforeBlockStatements": true,
|
|
||||||
"disallowParenthesesAroundArrowParam": true,
|
|
||||||
"disallowQuotedKeysInObjects": true,
|
|
||||||
"disallowSpaceAfterObjectKeys": {
|
|
||||||
"allExcept": [
|
|
||||||
"method"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"disallowSpaceAfterPrefixUnaryOperators": true,
|
|
||||||
"disallowSpaceBeforeComma": true,
|
|
||||||
"disallowSpaceBeforeSemicolon": true,
|
|
||||||
"disallowSpacesInCallExpression": true,
|
|
||||||
"disallowSpacesInFunction": {
|
|
||||||
"beforeOpeningRoundBrace": true
|
|
||||||
},
|
|
||||||
"disallowSpacesInsideArrayBrackets": true,
|
|
||||||
"disallowSpacesInsideBrackets": true,
|
|
||||||
"disallowSpacesInsideObjectBrackets": true,
|
|
||||||
"disallowSpacesInsideParentheses": true,
|
|
||||||
"disallowSpacesInsideTemplateStringPlaceholders": true,
|
|
||||||
"disallowTrailingComma": true,
|
|
||||||
"disallowTrailingWhitespace": true,
|
|
||||||
"disallowVar": true,
|
|
||||||
"disallowYodaConditions": true,
|
|
||||||
|
|
||||||
"maximumLineLength": 100,
|
|
||||||
|
|
||||||
"requireArrowFunctions": true,
|
|
||||||
"requireBlocksOnNewline": true,
|
|
||||||
"requireCamelCaseOrUpperCaseIdentifiers": true,
|
|
||||||
"requireCapitalizedConstructors": true,
|
|
||||||
"requireCommaBeforeLineBreak": true,
|
|
||||||
"requireCurlyBraces": true,
|
|
||||||
"requireDotNotation": true,
|
|
||||||
"requireFunctionDeclarations": true,
|
|
||||||
"requireLineBreakAfterVariableAssignment": true,
|
|
||||||
"requireLineFeedAtFileEnd": true,
|
|
||||||
"requireObjectKeysOnNewLine": true,
|
|
||||||
"requireParenthesesAroundIIFE": true,
|
|
||||||
"requireSemicolons": true,
|
|
||||||
"requireSpaceAfterBinaryOperators": true,
|
|
||||||
"requireSpaceAfterKeywords": [
|
|
||||||
"if",
|
|
||||||
"else",
|
|
||||||
"for",
|
|
||||||
"while",
|
|
||||||
"do",
|
|
||||||
"switch",
|
|
||||||
"try",
|
|
||||||
"catch"
|
|
||||||
],
|
|
||||||
"requireSpaceAfterLineComment": {
|
|
||||||
"allExcept": [
|
|
||||||
"="
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"requireSpaceBeforeBinaryOperators": true,
|
|
||||||
"requireSpaceBeforeBlockStatements": true,
|
|
||||||
"requireSpaceBeforeObjectValues": true,
|
|
||||||
"requireSpaceBetweenArguments": true,
|
|
||||||
"requireSpacesInConditionalExpression": true,
|
|
||||||
"requireSpacesInForStatement": true,
|
|
||||||
"requireSpacesInFunction": {
|
|
||||||
"beforeOpeningCurlyBrace": true
|
|
||||||
},
|
|
||||||
"requireTemplateStrings": true,
|
|
||||||
|
|
||||||
"validateIndentation": "\t",
|
|
||||||
"validateLineBreaks": "LF",
|
|
||||||
"validateNewlineAfterArrayElements": true,
|
|
||||||
"validateParameterSeparator": ", ",
|
|
||||||
"validateQuoteMarks": "'",
|
|
||||||
|
|
||||||
"excludeFiles": [
|
|
||||||
"coverage",
|
|
||||||
"node_modules",
|
|
||||||
"public/js"
|
|
||||||
]
|
|
||||||
}
|
|
26
.jshintrc
26
.jshintrc
@@ -1,26 +0,0 @@
|
|||||||
{
|
|
||||||
"curly": true,
|
|
||||||
"eqeqeq": true,
|
|
||||||
"esversion": 6,
|
|
||||||
"forin": true,
|
|
||||||
"globals": {
|
|
||||||
"after": true,
|
|
||||||
"afterEach": true,
|
|
||||||
"before": true,
|
|
||||||
"beforeEach": true,
|
|
||||||
"describe": true,
|
|
||||||
"it": true
|
|
||||||
},
|
|
||||||
"latedef": "nofunc",
|
|
||||||
"maxcomplexity": 6,
|
|
||||||
"maxdepth": 2,
|
|
||||||
"maxparams": 4,
|
|
||||||
"noarg": true,
|
|
||||||
"node": true,
|
|
||||||
"nonew": true,
|
|
||||||
"nonstandard": true,
|
|
||||||
"shadow": false,
|
|
||||||
"strict": true,
|
|
||||||
"undef": true,
|
|
||||||
"unused": true
|
|
||||||
}
|
|
47
Makefile
47
Makefile
@@ -1,47 +1,27 @@
|
|||||||
|
include Makefile.node
|
||||||
|
|
||||||
# Color helpers
|
# We need to run integration tests recursively
|
||||||
C_CYAN=\x1b[34;01m
|
export INTEGRATION_FLAGS := --recursive
|
||||||
C_RESET=\x1b[0m
|
|
||||||
|
|
||||||
# Group targets
|
|
||||||
all: deps lint test
|
|
||||||
ci: lint test
|
|
||||||
|
|
||||||
# Install dependencies
|
# Verify tasks
|
||||||
deps:
|
# ------------
|
||||||
@echo "$(C_CYAN)> installing dependencies$(C_RESET)"
|
|
||||||
@npm install
|
|
||||||
|
|
||||||
# Lint JavaScript
|
# Lint alias for backwards compatibility
|
||||||
lint: jshint jscs
|
lint: verify
|
||||||
|
|
||||||
# Run JSHint
|
|
||||||
jshint:
|
|
||||||
@echo "$(C_CYAN)> linting javascript$(C_RESET)"
|
|
||||||
@./node_modules/.bin/jshint .
|
|
||||||
|
|
||||||
# Run JavaScript Code Style
|
# Client-side asset tasks
|
||||||
jscs:
|
# -----------------------
|
||||||
@echo "$(C_CYAN)> checking javascript code style$(C_RESET)"
|
|
||||||
@./node_modules/.bin/jscs .
|
|
||||||
|
|
||||||
# Run all tests
|
|
||||||
test: test-integration
|
|
||||||
|
|
||||||
# Run integration tests
|
|
||||||
test-integration:
|
|
||||||
@echo "$(C_CYAN)> running integration tests$(C_RESET)"
|
|
||||||
@./node_modules/.bin/mocha ./test/integration --reporter spec --recursive --timeout 5000 --slow 50
|
|
||||||
|
|
||||||
# Compile LESS
|
# Compile LESS
|
||||||
less:
|
less:
|
||||||
@echo "$(C_CYAN)> compiling less$(C_RESET)"
|
@lessc -x ./public/less/main.less ./public/css/site.min.css
|
||||||
@./node_modules/.bin/lessc -x ./public/less/main.less ./public/css/site.min.css
|
@$(TASK_DONE)
|
||||||
|
|
||||||
# Compile client-side JavaScript
|
# Compile client-side JavaScript
|
||||||
uglify:
|
uglify:
|
||||||
@echo "$(C_CYAN)> compiling client-side JavaScript$(C_RESET)"
|
@uglifyjs \
|
||||||
@./node_modules/.bin/uglifyjs \
|
|
||||||
public/js/vendor/jquery/jquery.min.js \
|
public/js/vendor/jquery/jquery.min.js \
|
||||||
public/js/vendor/bootstrap/js/alert.js \
|
public/js/vendor/bootstrap/js/alert.js \
|
||||||
public/js/vendor/bootstrap/js/dropdown.js \
|
public/js/vendor/bootstrap/js/dropdown.js \
|
||||||
@@ -55,5 +35,4 @@ uglify:
|
|||||||
public/js/vendor/flot/jquery.flot.resize.js \
|
public/js/vendor/flot/jquery.flot.resize.js \
|
||||||
public/js/site.js \
|
public/js/site.js \
|
||||||
-o ./public/js/site.min.js
|
-o ./public/js/site.min.js
|
||||||
|
@$(TASK_DONE)
|
||||||
.PHONY: test
|
|
||||||
|
125
Makefile.node
Normal file
125
Makefile.node
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
#
|
||||||
|
# Node.js Makefile
|
||||||
|
# ================
|
||||||
|
#
|
||||||
|
# Do not update this file manually – it's maintained separately on GitHub:
|
||||||
|
# https://github.com/rowanmanning/makefiles/blob/master/Makefile.node
|
||||||
|
#
|
||||||
|
# To update to the latest version, run `make update-makefile`.
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
# Meta tasks
|
||||||
|
# ----------
|
||||||
|
|
||||||
|
.PHONY: test
|
||||||
|
|
||||||
|
|
||||||
|
# Useful variables
|
||||||
|
# ----------------
|
||||||
|
|
||||||
|
NPM_BIN = ./node_modules/.bin
|
||||||
|
export PATH := $(NPM_BIN):$(PATH)
|
||||||
|
export EXPECTED_COVERAGE := 90
|
||||||
|
export INTEGRATION_TIMEOUT := 5000
|
||||||
|
export INTEGRATION_SLOW := 4000
|
||||||
|
|
||||||
|
|
||||||
|
# Output helpers
|
||||||
|
# --------------
|
||||||
|
|
||||||
|
TASK_DONE = echo "✓ $@ done"
|
||||||
|
|
||||||
|
|
||||||
|
# Group tasks
|
||||||
|
# -----------
|
||||||
|
|
||||||
|
all: install ci
|
||||||
|
ci: verify test
|
||||||
|
|
||||||
|
|
||||||
|
# Install tasks
|
||||||
|
# -------------
|
||||||
|
|
||||||
|
clean:
|
||||||
|
@git clean -fxd
|
||||||
|
@$(TASK_DONE)
|
||||||
|
|
||||||
|
install: node_modules
|
||||||
|
@$(TASK_DONE)
|
||||||
|
|
||||||
|
node_modules: package.json
|
||||||
|
@npm prune --production=false
|
||||||
|
@npm install
|
||||||
|
@$(TASK_DONE)
|
||||||
|
|
||||||
|
|
||||||
|
# Verify tasks
|
||||||
|
# ------------
|
||||||
|
|
||||||
|
verify: verify-javascript verify-dust verify-spaces
|
||||||
|
@$(TASK_DONE)
|
||||||
|
|
||||||
|
verify-javascript: verify-eslint verify-jshint verify-jscs
|
||||||
|
@$(TASK_DONE)
|
||||||
|
|
||||||
|
verify-dust:
|
||||||
|
@if [ -e .dustmiterc* ]; then dustmite --path ./view && $(TASK_DONE); fi
|
||||||
|
|
||||||
|
verify-eslint:
|
||||||
|
@if [ -e .eslintrc* ]; then eslint . && $(TASK_DONE); fi
|
||||||
|
|
||||||
|
verify-jshint:
|
||||||
|
@if [ -e .jshintrc* ]; then jshint . && $(TASK_DONE); fi
|
||||||
|
|
||||||
|
verify-jscs:
|
||||||
|
@if [ -e .jscsrc* ]; then jscs . && $(TASK_DONE); fi
|
||||||
|
|
||||||
|
verify-spaces:
|
||||||
|
@if [ -e .editorconfig* ] && [ -x $(NPM_BIN)/lintspaces ]; then \
|
||||||
|
git ls-files | xargs lintspaces -e .editorconfig && $(TASK_DONE); \
|
||||||
|
fi
|
||||||
|
|
||||||
|
verify-coverage:
|
||||||
|
@if [ -d coverage ]; then \
|
||||||
|
if [ -x $(NPM_BIN)/nyc ]; then \
|
||||||
|
nyc check-coverage --lines $(EXPECTED_COVERAGE) --functions $(EXPECTED_COVERAGE) --branches $(EXPECTED_COVERAGE) && $(TASK_DONE); \
|
||||||
|
else \
|
||||||
|
if [ -x $(NPM_BIN)/istanbul ]; then \
|
||||||
|
istanbul check-coverage --statement $(EXPECTED_COVERAGE) --branch $(EXPECTED_COVERAGE) --function $(EXPECTED_COVERAGE) && $(TASK_DONE); \
|
||||||
|
fi \
|
||||||
|
fi \
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Test tasks
|
||||||
|
# ----------
|
||||||
|
|
||||||
|
test: test-unit-coverage verify-coverage test-integration
|
||||||
|
@$(TASK_DONE)
|
||||||
|
|
||||||
|
test-unit:
|
||||||
|
@if [ -d test/unit ]; then mocha test/unit --recursive && $(TASK_DONE); fi
|
||||||
|
|
||||||
|
test-unit-coverage:
|
||||||
|
@if [ -d test/unit ]; then \
|
||||||
|
if [ -x $(NPM_BIN)/nyc ]; then \
|
||||||
|
nyc --reporter=text --reporter=html $(NPM_BIN)/_mocha test/unit --recursive && $(TASK_DONE); \
|
||||||
|
else \
|
||||||
|
if [ -x $(NPM_BIN)/istanbul ]; then \
|
||||||
|
istanbul cover $(NPM_BIN)/_mocha -- test/unit --recursive && $(TASK_DONE); \
|
||||||
|
else \
|
||||||
|
make test-unit; \
|
||||||
|
fi \
|
||||||
|
fi \
|
||||||
|
fi
|
||||||
|
|
||||||
|
test-integration:
|
||||||
|
@if [ -d test/integration ]; then mocha test/integration --timeout $(INTEGRATION_TIMEOUT) --slow $(INTEGRATION_SLOW) $(INTEGRATION_FLAGS) && $(TASK_DONE); fi
|
||||||
|
|
||||||
|
|
||||||
|
# Tooling tasks
|
||||||
|
# -------------
|
||||||
|
|
||||||
|
update-makefile:
|
||||||
|
@curl -s https://raw.githubusercontent.com/rowanmanning/makefiles/master/Makefile.node > Makefile.node
|
||||||
|
@$(TASK_DONE)
|
14
README.md
14
README.md
@@ -87,24 +87,20 @@ Contributing
|
|||||||
|
|
||||||
There are many ways to contribute to Pa11y Dashboard, we cover these in the [contributing guide](CONTRIBUTING.md) for this repo.
|
There are many ways to contribute to Pa11y Dashboard, we cover these in the [contributing guide](CONTRIBUTING.md) for this repo.
|
||||||
|
|
||||||
If you're ready to contribute some code, you'll need to clone the repo and get set up as outlined in the [setup guide](#setup).
|
If you're ready to contribute some code, you'll need to clone the repo and get set up as outlined in the [setup guide](#setup). You'll then need to start the application in test mode with:
|
||||||
|
|
||||||
You'll need to start the application in test mode with:
|
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
NODE_ENV=test node index.js
|
NODE_ENV=test node index.js
|
||||||
```
|
```
|
||||||
|
|
||||||
Now you'll be able to run the following commands:
|
You'll now be able to run the following commands:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
make # Run the lint and test tasks together
|
make verify # Verify all of the code (ESLint)
|
||||||
make lint # Run linters with the correct config
|
make test # Run all tests
|
||||||
make test # Run integration tests
|
make test-integration # Run the integration tests
|
||||||
```
|
```
|
||||||
|
|
||||||
Code with lint errors or failing tests will not be accepted, please use the build tools outlined above.
|
|
||||||
|
|
||||||
To compile the client-side JavaScript and CSS, you'll need the following commands. Compiled code is committed to the repository.
|
To compile the client-side JavaScript and CSS, you'll need the following commands. Compiled code is committed to the repository.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
33
app.js
33
app.js
@@ -12,7 +12,6 @@
|
|||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
|
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const bodyParser = require('body-parser');
|
const bodyParser = require('body-parser');
|
||||||
@@ -84,9 +83,9 @@ function initApp(config, callback) {
|
|||||||
settings: {}
|
settings: {}
|
||||||
};
|
};
|
||||||
|
|
||||||
app.express.use((req, res, next) => {
|
app.express.use((request, response, next) => {
|
||||||
res.locals.isHomePage = (req.path === '/');
|
response.locals.isHomePage = (request.path === '/');
|
||||||
res.locals.host = req.hostname;
|
response.locals.host = request.hostname;
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -105,27 +104,27 @@ function initApp(config, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Error handling
|
// Error handling
|
||||||
app.express.get('*', (req, res) => {
|
app.express.get('*', (request, response) => {
|
||||||
res.status(404);
|
response.status(404);
|
||||||
res.render('404');
|
response.render('404');
|
||||||
});
|
});
|
||||||
app.express.use((err, req, res, next) => {
|
app.express.use((error, request, response, next) => {
|
||||||
/* jshint unused: false */
|
/* eslint no-unused-vars: 'off' */
|
||||||
if (err.code === 'ECONNREFUSED') {
|
if (error.code === 'ECONNREFUSED') {
|
||||||
err = new Error('Could not connect to Pa11y Webservice');
|
error = new Error('Could not connect to Pa11y Webservice');
|
||||||
}
|
}
|
||||||
app.emit('route-error', err);
|
app.emit('route-error', error);
|
||||||
if (process.env.NODE_ENV !== 'production') {
|
if (process.env.NODE_ENV !== 'production') {
|
||||||
res.locals.error = err;
|
response.locals.error = error;
|
||||||
}
|
}
|
||||||
res.status(500);
|
response.status(500);
|
||||||
res.render('500');
|
response.render('500');
|
||||||
});
|
});
|
||||||
|
|
||||||
app.server.listen(config.port, err => {
|
app.server.listen(config.port, error => {
|
||||||
const address = app.server.address();
|
const address = app.server.address();
|
||||||
app.address = `http://${address.address}:${address.port}`;
|
app.address = `http://${address.address}:${address.port}`;
|
||||||
callback(err, app);
|
callback(error, app);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -12,7 +12,6 @@
|
|||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
|
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
8
data/.eslintrc.js
Normal file
8
data/.eslintrc.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
// Clone the main config
|
||||||
|
var config = module.exports = JSON.parse(JSON.stringify(require('../.eslintrc')));
|
||||||
|
|
||||||
|
// Disable max line length/statements
|
||||||
|
config.rules['max-len'] = 'off';
|
||||||
|
config.rules['max-statements'] = 'off';
|
18
index.js
18
index.js
@@ -12,7 +12,6 @@
|
|||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
|
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const chalk = require('chalk');
|
const chalk = require('chalk');
|
||||||
@@ -23,15 +22,19 @@ process.on('SIGINT', () => {
|
|||||||
process.exit();
|
process.exit();
|
||||||
});
|
});
|
||||||
|
|
||||||
require('./app')(config, (err, app) => {
|
require('./app')(config, (error, app) => {
|
||||||
|
if (error) {
|
||||||
|
console.error(error.stack);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
console.log('');
|
console.log('');
|
||||||
console.log(chalk.underline.magenta('Pa11y Dashboard started'));
|
console.log(chalk.underline.magenta('Pa11y Dashboard started'));
|
||||||
console.log(chalk.grey('mode: %s'), process.env.NODE_ENV);
|
console.log(chalk.grey('mode: %s'), process.env.NODE_ENV);
|
||||||
console.log(chalk.grey('uri: %s'), app.address);
|
console.log(chalk.grey('uri: %s'), app.address);
|
||||||
|
|
||||||
app.on('route-error', err => {
|
app.on('route-error', error => {
|
||||||
const stack = (err.stack ? err.stack.split('\n') : [err.message]);
|
const stack = (error.stack ? error.stack.split('\n') : [error.message]);
|
||||||
const msg = chalk.red(stack.shift());
|
const msg = chalk.red(stack.shift());
|
||||||
console.error('');
|
console.error('');
|
||||||
console.error(msg);
|
console.error(msg);
|
||||||
@@ -40,7 +43,12 @@ require('./app')(config, (err, app) => {
|
|||||||
|
|
||||||
// Start the webservice if required
|
// Start the webservice if required
|
||||||
if (typeof config.webservice === 'object') {
|
if (typeof config.webservice === 'object') {
|
||||||
require('pa11y-webservice')(config.webservice, (err, webservice) => {
|
require('pa11y-webservice')(config.webservice, (error, webservice) => {
|
||||||
|
if (error) {
|
||||||
|
console.error(error.stack);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
console.log('');
|
console.log('');
|
||||||
console.log(chalk.underline.cyan('Pa11y Webservice started'));
|
console.log(chalk.underline.cyan('Pa11y Webservice started'));
|
||||||
console.log(chalk.grey('mode: %s'), process.env.NODE_ENV);
|
console.log(chalk.grey('mode: %s'), process.env.NODE_ENV);
|
||||||
|
@@ -38,10 +38,10 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"bower": "~1.7",
|
"bower": "~1.7",
|
||||||
"cheerio": "~0.20",
|
"cheerio": "~0.20",
|
||||||
"jscs": "^2",
|
"eslint": "^3.18.0",
|
||||||
"jshint": "^2",
|
|
||||||
"less": "~2.7",
|
"less": "~2.7",
|
||||||
"mocha": "^2",
|
"mocha": "^2",
|
||||||
|
"pa11y-lint-config": "^1.0.0",
|
||||||
"proclaim": "^3",
|
"proclaim": "^3",
|
||||||
"request": "^2.74",
|
"request": "^2.74",
|
||||||
"uglify-js": "~2.6"
|
"uglify-js": "~2.6"
|
||||||
|
@@ -12,7 +12,6 @@
|
|||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
|
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const presentTask = require('../view/presenter/task');
|
const presentTask = require('../view/presenter/task');
|
||||||
@@ -21,14 +20,14 @@ module.exports = route;
|
|||||||
|
|
||||||
// Route definition
|
// Route definition
|
||||||
function route(app) {
|
function route(app) {
|
||||||
app.express.get('/', (req, res, next) => {
|
app.express.get('/', (request, response, next) => {
|
||||||
app.webservice.tasks.get({lastres: true}, (err, tasks) => {
|
app.webservice.tasks.get({lastres: true}, (error, tasks) => {
|
||||||
if (err) {
|
if (error) {
|
||||||
return next(err);
|
return next(error);
|
||||||
}
|
}
|
||||||
res.render('index', {
|
response.render('index', {
|
||||||
tasks: tasks.map(presentTask),
|
tasks: tasks.map(presentTask),
|
||||||
deleted: (typeof req.query.deleted !== 'undefined'),
|
deleted: (typeof request.query.deleted !== 'undefined'),
|
||||||
isHomePage: true
|
isHomePage: true
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
49
route/new.js
49
route/new.js
@@ -12,9 +12,6 @@
|
|||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
|
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/*jshint maxcomplexity:10*/
|
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const getStandards = require('../data/standards');
|
const getStandards = require('../data/standards');
|
||||||
@@ -25,24 +22,24 @@ module.exports = route;
|
|||||||
// Route definition
|
// Route definition
|
||||||
function route(app) {
|
function route(app) {
|
||||||
|
|
||||||
app.express.get('/new', (req, res) => {
|
app.express.get('/new', (request, response) => {
|
||||||
const standards = getStandards().map(standard => {
|
const standards = getStandards().map(standard => {
|
||||||
if (standard.title === 'WCAG2AA') {
|
if (standard.title === 'WCAG2AA') {
|
||||||
standard.selected = true;
|
standard.selected = true;
|
||||||
}
|
}
|
||||||
return standard;
|
return standard;
|
||||||
});
|
});
|
||||||
res.render('new', {
|
response.render('new', {
|
||||||
standards: standards,
|
standards: standards,
|
||||||
isNewTaskPage: true
|
isNewTaskPage: true
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.express.post('/new', (req, res) => {
|
app.express.post('/new', (request, response) => {
|
||||||
|
|
||||||
let parsedActions;
|
let parsedActions;
|
||||||
if (req.body.actions) {
|
if (request.body.actions) {
|
||||||
parsedActions = req.body.actions.split(/[\r\n]+/)
|
parsedActions = request.body.actions.split(/[\r\n]+/)
|
||||||
.map(action => {
|
.map(action => {
|
||||||
return action.trim();
|
return action.trim();
|
||||||
})
|
})
|
||||||
@@ -52,26 +49,26 @@ function route(app) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let parsedHeaders;
|
let parsedHeaders;
|
||||||
if (req.body.headers) {
|
if (request.body.headers) {
|
||||||
parsedHeaders = httpHeaders(req.body.headers, true);
|
parsedHeaders = httpHeaders(request.body.headers, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
const newTask = {
|
const newTask = {
|
||||||
name: req.body.name,
|
name: request.body.name,
|
||||||
url: req.body.url,
|
url: request.body.url,
|
||||||
standard: req.body.standard,
|
standard: request.body.standard,
|
||||||
ignore: req.body.ignore || [],
|
ignore: request.body.ignore || [],
|
||||||
timeout: req.body.timeout || undefined,
|
timeout: request.body.timeout || undefined,
|
||||||
wait: req.body.wait || undefined,
|
wait: request.body.wait || undefined,
|
||||||
actions: parsedActions,
|
actions: parsedActions,
|
||||||
username: req.body.username || undefined,
|
username: request.body.username || undefined,
|
||||||
password: req.body.password || undefined,
|
password: request.body.password || undefined,
|
||||||
headers: parsedHeaders,
|
headers: parsedHeaders,
|
||||||
hideElements: req.body.hideElements || undefined
|
hideElements: request.body.hideElements || undefined
|
||||||
};
|
};
|
||||||
|
|
||||||
app.webservice.tasks.create(newTask, (err, task) => {
|
app.webservice.tasks.create(newTask, (error, task) => {
|
||||||
if (err) {
|
if (error) {
|
||||||
const standards = getStandards().map(standard => {
|
const standards = getStandards().map(standard => {
|
||||||
if (standard.title === newTask.standard) {
|
if (standard.title === newTask.standard) {
|
||||||
standard.selected = true;
|
standard.selected = true;
|
||||||
@@ -84,15 +81,15 @@ function route(app) {
|
|||||||
});
|
});
|
||||||
return standard;
|
return standard;
|
||||||
});
|
});
|
||||||
newTask.actions = req.body.actions;
|
newTask.actions = request.body.actions;
|
||||||
newTask.headers = req.body.headers;
|
newTask.headers = request.body.headers;
|
||||||
return res.render('new', {
|
return response.render('new', {
|
||||||
error: err,
|
error: error,
|
||||||
standards: standards,
|
standards: standards,
|
||||||
task: newTask
|
task: newTask
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
res.redirect(`/${task.id}?added`);
|
response.redirect(`/${task.id}?added`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -12,7 +12,6 @@
|
|||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
|
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const moment = require('moment');
|
const moment = require('moment');
|
||||||
@@ -22,20 +21,20 @@ module.exports = route;
|
|||||||
// Route definition
|
// Route definition
|
||||||
function route(app) {
|
function route(app) {
|
||||||
|
|
||||||
function getTaskAndResult(req, res, next) {
|
function getTaskAndResult(request, response, next) {
|
||||||
app.webservice.task(req.params.id).get({}, (err, task) => {
|
app.webservice.task(request.params.id).get({}, (error, task) => {
|
||||||
if (err) {
|
if (error) {
|
||||||
return next('route');
|
return next('route');
|
||||||
}
|
}
|
||||||
app.webservice
|
app.webservice
|
||||||
.task(req.params.id)
|
.task(request.params.id)
|
||||||
.result(req.params.rid)
|
.result(request.params.rid)
|
||||||
.get({full: true}, (err, result) => {
|
.get({full: true}, (error, result) => {
|
||||||
if (err) {
|
if (error) {
|
||||||
return next('route');
|
return next('route');
|
||||||
}
|
}
|
||||||
res.locals.task = task;
|
response.locals.task = task;
|
||||||
res.locals.result = result;
|
response.locals.result = result;
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -48,7 +47,7 @@ function route(app) {
|
|||||||
task.url
|
task.url
|
||||||
.replace(/^https?:\/\//i, '')
|
.replace(/^https?:\/\//i, '')
|
||||||
.replace(/\/$/, '')
|
.replace(/\/$/, '')
|
||||||
.replace(/[^a-z0-9\.\-\_]+/gi, '-'),
|
.replace(/[^a-z0-9.\-_]+/gi, '-'),
|
||||||
'--',
|
'--',
|
||||||
task.standard.toLowerCase(),
|
task.standard.toLowerCase(),
|
||||||
'--',
|
'--',
|
||||||
@@ -58,9 +57,9 @@ function route(app) {
|
|||||||
].join('');
|
].join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
app.express.get('/:id/:rid.csv', getTaskAndResult, (req, res) => {
|
app.express.get('/:id/:rid.csv', getTaskAndResult, (request, response) => {
|
||||||
const task = res.locals.task;
|
const task = response.locals.task;
|
||||||
const result = res.locals.result;
|
const result = response.locals.result;
|
||||||
const rows = ['"code","message","type","context","selector"'];
|
const rows = ['"code","message","type","context","selector"'];
|
||||||
result.results.forEach(msg => {
|
result.results.forEach(msg => {
|
||||||
rows.push([
|
rows.push([
|
||||||
@@ -71,18 +70,18 @@ function route(app) {
|
|||||||
JSON.stringify(msg.selector)
|
JSON.stringify(msg.selector)
|
||||||
].join(','));
|
].join(','));
|
||||||
});
|
});
|
||||||
res.attachment(getDownloadFileName(task, result, 'csv'));
|
response.attachment(getDownloadFileName(task, result, 'csv'));
|
||||||
res.send(rows.join('\n'));
|
response.send(rows.join('\n'));
|
||||||
});
|
});
|
||||||
|
|
||||||
app.express.get('/:id/:rid.json', getTaskAndResult, (req, res) => {
|
app.express.get('/:id/:rid.json', getTaskAndResult, (request, response) => {
|
||||||
const task = res.locals.task;
|
const task = response.locals.task;
|
||||||
const result = res.locals.result;
|
const result = response.locals.result;
|
||||||
res.attachment(getDownloadFileName(task, result, 'json'));
|
response.attachment(getDownloadFileName(task, result, 'json'));
|
||||||
delete task.id;
|
delete task.id;
|
||||||
delete result.id;
|
delete result.id;
|
||||||
result.task = task;
|
result.task = task;
|
||||||
res.send(result);
|
response.send(result);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -12,7 +12,6 @@
|
|||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
|
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const presentTask = require('../../view/presenter/task');
|
const presentTask = require('../../view/presenter/task');
|
||||||
@@ -23,19 +22,19 @@ module.exports = route;
|
|||||||
// Route definition
|
// Route definition
|
||||||
function route(app) {
|
function route(app) {
|
||||||
|
|
||||||
app.express.get('/:id/:rid', (req, res, next) => {
|
app.express.get('/:id/:rid', (request, response, next) => {
|
||||||
app.webservice.task(req.params.id).get({}, (err, task) => {
|
app.webservice.task(request.params.id).get({}, (error, task) => {
|
||||||
if (err) {
|
if (error) {
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
app.webservice
|
app.webservice
|
||||||
.task(req.params.id)
|
.task(request.params.id)
|
||||||
.result(req.params.rid)
|
.result(request.params.rid)
|
||||||
.get({full: true}, (err, result) => {
|
.get({full: true}, (error, result) => {
|
||||||
if (err) {
|
if (error) {
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
res.render('result', {
|
response.render('result', {
|
||||||
task: presentTask(task),
|
task: presentTask(task),
|
||||||
mainResult: presentResult(result),
|
mainResult: presentResult(result),
|
||||||
isResultPage: true
|
isResultPage: true
|
||||||
|
@@ -12,7 +12,6 @@
|
|||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
|
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const presentTask = require('../../view/presenter/task');
|
const presentTask = require('../../view/presenter/task');
|
||||||
@@ -22,24 +21,24 @@ module.exports = route;
|
|||||||
// Route definition
|
// Route definition
|
||||||
function route(app) {
|
function route(app) {
|
||||||
|
|
||||||
app.express.get('/:id/delete', (req, res, next) => {
|
app.express.get('/:id/delete', (request, response, next) => {
|
||||||
app.webservice.task(req.params.id).get({}, (err, task) => {
|
app.webservice.task(request.params.id).get({}, (error, task) => {
|
||||||
if (err) {
|
if (error) {
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
res.render('task/delete', {
|
response.render('task/delete', {
|
||||||
task: presentTask(task),
|
task: presentTask(task),
|
||||||
isTaskSubPage: true
|
isTaskSubPage: true
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.express.post('/:id/delete', (req, res, next) => {
|
app.express.post('/:id/delete', (request, response, next) => {
|
||||||
app.webservice.task(req.params.id).remove(err => {
|
app.webservice.task(request.params.id).remove(error => {
|
||||||
if (err) {
|
if (error) {
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
res.redirect('/?deleted');
|
response.redirect('/?deleted');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -12,9 +12,6 @@
|
|||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
|
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/*jshint maxcomplexity:12*/
|
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const presentTask = require('../../view/presenter/task');
|
const presentTask = require('../../view/presenter/task');
|
||||||
@@ -26,9 +23,9 @@ module.exports = route;
|
|||||||
// Route definition
|
// Route definition
|
||||||
function route(app) {
|
function route(app) {
|
||||||
|
|
||||||
app.express.get('/:id/edit', (req, res, next) => {
|
app.express.get('/:id/edit', (request, response, next) => {
|
||||||
app.webservice.task(req.params.id).get({}, (err, task) => {
|
app.webservice.task(request.params.id).get({}, (error, task) => {
|
||||||
if (err) {
|
if (error) {
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
const standards = getStandards().map(standard => {
|
const standards = getStandards().map(standard => {
|
||||||
@@ -44,8 +41,8 @@ function route(app) {
|
|||||||
return standard;
|
return standard;
|
||||||
});
|
});
|
||||||
task.actions = (task.actions ? task.actions.join('\n') : '');
|
task.actions = (task.actions ? task.actions.join('\n') : '');
|
||||||
res.render('task/edit', {
|
response.render('task/edit', {
|
||||||
edited: (typeof req.query.edited !== 'undefined'),
|
edited: (typeof request.query.edited !== 'undefined'),
|
||||||
standards: standards,
|
standards: standards,
|
||||||
task: presentTask(task),
|
task: presentTask(task),
|
||||||
isTaskSubPage: true
|
isTaskSubPage: true
|
||||||
@@ -53,18 +50,18 @@ function route(app) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.express.post('/:id/edit', (req, res, next) => {
|
app.express.post('/:id/edit', (request, response, next) => {
|
||||||
app.webservice.task(req.params.id).get({}, (err, task) => {
|
app.webservice.task(request.params.id).get({}, (error, task) => {
|
||||||
if (err) {
|
if (error) {
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
const originalActions = req.body.actions;
|
const originalActions = request.body.actions;
|
||||||
const originalHeaders = req.body.headers;
|
const originalHeaders = request.body.headers;
|
||||||
req.body.ignore = req.body.ignore || [];
|
request.body.ignore = request.body.ignore || [];
|
||||||
req.body.timeout = req.body.timeout || undefined;
|
request.body.timeout = request.body.timeout || undefined;
|
||||||
req.body.wait = req.body.wait || undefined;
|
request.body.wait = request.body.wait || undefined;
|
||||||
if (req.body.actions) {
|
if (request.body.actions) {
|
||||||
req.body.actions = req.body.actions.split(/[\r\n]+/)
|
request.body.actions = request.body.actions.split(/[\r\n]+/)
|
||||||
.map(action => {
|
.map(action => {
|
||||||
return action.trim();
|
return action.trim();
|
||||||
})
|
})
|
||||||
@@ -72,24 +69,24 @@ function route(app) {
|
|||||||
return Boolean(action);
|
return Boolean(action);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (!req.body.actions) {
|
if (!request.body.actions) {
|
||||||
req.body.actions = [];
|
request.body.actions = [];
|
||||||
}
|
}
|
||||||
req.body.username = req.body.username || undefined;
|
request.body.username = request.body.username || undefined;
|
||||||
req.body.password = req.body.password || undefined;
|
request.body.password = request.body.password || undefined;
|
||||||
req.body.hideElements = req.body.hideElements || undefined;
|
request.body.hideElements = request.body.hideElements || undefined;
|
||||||
req.body.headers = httpHeaders(req.body.headers || '', true);
|
request.body.headers = httpHeaders(request.body.headers || '', true);
|
||||||
app.webservice.task(req.params.id).edit(req.body, err => {
|
app.webservice.task(request.params.id).edit(request.body, error => {
|
||||||
if (err) {
|
if (error) {
|
||||||
task.name = req.body.name;
|
task.name = request.body.name;
|
||||||
task.ignore = req.body.ignore;
|
task.ignore = request.body.ignore;
|
||||||
task.timeout = req.body.timeout;
|
task.timeout = request.body.timeout;
|
||||||
task.wait = req.body.wait;
|
task.wait = request.body.wait;
|
||||||
task.actions = originalActions;
|
task.actions = originalActions;
|
||||||
task.username = req.body.username;
|
task.username = request.body.username;
|
||||||
task.password = req.body.password;
|
task.password = request.body.password;
|
||||||
task.headers = originalHeaders;
|
task.headers = originalHeaders;
|
||||||
task.hideElements = req.body.hideElements;
|
task.hideElements = request.body.hideElements;
|
||||||
const standards = getStandards().map(standard => {
|
const standards = getStandards().map(standard => {
|
||||||
if (standard.title === task.standard) {
|
if (standard.title === task.standard) {
|
||||||
standard.selected = true;
|
standard.selected = true;
|
||||||
@@ -102,14 +99,14 @@ function route(app) {
|
|||||||
});
|
});
|
||||||
return standard;
|
return standard;
|
||||||
});
|
});
|
||||||
return res.render('task/edit', {
|
return response.render('task/edit', {
|
||||||
error: err,
|
error: error,
|
||||||
standards: standards,
|
standards: standards,
|
||||||
task: task,
|
task: task,
|
||||||
isTaskSubPage: true
|
isTaskSubPage: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
res.redirect(`/${req.params.id}/edit?edited`);
|
response.redirect(`/${request.params.id}/edit?edited`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -5,20 +5,20 @@ module.exports = route;
|
|||||||
// Route definition
|
// Route definition
|
||||||
function route(app) {
|
function route(app) {
|
||||||
|
|
||||||
app.express.post('/:id/ignore', (req, res, next) => {
|
app.express.post('/:id/ignore', (request, response, next) => {
|
||||||
app.webservice.task(req.params.id).get({}, (err, task) => {
|
app.webservice.task(request.params.id).get({}, (error, task) => {
|
||||||
if (err) {
|
if (error) {
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
const edit = {
|
const edit = {
|
||||||
name: task.name,
|
name: task.name,
|
||||||
ignore: task.ignore
|
ignore: task.ignore
|
||||||
};
|
};
|
||||||
if (typeof req.body.rule === 'string') {
|
if (typeof request.body.rule === 'string') {
|
||||||
edit.ignore.push(req.body.rule);
|
edit.ignore.push(request.body.rule);
|
||||||
}
|
}
|
||||||
app.webservice.task(req.params.id).edit(edit, () => {
|
app.webservice.task(request.params.id).edit(edit, () => {
|
||||||
res.redirect(`/${req.params.id}?rule-ignored`);
|
response.redirect(`/${request.params.id}?rule-ignored`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -12,7 +12,6 @@
|
|||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
|
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const presentTask = require('../../view/presenter/task');
|
const presentTask = require('../../view/presenter/task');
|
||||||
@@ -24,24 +23,24 @@ module.exports = route;
|
|||||||
// Route definition
|
// Route definition
|
||||||
function route(app) {
|
function route(app) {
|
||||||
|
|
||||||
app.express.get('/:id', (req, res, next) => {
|
app.express.get('/:id', (request, response, next) => {
|
||||||
app.webservice.task(req.params.id).get({lastres: true}, (err, task) => {
|
app.webservice.task(request.params.id).get({lastres: true}, (error, task) => {
|
||||||
if (err) {
|
if (error) {
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
app.webservice.task(req.params.id).results({}, (err, results) => {
|
app.webservice.task(request.params.id).results({}, (error, results) => {
|
||||||
if (err) {
|
if (error) {
|
||||||
return next(err);
|
return next(error);
|
||||||
}
|
}
|
||||||
const presentedResults = presentResultList(results.map(presentResult));
|
const presentedResults = presentResultList(results.map(presentResult));
|
||||||
res.render('task', {
|
response.render('task', {
|
||||||
task: presentTask(task),
|
task: presentTask(task),
|
||||||
results: presentedResults,
|
results: presentedResults,
|
||||||
mainResult: task.lastResult || null,
|
mainResult: task.lastResult || null,
|
||||||
added: (typeof req.query.added !== 'undefined'),
|
added: (typeof request.query.added !== 'undefined'),
|
||||||
running: (typeof req.query.running !== 'undefined'),
|
running: (typeof request.query.running !== 'undefined'),
|
||||||
ruleIgnored: (typeof req.query['rule-ignored'] !== 'undefined'),
|
ruleIgnored: (typeof request.query['rule-ignored'] !== 'undefined'),
|
||||||
ruleUnignored: (typeof req.query['rule-unignored'] !== 'undefined'),
|
ruleUnignored: (typeof request.query['rule-unignored'] !== 'undefined'),
|
||||||
hasOneResult: (presentedResults.length < 2),
|
hasOneResult: (presentedResults.length < 2),
|
||||||
isTaskPage: true
|
isTaskPage: true
|
||||||
});
|
});
|
||||||
|
@@ -12,7 +12,6 @@
|
|||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
|
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
module.exports = route;
|
module.exports = route;
|
||||||
@@ -20,12 +19,12 @@ module.exports = route;
|
|||||||
// Route definition
|
// Route definition
|
||||||
function route(app) {
|
function route(app) {
|
||||||
|
|
||||||
app.express.get('/:id/run', (req, res, next) => {
|
app.express.get('/:id/run', (request, response, next) => {
|
||||||
app.webservice.task(req.params.id).run(err => {
|
app.webservice.task(request.params.id).run(error => {
|
||||||
if (err) {
|
if (error) {
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
res.redirect(`/${req.params.id}?running`);
|
response.redirect(`/${request.params.id}?running`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -5,21 +5,21 @@ module.exports = route;
|
|||||||
// Route definition
|
// Route definition
|
||||||
function route(app) {
|
function route(app) {
|
||||||
|
|
||||||
app.express.post('/:id/unignore', (req, res, next) => {
|
app.express.post('/:id/unignore', (request, response, next) => {
|
||||||
app.webservice.task(req.params.id).get({}, (err, task) => {
|
app.webservice.task(request.params.id).get({}, (error, task) => {
|
||||||
if (err) {
|
if (error) {
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
const edit = {
|
const edit = {
|
||||||
name: task.name,
|
name: task.name,
|
||||||
ignore: task.ignore
|
ignore: task.ignore
|
||||||
};
|
};
|
||||||
const indexOfRule = edit.ignore.indexOf(req.body.rule);
|
const indexOfRule = edit.ignore.indexOf(request.body.rule);
|
||||||
if (typeof req.body.rule === 'string' && indexOfRule !== -1) {
|
if (typeof request.body.rule === 'string' && indexOfRule !== -1) {
|
||||||
edit.ignore.splice(indexOfRule, 1);
|
edit.ignore.splice(indexOfRule, 1);
|
||||||
}
|
}
|
||||||
app.webservice.task(req.params.id).edit(edit, () => {
|
app.webservice.task(request.params.id).edit(edit, () => {
|
||||||
res.redirect(`/${req.params.id}?rule-unignored`);
|
response.redirect(`/${request.params.id}?rule-unignored`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
15
test/.eslintrc.js
Normal file
15
test/.eslintrc.js
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
// Clone the main config
|
||||||
|
var config = module.exports = JSON.parse(JSON.stringify(require('../.eslintrc')));
|
||||||
|
|
||||||
|
// We use `this` all over the integration tests
|
||||||
|
config.rules['no-invalid-this'] = 'off';
|
||||||
|
|
||||||
|
// Because of our use of `this`, arrow functions
|
||||||
|
// aren't really gonna work in the integration tests
|
||||||
|
config.rules['prefer-arrow-callback'] = 'off';
|
||||||
|
|
||||||
|
// Disable max line length/statements
|
||||||
|
config.rules['max-len'] = 'off';
|
||||||
|
config.rules['max-statements'] = 'off';
|
@@ -38,12 +38,15 @@ function createNavigator(baseUrl, store) {
|
|||||||
json: opts.json || false,
|
json: opts.json || false,
|
||||||
qs: opts.query,
|
qs: opts.query,
|
||||||
followAllRedirects: true
|
followAllRedirects: true
|
||||||
}, function(err, res, body) {
|
}, function(error, response, body) {
|
||||||
|
if (error) {
|
||||||
|
return callback(error);
|
||||||
|
}
|
||||||
|
|
||||||
store.body = body;
|
store.body = body;
|
||||||
store.request = res.request;
|
store.request = response.request;
|
||||||
store.response = res;
|
store.response = response;
|
||||||
store.status = res.statusCode;
|
store.status = response.statusCode;
|
||||||
|
|
||||||
if (opts.nonDom) {
|
if (opts.nonDom) {
|
||||||
store.dom = null;
|
store.dom = null;
|
||||||
|
@@ -21,11 +21,11 @@ const assert = require('proclaim');
|
|||||||
describe.only('GET /', function() {
|
describe.only('GET /', function() {
|
||||||
|
|
||||||
beforeEach(function(done) {
|
beforeEach(function(done) {
|
||||||
const req = {
|
const request = {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
endpoint: '/'
|
endpoint: '/'
|
||||||
};
|
};
|
||||||
this.navigate(req, done);
|
this.navigate(request, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should send a 200 status', function() {
|
it('should send a 200 status', function() {
|
||||||
|
@@ -21,11 +21,11 @@ const assert = require('proclaim');
|
|||||||
describe('GET /new', function() {
|
describe('GET /new', function() {
|
||||||
|
|
||||||
beforeEach(function(done) {
|
beforeEach(function(done) {
|
||||||
const req = {
|
const request = {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
endpoint: '/new'
|
endpoint: '/new'
|
||||||
};
|
};
|
||||||
this.navigate(req, done);
|
this.navigate(request, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should send a 200 status', function() {
|
it('should send a 200 status', function() {
|
||||||
@@ -122,7 +122,7 @@ describe('POST /new', function() {
|
|||||||
describe('with invalid query', function() {
|
describe('with invalid query', function() {
|
||||||
|
|
||||||
beforeEach(function(done) {
|
beforeEach(function(done) {
|
||||||
const req = {
|
const request = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
endpoint: '/new',
|
endpoint: '/new',
|
||||||
form: {
|
form: {
|
||||||
@@ -130,7 +130,7 @@ describe('POST /new', function() {
|
|||||||
url: ''
|
url: ''
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.navigate(req, done);
|
this.navigate(request, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should send a 200 status', function() {
|
it('should send a 200 status', function() {
|
||||||
@@ -146,7 +146,7 @@ describe('POST /new', function() {
|
|||||||
describe('with valid query', function() {
|
describe('with valid query', function() {
|
||||||
|
|
||||||
beforeEach(function(done) {
|
beforeEach(function(done) {
|
||||||
const req = {
|
const request = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
endpoint: '/new',
|
endpoint: '/new',
|
||||||
form: {
|
form: {
|
||||||
@@ -155,7 +155,7 @@ describe('POST /new', function() {
|
|||||||
standard: 'WCAG2AA'
|
standard: 'WCAG2AA'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.navigate(req, done);
|
this.navigate(request, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should send a 200 status', function() {
|
it('should send a 200 status', function() {
|
||||||
@@ -163,9 +163,9 @@ describe('POST /new', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should create the task', function(done) {
|
it('should create the task', function(done) {
|
||||||
this.webservice.tasks.get({}, function(err, tasks) {
|
this.webservice.tasks.get({}, function(error, tasks) {
|
||||||
assert.strictEqual(tasks.length, 4);
|
assert.strictEqual(tasks.length, 4);
|
||||||
done();
|
done(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -21,12 +21,12 @@ const assert = require('proclaim');
|
|||||||
describe('GET /<task-id>/<result-id>.csv', function() {
|
describe('GET /<task-id>/<result-id>.csv', function() {
|
||||||
|
|
||||||
beforeEach(function(done) {
|
beforeEach(function(done) {
|
||||||
const req = {
|
const request = {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
endpoint: '/abc000000000000000000001/def000000000000000000001.csv',
|
endpoint: '/abc000000000000000000001/def000000000000000000001.csv',
|
||||||
nonDom: true
|
nonDom: true
|
||||||
};
|
};
|
||||||
this.navigate(req, done);
|
this.navigate(request, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should send a 200 status', function() {
|
it('should send a 200 status', function() {
|
||||||
@@ -42,13 +42,13 @@ describe('GET /<task-id>/<result-id>.csv', function() {
|
|||||||
describe('GET /<task-id>/<result-id>.json', function() {
|
describe('GET /<task-id>/<result-id>.json', function() {
|
||||||
|
|
||||||
beforeEach(function(done) {
|
beforeEach(function(done) {
|
||||||
const req = {
|
const request = {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
endpoint: '/abc000000000000000000001/def000000000000000000001.json',
|
endpoint: '/abc000000000000000000001/def000000000000000000001.json',
|
||||||
nonDom: true,
|
nonDom: true,
|
||||||
json: true
|
json: true
|
||||||
};
|
};
|
||||||
this.navigate(req, done);
|
this.navigate(request, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should send a 200 status', function() {
|
it('should send a 200 status', function() {
|
||||||
|
@@ -21,11 +21,11 @@ const assert = require('proclaim');
|
|||||||
describe('GET /<task-id>/<result-id>', function() {
|
describe('GET /<task-id>/<result-id>', function() {
|
||||||
|
|
||||||
beforeEach(function(done) {
|
beforeEach(function(done) {
|
||||||
const req = {
|
const request = {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
endpoint: '/abc000000000000000000001/def000000000000000000001'
|
endpoint: '/abc000000000000000000001/def000000000000000000001'
|
||||||
};
|
};
|
||||||
this.navigate(req, done);
|
this.navigate(request, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should send a 200 status', function() {
|
it('should send a 200 status', function() {
|
||||||
|
@@ -21,11 +21,11 @@ const assert = require('proclaim');
|
|||||||
describe('GET /<task-id>/delete', function() {
|
describe('GET /<task-id>/delete', function() {
|
||||||
|
|
||||||
beforeEach(function(done) {
|
beforeEach(function(done) {
|
||||||
const req = {
|
const request = {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
endpoint: '/abc000000000000000000001/delete'
|
endpoint: '/abc000000000000000000001/delete'
|
||||||
};
|
};
|
||||||
this.navigate(req, done);
|
this.navigate(request, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should send a 200 status', function() {
|
it('should send a 200 status', function() {
|
||||||
@@ -48,11 +48,11 @@ describe('GET /<task-id>/delete', function() {
|
|||||||
describe('POST /<task-id>/delete', function() {
|
describe('POST /<task-id>/delete', function() {
|
||||||
|
|
||||||
beforeEach(function(done) {
|
beforeEach(function(done) {
|
||||||
const req = {
|
const request = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
endpoint: '/abc000000000000000000001/delete'
|
endpoint: '/abc000000000000000000001/delete'
|
||||||
};
|
};
|
||||||
this.navigate(req, done);
|
this.navigate(request, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should send a 200 status', function() {
|
it('should send a 200 status', function() {
|
||||||
@@ -60,8 +60,8 @@ describe('POST /<task-id>/delete', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should delete the task', function(done) {
|
it('should delete the task', function(done) {
|
||||||
this.webservice.task('abc000000000000000000001').get({}, function(err) {
|
this.webservice.task('abc000000000000000000001').get({}, function(error) {
|
||||||
assert.strictEqual(err.message, 'Error 404');
|
assert.strictEqual(error.message, 'Error 404');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -21,11 +21,11 @@ const assert = require('proclaim');
|
|||||||
describe('GET /<task-id>/edit', function() {
|
describe('GET /<task-id>/edit', function() {
|
||||||
|
|
||||||
beforeEach(function(done) {
|
beforeEach(function(done) {
|
||||||
const req = {
|
const request = {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
endpoint: '/abc000000000000000000001/edit'
|
endpoint: '/abc000000000000000000001/edit'
|
||||||
};
|
};
|
||||||
this.navigate(req, done);
|
this.navigate(request, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should send a 200 status', function() {
|
it('should send a 200 status', function() {
|
||||||
@@ -121,7 +121,7 @@ describe('GET /<task-id>/edit', function() {
|
|||||||
describe('POST /<task-id>/edit', function() {
|
describe('POST /<task-id>/edit', function() {
|
||||||
|
|
||||||
beforeEach(function(done) {
|
beforeEach(function(done) {
|
||||||
const req = {
|
const request = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
endpoint: '/abc000000000000000000001/edit',
|
endpoint: '/abc000000000000000000001/edit',
|
||||||
form: {
|
form: {
|
||||||
@@ -131,7 +131,7 @@ describe('POST /<task-id>/edit', function() {
|
|||||||
ignore: ['bar', 'baz']
|
ignore: ['bar', 'baz']
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.navigate(req, done);
|
this.navigate(request, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should send a 200 status', function() {
|
it('should send a 200 status', function() {
|
||||||
@@ -139,12 +139,12 @@ describe('POST /<task-id>/edit', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should edit the task', function(done) {
|
it('should edit the task', function(done) {
|
||||||
this.webservice.task('abc000000000000000000001').get({}, function(err, task) {
|
this.webservice.task('abc000000000000000000001').get({}, function(error, task) {
|
||||||
assert.strictEqual(task.name, 'foo');
|
assert.strictEqual(task.name, 'foo');
|
||||||
assert.strictEqual(task.username, 'newuser');
|
assert.strictEqual(task.username, 'newuser');
|
||||||
assert.strictEqual(task.password, 'secure');
|
assert.strictEqual(task.password, 'secure');
|
||||||
assert.deepEqual(task.ignore, ['bar', 'baz']);
|
assert.deepEqual(task.ignore, ['bar', 'baz']);
|
||||||
done();
|
done(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -23,11 +23,11 @@ describe('GET /<task-id>', function() {
|
|||||||
describe('when task has results', function() {
|
describe('when task has results', function() {
|
||||||
|
|
||||||
beforeEach(function(done) {
|
beforeEach(function(done) {
|
||||||
const req = {
|
const request = {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
endpoint: '/abc000000000000000000001'
|
endpoint: '/abc000000000000000000001'
|
||||||
};
|
};
|
||||||
this.navigate(req, done);
|
this.navigate(request, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should send a 200 status', function() {
|
it('should send a 200 status', function() {
|
||||||
@@ -82,11 +82,11 @@ describe('GET /<task-id>', function() {
|
|||||||
describe('when task has no results', function() {
|
describe('when task has no results', function() {
|
||||||
|
|
||||||
beforeEach(function(done) {
|
beforeEach(function(done) {
|
||||||
const req = {
|
const request = {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
endpoint: '/abc000000000000000000003'
|
endpoint: '/abc000000000000000000003'
|
||||||
};
|
};
|
||||||
this.navigate(req, done);
|
this.navigate(request, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should send a 200 status', function() {
|
it('should send a 200 status', function() {
|
||||||
|
@@ -21,11 +21,11 @@ const assert = require('proclaim');
|
|||||||
describe('GET /<task-id>/run', function() {
|
describe('GET /<task-id>/run', function() {
|
||||||
|
|
||||||
beforeEach(function(done) {
|
beforeEach(function(done) {
|
||||||
const req = {
|
const request = {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
endpoint: '/abc000000000000000000001/run'
|
endpoint: '/abc000000000000000000001/run'
|
||||||
};
|
};
|
||||||
this.navigate(req, done);
|
this.navigate(request, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should send a 200 status', function() {
|
it('should send a 200 status', function() {
|
||||||
|
@@ -40,8 +40,8 @@ afterEach(function(done) {
|
|||||||
|
|
||||||
// Check that the test application is running, and exit if not
|
// Check that the test application is running, and exit if not
|
||||||
function assertTestAppIsRunning(url, done) {
|
function assertTestAppIsRunning(url, done) {
|
||||||
request(url, err => {
|
request(url, error => {
|
||||||
if (err) {
|
if (error) {
|
||||||
console.error('Error: Test app not started; run with `NODE_ENV=test node index.js`');
|
console.error('Error: Test app not started; run with `NODE_ENV=test node index.js`');
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
@@ -12,7 +12,6 @@
|
|||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
|
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const moment = require('moment');
|
const moment = require('moment');
|
||||||
|
@@ -12,7 +12,6 @@
|
|||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
|
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
module.exports = helper;
|
module.exports = helper;
|
||||||
|
@@ -12,7 +12,6 @@
|
|||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
|
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const standardsArray = require('../../data/standards')();
|
const standardsArray = require('../../data/standards')();
|
||||||
|
@@ -12,7 +12,6 @@
|
|||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
|
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const _ = require('underscore');
|
const _ = require('underscore');
|
||||||
|
@@ -12,7 +12,6 @@
|
|||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
|
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const _ = require('underscore');
|
const _ = require('underscore');
|
||||||
|
@@ -12,8 +12,6 @@
|
|||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
|
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const presentIgnoreRules = require('./ignore');
|
const presentIgnoreRules = require('./ignore');
|
||||||
|
Reference in New Issue
Block a user