mirror of
https://github.com/pa11y/pa11y-dashboard.git
synced 2025-09-24 22:31:15 +00:00
Support Node.js 0.10–6 (#132)
* Update dependencies * Switch from jsdom to cheerio * Update the supported Node.js versions * Recompile the client-side CSS and JS
This commit is contained in:

committed by
Andrew Mee

parent
6bfb4f72d9
commit
ae6208d87e
11
.travis.yml
11
.travis.yml
@@ -3,16 +3,11 @@
|
|||||||
language: node_js
|
language: node_js
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
|
|
||||||
# Run tests in Node.js 0.10 (unsupported)
|
|
||||||
- node_js: '0.10'
|
- node_js: '0.10'
|
||||||
|
|
||||||
# Run tests in Node.js 0.12
|
|
||||||
- node_js: '0.12'
|
- node_js: '0.12'
|
||||||
|
- node_js: '4'
|
||||||
# Allow Node.js 0.10 to fail – it's unsupported
|
- node_js: '5'
|
||||||
allow_failures:
|
- node_js: '6'
|
||||||
- node_js: '0.10'
|
|
||||||
|
|
||||||
# Build only master (and pull-requests)
|
# Build only master (and pull-requests)
|
||||||
branches:
|
branches:
|
||||||
|
@@ -138,6 +138,6 @@ Copyright © 2013–2016, Springer Nature
|
|||||||
[info-node]: package.json
|
[info-node]: package.json
|
||||||
[info-build]: https://travis-ci.org/pa11y/pa11y-dashboard
|
[info-build]: https://travis-ci.org/pa11y/pa11y-dashboard
|
||||||
[shield-license]: https://img.shields.io/badge/license-GPL%203.0-blue.svg
|
[shield-license]: https://img.shields.io/badge/license-GPL%203.0-blue.svg
|
||||||
[shield-node]: https://img.shields.io/badge/node.js%20support-0.10-brightgreen.svg
|
[shield-node]: https://img.shields.io/badge/node.js%20support-0.10–6-brightgreen.svg
|
||||||
[shield-version]: https://img.shields.io/badge/version-1.11.0-blue.svg
|
[shield-version]: https://img.shields.io/badge/version-1.11.0-blue.svg
|
||||||
[shield-build]: https://img.shields.io/travis/pa11y/pa11y-dashboard/master.svg
|
[shield-build]: https://img.shields.io/travis/pa11y/pa11y-dashboard/master.svg
|
||||||
|
27
app.js
27
app.js
@@ -15,6 +15,8 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
var bodyParser = require('body-parser');
|
||||||
|
var compression = require('compression');
|
||||||
var createClient = require('pa11y-webservice-client-node');
|
var createClient = require('pa11y-webservice-client-node');
|
||||||
var EventEmitter = require('events').EventEmitter;
|
var EventEmitter = require('events').EventEmitter;
|
||||||
var express = require('express');
|
var express = require('express');
|
||||||
@@ -40,7 +42,7 @@ function initApp(config, callback) {
|
|||||||
app.webservice = createClient(webserviceUrl);
|
app.webservice = createClient(webserviceUrl);
|
||||||
|
|
||||||
// Compression
|
// Compression
|
||||||
app.express.use(express.compress());
|
app.express.use(compression());
|
||||||
|
|
||||||
// Public files
|
// Public files
|
||||||
app.express.use(express.static(__dirname + '/public', {
|
app.express.use(express.static(__dirname + '/public', {
|
||||||
@@ -49,26 +51,28 @@ function initApp(config, callback) {
|
|||||||
|
|
||||||
// General express config
|
// General express config
|
||||||
app.express.disable('x-powered-by');
|
app.express.disable('x-powered-by');
|
||||||
app.express.use(express.bodyParser());
|
app.express.use(bodyParser.urlencoded({
|
||||||
|
extended: true
|
||||||
|
}));
|
||||||
|
|
||||||
// View engine
|
// View engine
|
||||||
app.express.set('views', __dirname + '/view');
|
app.express.engine('html', hbs.express4({
|
||||||
app.express.engine('html', hbs.express3({
|
|
||||||
extname: '.html',
|
extname: '.html',
|
||||||
contentHelperName: 'content',
|
contentHelperName: 'content',
|
||||||
layoutsDir: __dirname + '/view/layout',
|
layoutsDir: __dirname + '/view/layout',
|
||||||
partialsDir: __dirname + '/view/partial',
|
partialsDir: __dirname + '/view/partial',
|
||||||
defaultLayout: __dirname + '/view/layout/default'
|
defaultLayout: __dirname + '/view/layout/default'
|
||||||
}));
|
}));
|
||||||
|
app.express.set('views', __dirname + '/view');
|
||||||
app.express.set('view engine', 'html');
|
app.express.set('view engine', 'html');
|
||||||
|
|
||||||
// View helpers
|
// View helpers
|
||||||
require('./view/helper/date')(hbs.registerHelper);
|
require('./view/helper/date')(hbs);
|
||||||
require('./view/helper/string')(hbs.registerHelper);
|
require('./view/helper/string')(hbs);
|
||||||
require('./view/helper/url')(hbs.registerHelper);
|
require('./view/helper/url')(hbs);
|
||||||
|
|
||||||
// Populate view locals
|
// Populate view locals
|
||||||
app.express.locals({
|
app.express.locals = {
|
||||||
lang: 'en',
|
lang: 'en',
|
||||||
year: (new Date()).getFullYear(),
|
year: (new Date()).getFullYear(),
|
||||||
version: pkg.version,
|
version: pkg.version,
|
||||||
@@ -76,12 +80,13 @@ function initApp(config, callback) {
|
|||||||
bugtracker: pkg.bugs,
|
bugtracker: pkg.bugs,
|
||||||
noindex: config.noindex,
|
noindex: config.noindex,
|
||||||
readonly: config.readonly,
|
readonly: config.readonly,
|
||||||
siteMessage: config.siteMessage
|
siteMessage: config.siteMessage,
|
||||||
});
|
settings: {}
|
||||||
|
};
|
||||||
|
|
||||||
app.express.use(function(req, res, next) {
|
app.express.use(function(req, res, next) {
|
||||||
res.locals.isHomePage = (req.path === '/');
|
res.locals.isHomePage = (req.path === '/');
|
||||||
res.locals.host = req.host;
|
res.locals.host = req.hostname;
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
26
package.json
26
package.json
@@ -21,24 +21,26 @@
|
|||||||
"node": ">=0.10"
|
"node": ">=0.10"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"chalk": "~0.2",
|
"body-parser": "~1.15",
|
||||||
"express": "~3.4",
|
"chalk": "~1.1",
|
||||||
"express-hbs": "~0.2",
|
"compression": "~1.6",
|
||||||
"moment": "~2.2",
|
"express": "~4.13",
|
||||||
"pa11y-webservice": "~1.10",
|
"express-hbs": "~1.0",
|
||||||
"pa11y-webservice-client-node": "~1.1",
|
"moment": "~2.13",
|
||||||
"underscore": "~1.5"
|
"pa11y-webservice": "~1.11",
|
||||||
|
"pa11y-webservice-client-node": "~1.2",
|
||||||
|
"underscore": "~1.8"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"bower": "~1.2",
|
"bower": "~1.7",
|
||||||
|
"cheerio": "~0.20",
|
||||||
"jscs": "^2",
|
"jscs": "^2",
|
||||||
"jsdom": "^3",
|
|
||||||
"jshint": "^2",
|
"jshint": "^2",
|
||||||
"less": "~1.5",
|
"less": "~2.7",
|
||||||
"mocha": "^2",
|
"mocha": "^2",
|
||||||
"proclaim": "^3",
|
"proclaim": "^3",
|
||||||
"request": "~2.27",
|
"request": "^2",
|
||||||
"uglify-js": "~2.4"
|
"uglify-js": "~2.6"
|
||||||
},
|
},
|
||||||
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
2
public/css/site.min.css
vendored
2
public/css/site.min.css
vendored
File diff suppressed because one or more lines are too long
12
public/js/site.min.js
vendored
12
public/js/site.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var jsdom = require('jsdom');
|
var cheerio = require('cheerio');
|
||||||
var request = require('request');
|
var request = require('request');
|
||||||
|
|
||||||
module.exports = createNavigator;
|
module.exports = createNavigator;
|
||||||
@@ -29,13 +29,12 @@ function createNavigator(baseUrl, store) {
|
|||||||
store.request = null;
|
store.request = null;
|
||||||
store.response = null;
|
store.response = null;
|
||||||
store.status = null;
|
store.status = null;
|
||||||
store.window = null;
|
|
||||||
|
|
||||||
request({
|
request({
|
||||||
url: baseUrl + opts.endpoint,
|
url: baseUrl + opts.endpoint,
|
||||||
method: opts.method || 'GET',
|
method: opts.method || 'GET',
|
||||||
body: opts.body,
|
form: opts.form,
|
||||||
json: true,
|
json: opts.json || false,
|
||||||
qs: opts.query,
|
qs: opts.query,
|
||||||
followAllRedirects: true
|
followAllRedirects: true
|
||||||
}, function(err, res, body) {
|
}, function(err, res, body) {
|
||||||
@@ -46,19 +45,11 @@ function createNavigator(baseUrl, store) {
|
|||||||
store.status = res.statusCode;
|
store.status = res.statusCode;
|
||||||
|
|
||||||
if (opts.nonDom) {
|
if (opts.nonDom) {
|
||||||
store.window = null;
|
|
||||||
store.dom = null;
|
store.dom = null;
|
||||||
callback();
|
|
||||||
} else {
|
} else {
|
||||||
jsdom.env(
|
store.dom = cheerio.load(store.body);
|
||||||
store.body,
|
|
||||||
function(err, window) {
|
|
||||||
store.window = window;
|
|
||||||
store.dom = window.document;
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
callback();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
var assert = require('proclaim');
|
var assert = require('proclaim');
|
||||||
|
|
||||||
describe('GET /', function() {
|
describe.only('GET /', function() {
|
||||||
|
|
||||||
beforeEach(function(done) {
|
beforeEach(function(done) {
|
||||||
var req = {
|
var req = {
|
||||||
@@ -32,61 +32,61 @@ describe('GET /', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should display an "Add new URL" button', function() {
|
it('should display an "Add new URL" button', function() {
|
||||||
var elem = this.last.dom.querySelectorAll('[data-test=add-task]');
|
var elem = this.last.dom('[data-test=add-task]');
|
||||||
assert.strictEqual(elem.length, 1);
|
assert.strictEqual(elem.length, 1);
|
||||||
assert.strictEqual(elem[0].getAttribute('href'), '/new');
|
assert.strictEqual(elem.eq(0).attr('href'), '/new');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display all of the expected tasks', function() {
|
it('should display all of the expected tasks', function() {
|
||||||
var tasks = this.last.dom.querySelectorAll('[data-test=task]');
|
var tasks = this.last.dom('[data-test=task]');
|
||||||
assert.strictEqual(tasks.length, 3);
|
assert.strictEqual(tasks.length, 3);
|
||||||
assert.match(tasks[0].textContent, /npg home\s+\(wcag2aa\)/i);
|
assert.match(tasks.eq(0).text(), /npg home\s+\(wcag2aa\)/i);
|
||||||
assert.match(tasks[1].textContent, /npg home\s+\(wcag2aaa\)/i);
|
assert.match(tasks.eq(1).text(), /npg home\s+\(wcag2aaa\)/i);
|
||||||
assert.match(tasks[2].textContent, /nature news\s+\(section508\)/i);
|
assert.match(tasks.eq(2).text(), /nature news\s+\(section508\)/i);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have links to each task', function() {
|
it('should have links to each task', function() {
|
||||||
var tasks = this.last.dom.querySelectorAll('[data-test=task]');
|
var tasks = this.last.dom('[data-test=task]');
|
||||||
assert.strictEqual(tasks[0].querySelectorAll('[href="/abc000000000000000000001"]').length, 1);
|
assert.strictEqual(tasks.eq(0).find('[href="/abc000000000000000000001"]').length, 1);
|
||||||
assert.strictEqual(tasks[1].querySelectorAll('[href="/abc000000000000000000002"]').length, 1);
|
assert.strictEqual(tasks.eq(1).find('[href="/abc000000000000000000002"]').length, 1);
|
||||||
assert.strictEqual(tasks[2].querySelectorAll('[href="/abc000000000000000000003"]').length, 1);
|
assert.strictEqual(tasks.eq(2).find('[href="/abc000000000000000000003"]').length, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display an "Edit" button for each task', function() {
|
it('should display an "Edit" button for each task', function() {
|
||||||
var tasks = this.last.dom.querySelectorAll('[data-test=task]');
|
var tasks = this.last.dom('[data-test=task]');
|
||||||
assert.strictEqual(tasks[0].querySelectorAll('[href="/abc000000000000000000001/edit"]').length, 1);
|
assert.strictEqual(tasks.eq(0).find('[href="/abc000000000000000000001/edit"]').length, 1);
|
||||||
assert.strictEqual(tasks[1].querySelectorAll('[href="/abc000000000000000000002/edit"]').length, 1);
|
assert.strictEqual(tasks.eq(1).find('[href="/abc000000000000000000002/edit"]').length, 1);
|
||||||
assert.strictEqual(tasks[2].querySelectorAll('[href="/abc000000000000000000003/edit"]').length, 1);
|
assert.strictEqual(tasks.eq(2).find('[href="/abc000000000000000000003/edit"]').length, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display a "Delete" button for each task', function() {
|
it('should display a "Delete" button for each task', function() {
|
||||||
var tasks = this.last.dom.querySelectorAll('[data-test=task]');
|
var tasks = this.last.dom('[data-test=task]');
|
||||||
assert.strictEqual(tasks[0].querySelectorAll('[href="/abc000000000000000000001/delete"]').length, 1);
|
assert.strictEqual(tasks.eq(0).find('[href="/abc000000000000000000001/delete"]').length, 1);
|
||||||
assert.strictEqual(tasks[1].querySelectorAll('[href="/abc000000000000000000002/delete"]').length, 1);
|
assert.strictEqual(tasks.eq(1).find('[href="/abc000000000000000000002/delete"]').length, 1);
|
||||||
assert.strictEqual(tasks[2].querySelectorAll('[href="/abc000000000000000000003/delete"]').length, 1);
|
assert.strictEqual(tasks.eq(2).find('[href="/abc000000000000000000003/delete"]').length, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display a "Run" button for each task', function() {
|
it('should display a "Run" button for each task', function() {
|
||||||
var tasks = this.last.dom.querySelectorAll('[data-test=task]');
|
var tasks = this.last.dom('[data-test=task]');
|
||||||
assert.strictEqual(tasks[0].querySelectorAll('[href="/abc000000000000000000001/run"]').length, 1);
|
assert.strictEqual(tasks.eq(0).find('[href="/abc000000000000000000001/run"]').length, 1);
|
||||||
assert.strictEqual(tasks[1].querySelectorAll('[href="/abc000000000000000000002/run"]').length, 1);
|
assert.strictEqual(tasks.eq(1).find('[href="/abc000000000000000000002/run"]').length, 1);
|
||||||
assert.strictEqual(tasks[2].querySelectorAll('[href="/abc000000000000000000003/run"]').length, 1);
|
assert.strictEqual(tasks.eq(2).find('[href="/abc000000000000000000003/run"]').length, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display the task result counts if the task has been run', function() {
|
it('should display the task result counts if the task has been run', function() {
|
||||||
var tasks = this.last.dom.querySelectorAll('[data-test=task]');
|
var tasks = this.last.dom('[data-test=task]');
|
||||||
assert.match(tasks[0].textContent, /1\s*errors/i);
|
assert.match(tasks.eq(0).text(), /1\s*errors/i);
|
||||||
assert.match(tasks[0].textContent, /2\s*warnings/i);
|
assert.match(tasks.eq(0).text(), /2\s*warnings/i);
|
||||||
assert.match(tasks[0].textContent, /3\s*notices/i);
|
assert.match(tasks.eq(0).text(), /3\s*notices/i);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display a message indicating that there are no results if the task has not been run', function() {
|
it('should display a message indicating that there are no results if the task has not been run', function() {
|
||||||
var tasks = this.last.dom.querySelectorAll('[data-test=task]');
|
var tasks = this.last.dom('[data-test=task]');
|
||||||
assert.match(tasks[2].textContent, /no results/i);
|
assert.match(tasks.eq(2).text(), /no results/i);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not display an alert message', function() {
|
it('should not display an alert message', function() {
|
||||||
assert.strictEqual(this.last.dom.querySelectorAll('[data-test=alert]').length, 0);
|
assert.strictEqual(this.last.dom('[data-test=alert]').length, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@@ -32,65 +32,65 @@ describe('GET /new', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should not display an error message', function() {
|
it('should not display an error message', function() {
|
||||||
assert.strictEqual(this.last.dom.querySelectorAll('[data-test=error]').length, 0);
|
assert.strictEqual(this.last.dom('[data-test=error]').length, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have an "Add new URL" form', function() {
|
it('should have an "Add new URL" form', function() {
|
||||||
var form = this.last.dom.querySelectorAll('[data-test=new-url-form]')[0];
|
var form = this.last.dom('[data-test=new-url-form]').eq(0);
|
||||||
assert.isDefined(form);
|
assert.isDefined(form);
|
||||||
assert.strictEqual(form.getAttribute('action'), '/new');
|
assert.strictEqual(form.attr('action'), '/new');
|
||||||
assert.strictEqual(form.getAttribute('method'), 'post');
|
assert.strictEqual(form.attr('method'), 'post');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('"Add New URL" form', function() {
|
describe('"Add New URL" form', function() {
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
this.form = this.last.dom.querySelectorAll('[data-test=new-url-form]')[0];
|
this.form = this.last.dom('[data-test=new-url-form]').eq(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a "name" field', function() {
|
it('should have a "name" field', function() {
|
||||||
var field = this.form.querySelectorAll('input[name=name]')[0];
|
var field = this.form.find('input[name=name]').eq(0);
|
||||||
assert.isDefined(field);
|
assert.isDefined(field);
|
||||||
assert.strictEqual(field.getAttribute('type'), 'text');
|
assert.strictEqual(field.attr('type'), 'text');
|
||||||
assert.strictEqual(field.getAttribute('value'), '');
|
assert.strictEqual(field.attr('value'), '');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a "url" field', function() {
|
it('should have a "url" field', function() {
|
||||||
var field = this.form.querySelectorAll('input[name=url]')[0];
|
var field = this.form.find('input[name=url]').eq(0);
|
||||||
assert.isDefined(field);
|
assert.isDefined(field);
|
||||||
assert.strictEqual(field.getAttribute('type'), 'url');
|
assert.strictEqual(field.attr('type'), 'url');
|
||||||
assert.strictEqual(field.getAttribute('value'), '');
|
assert.strictEqual(field.attr('value'), '');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a "wait" field', function() {
|
it('should have a "wait" field', function() {
|
||||||
var field = this.form.querySelectorAll('input[name=wait]')[0];
|
var field = this.form.find('input[name=wait]').eq(0);
|
||||||
assert.isDefined(field);
|
assert.isDefined(field);
|
||||||
assert.strictEqual(field.getAttribute('type'), 'text');
|
assert.strictEqual(field.attr('type'), 'text');
|
||||||
assert.strictEqual(field.getAttribute('value'), '');
|
assert.strictEqual(field.attr('value'), '');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a "username" field', function() {
|
it('should have a "username" field', function() {
|
||||||
var field = this.form.querySelectorAll('input[name=username]')[0];
|
var field = this.form.find('input[name=username]').eq(0);
|
||||||
assert.isDefined(field);
|
assert.isDefined(field);
|
||||||
assert.strictEqual(field.getAttribute('type'), 'text');
|
assert.strictEqual(field.attr('type'), 'text');
|
||||||
assert.strictEqual(field.getAttribute('value'), '');
|
assert.strictEqual(field.attr('value'), '');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a "password" field', function() {
|
it('should have a "password" field', function() {
|
||||||
var field = this.form.querySelectorAll('input[name=password]')[0];
|
var field = this.form.find('input[name=password]').eq(0);
|
||||||
assert.isDefined(field);
|
assert.isDefined(field);
|
||||||
assert.strictEqual(field.getAttribute('type'), 'text');
|
assert.strictEqual(field.attr('type'), 'text');
|
||||||
assert.strictEqual(field.getAttribute('value'), '');
|
assert.strictEqual(field.attr('value'), '');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a "standard" field', function() {
|
it('should have a "standard" field', function() {
|
||||||
var field = this.form.querySelectorAll('select[name=standard]')[0];
|
var field = this.form.find('select[name=standard]').eq(0);
|
||||||
assert.isDefined(field);
|
assert.isDefined(field);
|
||||||
assert.strictEqual(field.querySelectorAll('option').length, 4);
|
assert.strictEqual(field.find('option').length, 4);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have "ignore" fields', function() {
|
it('should have "ignore" fields', function() {
|
||||||
var fields = this.form.querySelectorAll('input[name="ignore[]"]');
|
var fields = this.form.find('input[name="ignore[]"]');
|
||||||
assert.isDefined(fields);
|
assert.isDefined(fields);
|
||||||
assert.notStrictEqual(fields.length, 0);
|
assert.notStrictEqual(fields.length, 0);
|
||||||
});
|
});
|
||||||
@@ -107,7 +107,7 @@ describe('POST /new', function() {
|
|||||||
var req = {
|
var req = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
endpoint: '/new',
|
endpoint: '/new',
|
||||||
body: {
|
form: {
|
||||||
name: '',
|
name: '',
|
||||||
url: ''
|
url: ''
|
||||||
}
|
}
|
||||||
@@ -120,7 +120,7 @@ describe('POST /new', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should display an error message', function() {
|
it('should display an error message', function() {
|
||||||
assert.strictEqual(this.last.dom.querySelectorAll('[data-test=error]').length, 1);
|
assert.strictEqual(this.last.dom('[data-test=error]').length, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -131,7 +131,7 @@ describe('POST /new', function() {
|
|||||||
var req = {
|
var req = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
endpoint: '/new',
|
endpoint: '/new',
|
||||||
body: {
|
form: {
|
||||||
name: 'Example',
|
name: 'Example',
|
||||||
url: 'http://example.com/',
|
url: 'http://example.com/',
|
||||||
standard: 'WCAG2AA'
|
standard: 'WCAG2AA'
|
||||||
@@ -156,11 +156,11 @@ describe('POST /new', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should not display an error message', function() {
|
it('should not display an error message', function() {
|
||||||
assert.strictEqual(this.last.dom.querySelectorAll('[data-test=error]').length, 0);
|
assert.strictEqual(this.last.dom('[data-test=error]').length, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display a success message', function() {
|
it('should display a success message', function() {
|
||||||
var alert = this.last.dom.querySelectorAll('[data-test=alert]')[0];
|
var alert = this.last.dom('[data-test=alert]').eq(0);
|
||||||
assert.isDefined(alert);
|
assert.isDefined(alert);
|
||||||
assert.match(alert.textContent, /url has been added/i);
|
assert.match(alert.textContent, /url has been added/i);
|
||||||
});
|
});
|
||||||
|
@@ -44,7 +44,8 @@ describe('GET /<task-id>/<result-id>.json', function() {
|
|||||||
var req = {
|
var req = {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
endpoint: '/abc000000000000000000001/def000000000000000000001.json',
|
endpoint: '/abc000000000000000000001/def000000000000000000001.json',
|
||||||
nonDom: true
|
nonDom: true,
|
||||||
|
json: true
|
||||||
};
|
};
|
||||||
this.navigate(req, done);
|
this.navigate(req, done);
|
||||||
});
|
});
|
||||||
|
@@ -32,37 +32,37 @@ describe('GET /<task-id>/<result-id>', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should display a "Download CSV" button', function() {
|
it('should display a "Download CSV" button', function() {
|
||||||
var elem = this.last.dom.querySelectorAll('[data-test=download-csv]');
|
var elem = this.last.dom('[data-test=download-csv]');
|
||||||
assert.strictEqual(elem.length, 1);
|
assert.strictEqual(elem.length, 1);
|
||||||
assert.strictEqual(elem[0].getAttribute('href'), '/abc000000000000000000001/def000000000000000000001.csv');
|
assert.strictEqual(elem.eq(0).attr('href'), '/abc000000000000000000001/def000000000000000000001.csv');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display a "Download JSON" button', function() {
|
it('should display a "Download JSON" button', function() {
|
||||||
var elem = this.last.dom.querySelectorAll('[data-test=download-json]');
|
var elem = this.last.dom('[data-test=download-json]');
|
||||||
assert.strictEqual(elem.length, 1);
|
assert.strictEqual(elem.length, 1);
|
||||||
assert.strictEqual(elem[0].getAttribute('href'), '/abc000000000000000000001/def000000000000000000001.json');
|
assert.strictEqual(elem.eq(0).attr('href'), '/abc000000000000000000001/def000000000000000000001.json');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display a link back to the task', function() {
|
it('should display a link back to the task', function() {
|
||||||
assert.isDefined(this.last.dom.querySelectorAll('[href="/abc000000000000000000001"]')[0]);
|
assert.isDefined(this.last.dom('[href="/abc000000000000000000001"]').eq(0));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display errors', function() {
|
it('should display errors', function() {
|
||||||
var elem = this.last.dom.querySelectorAll('[data-test=task-errors]')[0];
|
var elem = this.last.dom('[data-test=task-errors]').eq(0);
|
||||||
assert.isDefined(elem);
|
assert.isDefined(elem);
|
||||||
assert.match(elem.textContent, /errors \( 1 \)/i);
|
assert.match(elem.text(), /errors \( 1 \)/i);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display warnings', function() {
|
it('should display warnings', function() {
|
||||||
var elem = this.last.dom.querySelectorAll('[data-test=task-warnings]')[0];
|
var elem = this.last.dom('[data-test=task-warnings]').eq(0);
|
||||||
assert.isDefined(elem);
|
assert.isDefined(elem);
|
||||||
assert.match(elem.textContent, /warnings \( 2 \)/i);
|
assert.match(elem.text(), /warnings \( 2 \)/i);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display notices', function() {
|
it('should display notices', function() {
|
||||||
var elem = this.last.dom.querySelectorAll('[data-test=task-notices]')[0];
|
var elem = this.last.dom('[data-test=task-notices]').eq(0);
|
||||||
assert.isDefined(elem);
|
assert.isDefined(elem);
|
||||||
assert.match(elem.textContent, /notices \( 3 \)/i);
|
assert.match(elem.text(), /notices \( 3 \)/i);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@@ -32,14 +32,14 @@ describe('GET /<task-id>/delete', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should have a "Delete URL" form', function() {
|
it('should have a "Delete URL" form', function() {
|
||||||
var form = this.last.dom.querySelectorAll('[data-test=delete-url-form]')[0];
|
var form = this.last.dom('[data-test=delete-url-form]').eq(0);
|
||||||
assert.isDefined(form);
|
assert.isDefined(form);
|
||||||
assert.strictEqual(form.getAttribute('action'), '/abc000000000000000000001/delete');
|
assert.strictEqual(form.attr('action'), '/abc000000000000000000001/delete');
|
||||||
assert.strictEqual(form.getAttribute('method'), 'post');
|
assert.strictEqual(form.attr('method'), 'post');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display a link back to the task page', function() {
|
it('should display a link back to the task page', function() {
|
||||||
assert.greaterThan(this.last.dom.querySelectorAll('[href="/abc000000000000000000001"]').length, 0);
|
assert.greaterThan(this.last.dom('[href="/abc000000000000000000001"]').length, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -70,9 +70,9 @@ describe('POST /<task-id>/delete', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should display a success message', function() {
|
it('should display a success message', function() {
|
||||||
var alert = this.last.dom.querySelectorAll('[data-test=alert]')[0];
|
var alert = this.last.dom('[data-test=alert]').eq(0);
|
||||||
assert.isDefined(alert);
|
assert.isDefined(alert);
|
||||||
assert.match(alert.textContent, /been deleted/i);
|
assert.match(alert.text(), /been deleted/i);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@@ -32,66 +32,66 @@ describe('GET /<task-id>/edit', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should have an "Edit URL" form', function() {
|
it('should have an "Edit URL" form', function() {
|
||||||
var form = this.last.dom.querySelectorAll('[data-test=edit-url-form]')[0];
|
var form = this.last.dom('[data-test=edit-url-form]').eq(0);
|
||||||
assert.isDefined(form);
|
assert.isDefined(form);
|
||||||
assert.strictEqual(form.getAttribute('action'), '/abc000000000000000000001/edit');
|
assert.strictEqual(form.attr('action'), '/abc000000000000000000001/edit');
|
||||||
assert.strictEqual(form.getAttribute('method'), 'post');
|
assert.strictEqual(form.attr('method'), 'post');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display a link back to the task page', function() {
|
it('should display a link back to the task page', function() {
|
||||||
assert.greaterThan(this.last.dom.querySelectorAll('[href="/abc000000000000000000001"]').length, 0);
|
assert.greaterThan(this.last.dom('[href="/abc000000000000000000001"]').length, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('"Edit URL" form', function() {
|
describe('"Edit URL" form', function() {
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
this.form = this.last.dom.querySelectorAll('[data-test=edit-url-form]')[0];
|
this.form = this.last.dom('[data-test=edit-url-form]').eq(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a "name" field', function() {
|
it('should have a "name" field', function() {
|
||||||
var field = this.form.querySelectorAll('input[name=name]')[0];
|
var field = this.form.find('input[name=name]').eq(0);
|
||||||
assert.isDefined(field);
|
assert.isDefined(field);
|
||||||
assert.strictEqual(field.getAttribute('type'), 'text');
|
assert.strictEqual(field.attr('type'), 'text');
|
||||||
assert.strictEqual(field.getAttribute('value'), 'NPG Home');
|
assert.strictEqual(field.attr('value'), 'NPG Home');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a disabled "url" field', function() {
|
it('should have a disabled "url" field', function() {
|
||||||
var field = this.form.querySelectorAll('input[name=url]')[0];
|
var field = this.form.find('input[name=url]').eq(0);
|
||||||
assert.isDefined(field);
|
assert.isDefined(field);
|
||||||
assert.strictEqual(field.getAttribute('type'), 'url');
|
assert.strictEqual(field.attr('type'), 'url');
|
||||||
assert.strictEqual(field.getAttribute('value'), 'nature.com');
|
assert.strictEqual(field.attr('value'), 'nature.com');
|
||||||
assert.isDefined(field.getAttribute('disabled'));
|
assert.isDefined(field.attr('disabled'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a "wait" field', function() {
|
it('should have a "wait" field', function() {
|
||||||
var field = this.form.querySelectorAll('input[name=wait]')[0];
|
var field = this.form.find('input[name=wait]').eq(0);
|
||||||
assert.isDefined(field);
|
assert.isDefined(field);
|
||||||
assert.strictEqual(field.getAttribute('type'), 'text');
|
assert.strictEqual(field.attr('type'), 'text');
|
||||||
assert.strictEqual(field.getAttribute('value'), '0');
|
assert.strictEqual(field.attr('value'), '0');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a disabled "standard" field', function() {
|
it('should have a disabled "standard" field', function() {
|
||||||
var field = this.form.querySelectorAll('select[name=standard]')[0];
|
var field = this.form.find('select[name=standard]').eq(0);
|
||||||
assert.isDefined(field);
|
assert.isDefined(field);
|
||||||
assert.isDefined(field.getAttribute('disabled'));
|
assert.isDefined(field.attr('disabled'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a "username" field', function() {
|
it('should have a "username" field', function() {
|
||||||
var field = this.form.querySelectorAll('input[name=username]')[0];
|
var field = this.form.find('input[name=username]').eq(0);
|
||||||
assert.isDefined(field);
|
assert.isDefined(field);
|
||||||
assert.strictEqual(field.getAttribute('type'), 'text');
|
assert.strictEqual(field.attr('type'), 'text');
|
||||||
assert.strictEqual(field.getAttribute('value'), 'user');
|
assert.strictEqual(field.attr('value'), 'user');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a "password" field', function() {
|
it('should have a "password" field', function() {
|
||||||
var field = this.form.querySelectorAll('input[name=password]')[0];
|
var field = this.form.find('input[name=password]').eq(0);
|
||||||
assert.isDefined(field);
|
assert.isDefined(field);
|
||||||
assert.strictEqual(field.getAttribute('type'), 'text');
|
assert.strictEqual(field.attr('type'), 'text');
|
||||||
assert.strictEqual(field.getAttribute('value'), 'access');
|
assert.strictEqual(field.attr('value'), 'access');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have "ignore" fields', function() {
|
it('should have "ignore" fields', function() {
|
||||||
var fields = this.form.querySelectorAll('input[name="ignore[]"]');
|
var fields = this.form.find('input[name="ignore[]"]');
|
||||||
assert.isDefined(fields);
|
assert.isDefined(fields);
|
||||||
assert.notStrictEqual(fields.length, 0);
|
assert.notStrictEqual(fields.length, 0);
|
||||||
});
|
});
|
||||||
@@ -106,7 +106,7 @@ describe('POST /<task-id>/edit', function() {
|
|||||||
var req = {
|
var req = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
endpoint: '/abc000000000000000000001/edit',
|
endpoint: '/abc000000000000000000001/edit',
|
||||||
body: {
|
form: {
|
||||||
name: 'foo',
|
name: 'foo',
|
||||||
username: 'newuser',
|
username: 'newuser',
|
||||||
password: 'secure',
|
password: 'secure',
|
||||||
@@ -131,9 +131,9 @@ describe('POST /<task-id>/edit', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should display a success message', function() {
|
it('should display a success message', function() {
|
||||||
var alert = this.last.dom.querySelectorAll('[data-test=alert]')[0];
|
var alert = this.last.dom('[data-test=alert]').eq(0);
|
||||||
assert.isDefined(alert);
|
assert.isDefined(alert);
|
||||||
assert.match(alert.textContent, /been saved/i);
|
assert.match(alert.text(), /been saved/i);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@@ -34,46 +34,46 @@ describe('GET /<task-id>', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should display an "Edit" button', function() {
|
it('should display an "Edit" button', function() {
|
||||||
assert.strictEqual(this.last.dom.querySelectorAll('[href="/abc000000000000000000001/edit"]').length, 1);
|
assert.strictEqual(this.last.dom('[href="/abc000000000000000000001/edit"]').length, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display a "Delete" button', function() {
|
it('should display a "Delete" button', function() {
|
||||||
assert.strictEqual(this.last.dom.querySelectorAll('[href="/abc000000000000000000001/delete"]').length, 1);
|
assert.strictEqual(this.last.dom('[href="/abc000000000000000000001/delete"]').length, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display a "Run" button', function() {
|
it('should display a "Run" button', function() {
|
||||||
assert.strictEqual(this.last.dom.querySelectorAll('[href="/abc000000000000000000001/run"]').length, 1);
|
assert.strictEqual(this.last.dom('[href="/abc000000000000000000001/run"]').length, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display a "Download CSV" button for the latest result', function() {
|
it('should display a "Download CSV" button for the latest result', function() {
|
||||||
assert.strictEqual(this.last.dom.querySelectorAll('[href="/abc000000000000000000001/def000000000000000000001.csv"]').length, 1);
|
assert.strictEqual(this.last.dom('[href="/abc000000000000000000001/def000000000000000000001.csv"]').length, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display a "Download JSON" button for the latest result', function() {
|
it('should display a "Download JSON" button for the latest result', function() {
|
||||||
assert.strictEqual(this.last.dom.querySelectorAll('[href="/abc000000000000000000001/def000000000000000000001.json"]').length, 1);
|
assert.strictEqual(this.last.dom('[href="/abc000000000000000000001/def000000000000000000001.json"]').length, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display links to all results', function() {
|
it('should display links to all results', function() {
|
||||||
assert.isDefined(this.last.dom.querySelectorAll('[href="/abc000000000000000000001/def000000000000000000001"]')[0]);
|
assert.isDefined(this.last.dom('[href="/abc000000000000000000001/def000000000000000000001"]').eq(0));
|
||||||
assert.isDefined(this.last.dom.querySelectorAll('[href="/abc000000000000000000001/def000000000000000000003"]')[0]);
|
assert.isDefined(this.last.dom('[href="/abc000000000000000000001/def000000000000000000003"]').eq(0));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display errors', function() {
|
it('should display errors', function() {
|
||||||
var elem = this.last.dom.querySelectorAll('[data-test=task-errors]')[0];
|
var elem = this.last.dom('[data-test=task-errors]').eq(0);
|
||||||
assert.isDefined(elem);
|
assert.isDefined(elem);
|
||||||
assert.match(elem.textContent, /errors \( 1 \)/i);
|
assert.match(elem.text(), /errors \( 1 \)/i);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display warnings', function() {
|
it('should display warnings', function() {
|
||||||
var elem = this.last.dom.querySelectorAll('[data-test=task-warnings]')[0];
|
var elem = this.last.dom('[data-test=task-warnings]').eq(0);
|
||||||
assert.isDefined(elem);
|
assert.isDefined(elem);
|
||||||
assert.match(elem.textContent, /warnings \( 2 \)/i);
|
assert.match(elem.text(), /warnings \( 2 \)/i);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display notices', function() {
|
it('should display notices', function() {
|
||||||
var elem = this.last.dom.querySelectorAll('[data-test=task-notices]')[0];
|
var elem = this.last.dom('[data-test=task-notices]').eq(0);
|
||||||
assert.isDefined(elem);
|
assert.isDefined(elem);
|
||||||
assert.match(elem.textContent, /notices \( 3 \)/i);
|
assert.match(elem.text(), /notices \( 3 \)/i);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -93,15 +93,15 @@ describe('GET /<task-id>', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should display a "Run" button', function() {
|
it('should display a "Run" button', function() {
|
||||||
var elem = this.last.dom.querySelectorAll('[data-test=run-task]');
|
var elem = this.last.dom('[data-test=run-task]');
|
||||||
assert.strictEqual(elem.length, 1);
|
assert.strictEqual(elem.length, 1);
|
||||||
assert.strictEqual(elem[0].getAttribute('href'), '/abc000000000000000000003/run');
|
assert.strictEqual(elem.eq(0).attr('href'), '/abc000000000000000000003/run');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display a message indicating that there are no results', function() {
|
it('should display a message indicating that there are no results', function() {
|
||||||
var alert = this.last.dom.querySelectorAll('[data-test=alert]')[0];
|
var alert = this.last.dom('[data-test=alert]').eq(0);
|
||||||
assert.isDefined(alert);
|
assert.isDefined(alert);
|
||||||
assert.match(alert.textContent, /there are no results to show/i);
|
assert.match(alert.text(), /there are no results to show/i);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@@ -36,9 +36,9 @@ describe('GET /<task-id>/run', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should display a success message', function() {
|
it('should display a success message', function() {
|
||||||
var alert = this.last.dom.querySelectorAll('[data-test=alert]')[0];
|
var alert = this.last.dom('[data-test=alert]').eq(0);
|
||||||
assert.isDefined(alert);
|
assert.isDefined(alert);
|
||||||
assert.match(alert.textContent, /new results are being generated/i);
|
assert.match(alert.text(), /new results are being generated/i);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@@ -19,20 +19,20 @@ var moment = require('moment');
|
|||||||
|
|
||||||
module.exports = helper;
|
module.exports = helper;
|
||||||
|
|
||||||
function helper(register) {
|
function helper(hbs) {
|
||||||
|
|
||||||
// Format a date with Moment
|
// Format a date with Moment
|
||||||
register('date-format', function(context, block) {
|
hbs.registerHelper('date-format', function(context, block) {
|
||||||
var format = block.hash.format || 'YYYY-MM-DD HH:mm:ss';
|
var format = block.hash.format || 'YYYY-MM-DD HH:mm:ss';
|
||||||
return moment(context).format(format);
|
return moment(context).format(format);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Get a relative date
|
// Get a relative date
|
||||||
register('date-relative', function(context) {
|
hbs.registerHelper('date-relative', function(context) {
|
||||||
return moment(context).fromNow();
|
return moment(context).fromNow();
|
||||||
});
|
});
|
||||||
|
|
||||||
register('date-timestamp', function(context) {
|
hbs.registerHelper('date-timestamp', function(context) {
|
||||||
return moment(context).valueOf();
|
return moment(context).valueOf();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
module.exports = helper;
|
module.exports = helper;
|
||||||
|
|
||||||
function helper(register) {
|
function helper(hbs) {
|
||||||
|
|
||||||
// Convert a string to lower-case
|
// Convert a string to lower-case
|
||||||
register('lowercase', function(context) {
|
hbs.registerHelper('lowercase', function(context) {
|
||||||
return context.toLowerCase();
|
return context.toLowerCase();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -17,10 +17,10 @@
|
|||||||
|
|
||||||
module.exports = helper;
|
module.exports = helper;
|
||||||
|
|
||||||
function helper(register) {
|
function helper(hbs) {
|
||||||
|
|
||||||
// Simplify url by removing (eg http://, https://, trailing slashes) from url
|
// Simplify url by removing (eg http://, https://, trailing slashes) from url
|
||||||
register('simplify-url', function(context) {
|
hbs.registerHelper('simplify-url', function(context) {
|
||||||
return context.replace(/^https?:\/\//i, '').replace(/\/$/, '').toLowerCase();
|
return context.replace(/^https?:\/\//i, '').replace(/\/$/, '').toLowerCase();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user