mirror of
https://github.com/pa11y/pa11y-dashboard.git
synced 2025-09-24 14:21:13 +00:00
Add support for Pa11y actions (#176)
This commit is contained in:
@@ -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"
|
||||
},
|
||||
|
15
route/new.js
15
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,
|
||||
|
@@ -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;
|
||||
|
@@ -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);
|
||||
|
@@ -71,6 +71,11 @@ describe('GET /<task-id>/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);
|
||||
|
@@ -84,6 +84,19 @@ along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group clearfix">
|
||||
<div class="row">
|
||||
<div class="col-md-4 col-sm-4 col-xs-6">
|
||||
<label class="control-label" for="new-task-actions">
|
||||
Task Actions
|
||||
(<a href="https://github.com/pa11y/pa11y#actions">see Pa11y documentation</a>)
|
||||
</label>
|
||||
<textarea class="form-control" id="new-task-actions" name="actions" aria-describedby="action-detail" placeholder="E.g. Click element #login-button">{{task.actions}}</textarea>
|
||||
<em id="action-detail">(one action per line)</em>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group clearfix">
|
||||
<div class="row">
|
||||
<div class="col-md-4 col-sm-4 col-xs-6">
|
||||
|
@@ -96,6 +96,19 @@ along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group clearfix">
|
||||
<div class="row">
|
||||
<div class="col-md-4 col-sm-4 col-xs-6">
|
||||
<label class="control-label" for="new-task-actions">
|
||||
Task Actions
|
||||
(<a href="https://github.com/pa11y/pa11y#actions">see Pa11y documentation</a>)
|
||||
</label>
|
||||
<textarea class="form-control" id="new-task-actions" name="actions" aria-describedby="action-detail" placeholder="E.g. Click element #login-button">{{task.actions}}</textarea>
|
||||
<em id="action-detail">(one action per line)</em>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group clearfix">
|
||||
<div class="row">
|
||||
<div class="col-md-4 col-sm-4 col-xs-6">
|
||||
|
Reference in New Issue
Block a user