forked from external-repos/pa11y-dashboard
Fix tests, test more, support Node 16-20 (#318)
* Add `.nvmrc` → 14 * Fix package.json's URLs * Update to Pa11y CI's version (`https` etc) * Add Node 16 to matrix, and make linter run each time * Standardise `.editorconfig` * Upgrade to `actions/checkout@4` and `actions/setup-node@3` * Replace `npm install` with `npm ci` * Replace `wait-action` with `sleep 10s` * Rewrite to detach config, use promises, and replace `request` with `fetch` (adding `node-fetch` until Node 18) * Delete small single-use helper * Bump to `pa11y-webservice@4.1` and use caret from here (we control the dep) * Return to `this.last`, fix syntax errors * Update copyright to 2023 and remove unused ref * Fix troubleshooting link * Remove symbols, since they could become outdated * Remove missing link * Replace emoji note with GitHub Markdown note * Fix setup link * Replace br with double space * Replace `sh` with `console` for terminal output * Rename Mongo DB used in integration tests to avoid clash locally * Remove JSCS and references to other unused tools * Remove tooling tasks update * Compress definitions and layout where it makes sense or brings clarity * Rename db used in tests to `pa11y-dashboard-integration-test`, to avoid clash with `pa11y-webservice`'s own test DB * Use briefer syntax * Fix integration test setup & config * Reverse function order to return early * Update to `pa11y-lint-config@3`, update `ecmaVersion` to 2020, remove some rule overrides * Fix linting errors, remove cruft * Move linting and broken integration test command into npm scripts (it remains broken) * Revert `node-fetch` to `^2.7.0` (can't do ESM right now) * Upgrade to `pa11y-webservice@^4.2` from `^4.1` * Upgrade to `mocha@^9.2` from `^8.4` (can't do `10` yet because it drops Node 12) * Use backticks for property names * Fix anchor link for 'installing MongoDB' * Reorganise test workflow and add Node `18` and `20` to test matrix * Fix `lockfile-version` to `2` * Apply support policy * Replace Travis badge with one for Actions * Define some more links, separate code blocks * Reflect greater confidence in support for recent versions of MongoDB * Test against MongoDB versions 3-7 * Remove Make tasks `all`, `ci`, `clean`, `install`, `node_modules`, `lint` * Fix integration test command in workflow * Restore shallow Mocha command for now * Move linting into own step `lint` to avoid duplicated warnings * Give the `test` workflow a better name now that it uses a bigger matrix * Drop back to ES2019 from ES2020 for Node 12, remove use of `?.` * Reduce `--slow` to `4000` * Remove a `describe.only` 👀 * Fix broken test for add new item → standard * Rename availability check function * Fix task count check when testing task creation * Return fully to the original `new` logic * Use `127.0.0.1` consistently to fix (possible) IPV6 issue * Fix Cheerio call in failing test * Add MongoDB 2, and tweak other final versions * Lower case and shorten test name, to sit well alongside lint job * Replace `underscore(.groupBy)` with `lodash/groupby` * Capitalise Puppeteer * Say we test against MongoDB 2 as well * Document two replacements of Make with npm scripts * Revise requirements, permitting Node 16+ and describing Ubuntu issue * Support Node 16, 18, 20 * Install `lodash.keys` and fix Lodash mistakes * Fix rebase autoresolution error affecting `index.js` 👀 * This is Pa11y Dashboard not Webservice * Fix MongoDB link * Remove unused link def for Puppeteer * Shush markdown linter * Actually use `pa11y-webservice@4.3` * Improve support table * Don't `fail-fast` * Remove dependency `underscore` * Fix dashboard's port definition for integration test * Set `NODE_ENV=test` for integration tests * Use `mocha@10` * Extend the sleep to rule out the service not starting in time * Wait on port `4000` instead of sleeping * Fix `wait-on-action` to `v1.1.0` * Fix includes of `lodash.groupby` and `lodash.keys` * Label the port waiting action * Fix to `pa11y-webservice@4.2.0` until dep issue resolved * Set waiter action to start after 1s, time out after 30s, and log * Upgrade to `pa11y-webservice@^4.3.1` from `~4.2.0` * Remove comment about recent versions of MongoDB, since we test with them now
This commit is contained in:
@@ -16,10 +16,7 @@
|
||||
|
||||
const presentTask = require('../view/presenter/task');
|
||||
|
||||
module.exports = route;
|
||||
|
||||
// Route definition
|
||||
function route(app) {
|
||||
module.exports = function index(app) {
|
||||
app.express.get('/', (request, response, next) => {
|
||||
app.webservice.tasks.get({lastres: true}, (error, tasks) => {
|
||||
if (error) {
|
||||
@@ -32,4 +29,4 @@ function route(app) {
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
94
route/new.js
94
route/new.js
@@ -18,18 +18,15 @@
|
||||
const getStandards = require('../data/standards');
|
||||
const httpHeaders = require('http-headers');
|
||||
|
||||
module.exports = route;
|
||||
|
||||
// Route definition
|
||||
function route(app) {
|
||||
|
||||
module.exports = function route(app) {
|
||||
app.express.get('/new', (request, response) => {
|
||||
const standards = getStandards().map(standard => {
|
||||
if (standard.title === 'WCAG2AA') {
|
||||
standard.selected = true;
|
||||
}
|
||||
return standard;
|
||||
});
|
||||
const standards = getStandards().map(
|
||||
standard => {
|
||||
if (standard.title === 'WCAG2AA') {
|
||||
standard.selected = true;
|
||||
}
|
||||
return standard;
|
||||
});
|
||||
response.render('new', {
|
||||
standards,
|
||||
isNewTaskPage: true
|
||||
@@ -37,43 +34,38 @@ function route(app) {
|
||||
});
|
||||
|
||||
app.express.post('/new', (request, response) => {
|
||||
|
||||
const parsedActions = parseActions(request.body.actions);
|
||||
let parsedHeaders;
|
||||
|
||||
if (request.body.headers) {
|
||||
parsedHeaders = httpHeaders(request.body.headers, true);
|
||||
}
|
||||
const parsedHeaders = request.body.headers && httpHeaders(request.body.headers, true);
|
||||
|
||||
const newTask = createNewTask(request, parsedActions, parsedHeaders);
|
||||
|
||||
app.webservice.tasks.create(newTask, (error, task) => {
|
||||
if (error) {
|
||||
const standards = getStandards().map(standard => {
|
||||
if (standard.title === newTask.standard) {
|
||||
standard.selected = true;
|
||||
}
|
||||
standard.rules = standard.rules.map(rule => {
|
||||
if (newTask.ignore.indexOf(rule.name) !== -1) {
|
||||
rule.ignored = true;
|
||||
}
|
||||
return rule;
|
||||
});
|
||||
return standard;
|
||||
});
|
||||
newTask.actions = request.body.actions;
|
||||
newTask.headers = request.body.headers;
|
||||
return response.render('new', {
|
||||
error,
|
||||
standards,
|
||||
task: newTask
|
||||
});
|
||||
if (!error) {
|
||||
return response.redirect(`/${task.id}?added`);
|
||||
}
|
||||
response.redirect(`/${task.id}?added`);
|
||||
|
||||
const standards = getStandards().map(standard => {
|
||||
if (standard.title === newTask.standard) {
|
||||
standard.selected = true;
|
||||
}
|
||||
standard.rules = standard.rules.map(rule => {
|
||||
if (newTask.ignore.indexOf(rule.name) !== -1) {
|
||||
rule.ignored = true;
|
||||
}
|
||||
return rule;
|
||||
});
|
||||
return standard;
|
||||
});
|
||||
newTask.actions = request.body.actions;
|
||||
newTask.headers = request.body.headers;
|
||||
response.render('new', {
|
||||
error,
|
||||
standards,
|
||||
task: newTask
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
function parseActions(actions) {
|
||||
if (actions) {
|
||||
@@ -87,19 +79,19 @@ function parseActions(actions) {
|
||||
}
|
||||
}
|
||||
|
||||
/* eslint-disable complexity */
|
||||
function createNewTask(request, actions, headers) {
|
||||
|
||||
function createNewTask({body}, actions, headers) {
|
||||
return {
|
||||
name: request.body.name,
|
||||
url: request.body.url,
|
||||
standard: request.body.standard,
|
||||
ignore: request.body.ignore || [],
|
||||
timeout: request.body.timeout || undefined,
|
||||
wait: request.body.wait || undefined,
|
||||
name: body.name,
|
||||
url: body.url,
|
||||
standard: body.standard,
|
||||
ignore: body.ignore || [],
|
||||
timeout: body.timeout || undefined,
|
||||
wait: body.wait || undefined,
|
||||
actions,
|
||||
username: request.body.username || undefined,
|
||||
password: request.body.password || undefined,
|
||||
username: body.username || undefined,
|
||||
password: body.password || undefined,
|
||||
headers,
|
||||
hideElements: request.body.hideElements || undefined
|
||||
hideElements: body.hideElements || undefined
|
||||
};
|
||||
}
|
||||
|
@@ -16,11 +16,7 @@
|
||||
|
||||
const moment = require('moment');
|
||||
|
||||
module.exports = route;
|
||||
|
||||
// Route definition
|
||||
function route(app) {
|
||||
|
||||
module.exports = function download(app) {
|
||||
function getTaskAndResult(request, response, next) {
|
||||
app.webservice.task(request.params.id).get({}, (error, task) => {
|
||||
if (error) {
|
||||
@@ -83,5 +79,4 @@ function route(app) {
|
||||
result.task = task;
|
||||
response.send(result);
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
|
@@ -17,19 +17,15 @@
|
||||
const presentTask = require('../../view/presenter/task');
|
||||
const presentResult = require('../../view/presenter/result');
|
||||
|
||||
module.exports = route;
|
||||
|
||||
// Route definition
|
||||
function route(app) {
|
||||
|
||||
app.express.get('/:id/:rid', (request, response, next) => {
|
||||
app.webservice.task(request.params.id).get({}, (error, task) => {
|
||||
module.exports = function resultIndex(app) {
|
||||
app.express.get('/:id/:rid', ({params}, response, next) => {
|
||||
app.webservice.task(params.id).get({}, (error, task) => {
|
||||
if (error) {
|
||||
return next();
|
||||
}
|
||||
app.webservice
|
||||
.task(request.params.id)
|
||||
.result(request.params.rid)
|
||||
.task(params.id)
|
||||
.result(params.rid)
|
||||
.get({full: true}, (webserviceError, result) => {
|
||||
if (webserviceError) {
|
||||
return next();
|
||||
@@ -42,5 +38,4 @@ function route(app) {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
|
@@ -16,13 +16,9 @@
|
||||
|
||||
const presentTask = require('../../view/presenter/task');
|
||||
|
||||
module.exports = route;
|
||||
|
||||
// Route definition
|
||||
function route(app) {
|
||||
|
||||
app.express.get('/:id/delete', (request, response, next) => {
|
||||
app.webservice.task(request.params.id).get({}, (error, task) => {
|
||||
module.exports = function del(app) {
|
||||
app.express.get('/:id/delete', ({params}, response, next) => {
|
||||
app.webservice.task(params.id).get({}, (error, task) => {
|
||||
if (error) {
|
||||
return next();
|
||||
}
|
||||
@@ -33,13 +29,12 @@ function route(app) {
|
||||
});
|
||||
});
|
||||
|
||||
app.express.post('/:id/delete', (request, response, next) => {
|
||||
app.webservice.task(request.params.id).remove(error => {
|
||||
app.express.post('/:id/delete', ({params}, response, next) => {
|
||||
app.webservice.task(params.id).remove(error => {
|
||||
if (error) {
|
||||
return next();
|
||||
}
|
||||
response.redirect('/?deleted');
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
|
@@ -18,11 +18,7 @@ const presentTask = require('../../view/presenter/task');
|
||||
const getStandards = require('../../data/standards');
|
||||
const httpHeaders = require('http-headers');
|
||||
|
||||
module.exports = route;
|
||||
|
||||
// Route definition
|
||||
function route(app) {
|
||||
|
||||
module.exports = function edit(app) {
|
||||
app.express.get('/:id/edit', (request, response, next) => {
|
||||
app.webservice.task(request.params.id).get({}, (error, task) => {
|
||||
if (error) {
|
||||
@@ -117,5 +113,4 @@ function route(app) {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
|
@@ -1,10 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = route;
|
||||
|
||||
// Route definition
|
||||
function route(app) {
|
||||
|
||||
module.exports = function ignore(app) {
|
||||
app.express.post('/:id/ignore', (request, response, next) => {
|
||||
app.webservice.task(request.params.id).get({}, (error, task) => {
|
||||
if (error) {
|
||||
@@ -22,5 +18,4 @@ function route(app) {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
|
@@ -18,11 +18,7 @@ const presentTask = require('../../view/presenter/task');
|
||||
const presentResult = require('../../view/presenter/result');
|
||||
const presentResultList = require('../../view/presenter/result-list');
|
||||
|
||||
module.exports = route;
|
||||
|
||||
// Route definition
|
||||
function route(app) {
|
||||
|
||||
module.exports = function taskIndex(app) {
|
||||
app.express.get('/:id', (request, response, next) => {
|
||||
app.webservice.task(request.params.id).get({lastres: true}, (error, task) => {
|
||||
if (error) {
|
||||
@@ -47,5 +43,4 @@ function route(app) {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
|
@@ -14,11 +14,7 @@
|
||||
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
|
||||
'use strict';
|
||||
|
||||
module.exports = route;
|
||||
|
||||
// Route definition
|
||||
function route(app) {
|
||||
|
||||
module.exports = function run(app) {
|
||||
app.express.get('/:id/run', (request, response, next) => {
|
||||
app.webservice.task(request.params.id).run(error => {
|
||||
if (error) {
|
||||
@@ -27,5 +23,4 @@ function route(app) {
|
||||
response.redirect(`/${request.params.id}?running`);
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
|
@@ -2,9 +2,7 @@
|
||||
|
||||
module.exports = route;
|
||||
|
||||
// Route definition
|
||||
function route(app) {
|
||||
|
||||
app.express.post('/:id/unignore', (request, response, next) => {
|
||||
app.webservice.task(request.params.id).get({}, (error, task) => {
|
||||
if (error) {
|
||||
@@ -23,5 +21,4 @@ function route(app) {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user