diff --git a/package.json b/package.json index 2068f6b..92e9dad 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "express-hbs": "~1.0", "http-headers": "^3.0.1", "moment": "~2.13", - "pa11y-webservice": "^2.1.2", + "pa11y-webservice": "^2.3.0", "pa11y-webservice-client-node": "^1.2.1", "underscore": "~1.8" }, diff --git a/route/new.js b/route/new.js index d67192d..91bf15b 100644 --- a/route/new.js +++ b/route/new.js @@ -40,11 +40,21 @@ function route(app) { app.express.post('/new', (req, res) => { + let parsedActions; + if (req.body.actions) { + parsedActions = req.body.actions.split(/[\r\n]+/) + .map(action => { + return action.trim(); + }) + .filter(action => { + return Boolean(action); + }); + } + let parsedHeaders; if (req.body.headers) { parsedHeaders = httpHeaders(req.body.headers, true); } - console.log(parsedHeaders); const newTask = { name: req.body.name, @@ -53,6 +63,7 @@ function route(app) { ignore: req.body.ignore || [], timeout: req.body.timeout || undefined, wait: req.body.wait || undefined, + actions: parsedActions, username: req.body.username || undefined, password: req.body.password || undefined, headers: parsedHeaders, @@ -73,6 +84,8 @@ function route(app) { }); return standard; }); + newTask.actions = req.body.actions; + newTask.headers = req.body.headers; return res.render('new', { error: err, standards: standards, diff --git a/route/task/edit.js b/route/task/edit.js index b4f84e8..aef3960 100644 --- a/route/task/edit.js +++ b/route/task/edit.js @@ -43,6 +43,7 @@ function route(app) { }); return standard; }); + task.actions = (task.actions ? task.actions.join('\n') : ''); res.render('task/edit', { edited: (typeof req.query.edited !== 'undefined'), standards: standards, @@ -57,10 +58,20 @@ function route(app) { if (err) { return next(); } + const originalActions = req.body.actions; const originalHeaders = req.body.headers; req.body.ignore = req.body.ignore || []; req.body.timeout = req.body.timeout || undefined; req.body.wait = req.body.wait || undefined; + if (req.body.actions) { + req.body.actions = req.body.actions.split(/[\r\n]+/) + .map(action => { + return action.trim(); + }) + .filter(action => { + return Boolean(action); + }); + } req.body.username = req.body.username || undefined; req.body.password = req.body.password || undefined; req.body.hideElements = req.body.hideElements || undefined; @@ -71,6 +82,7 @@ function route(app) { task.ignore = req.body.ignore; task.timeout = req.body.timeout; task.wait = req.body.wait; + task.actions = originalActions; task.username = req.body.username; task.password = req.body.password; task.headers = originalHeaders; diff --git a/test/integration/route/new.js b/test/integration/route/new.js index 4a6da6a..b86a30f 100644 --- a/test/integration/route/new.js +++ b/test/integration/route/new.js @@ -70,6 +70,11 @@ describe('GET /new', function() { assert.strictEqual(field.attr('value'), ''); }); + it('should have an "actions" field', function() { + const field = this.form.find('textarea[name=actions]').eq(0); + assert.isDefined(field); + }); + it('should have a "username" field', function() { const field = this.form.find('input[name=username]').eq(0); assert.isDefined(field); diff --git a/test/integration/route/task/edit.js b/test/integration/route/task/edit.js index b8159da..c684035 100644 --- a/test/integration/route/task/edit.js +++ b/test/integration/route/task/edit.js @@ -71,6 +71,11 @@ describe('GET //edit', function() { assert.strictEqual(field.attr('value'), '0'); }); + it('should have an "actions" field', function() { + const field = this.form.find('textarea[name=actions]').eq(0); + assert.isDefined(field); + }); + it('should have a disabled "standard" field', function() { const field = this.form.find('select[name=standard]').eq(0); assert.isDefined(field); diff --git a/view/new.html b/view/new.html index f5228db..dd0f808 100644 --- a/view/new.html +++ b/view/new.html @@ -84,6 +84,19 @@ along with Pa11y Dashboard. If not, see . +
+
+
+ + + (one action per line) +
+
+
+
diff --git a/view/task/edit.html b/view/task/edit.html index bc564ad..b34862a 100644 --- a/view/task/edit.html +++ b/view/task/edit.html @@ -96,6 +96,19 @@ along with Pa11y Dashboard. If not, see .
+
+
+
+ + + (one action per line) +
+
+
+