Skip to content
This repository was archived by the owner on May 22, 2019. It is now read-only.

Commit 33b7f47

Browse files
authored
Enable: POST requests in pa11yci (#182)
1 parent f53914d commit 33b7f47

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

config/.pa11yci.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const extend = require('node.extend');
2+
const querystring = require('querystring');
23

34
const viewports = process.env.PA11Y_VIEWPORTS || [
45
{
@@ -76,10 +77,10 @@ smoke.forEach((smokeConfig) => {
7677
url: process.env.TEST_URL + url
7778
}
7879

80+
thisUrl.page = {};
81+
7982
// Do we have test-specific headers?
8083
if (smokeConfig.headers) {
81-
thisUrl.page = {};
82-
8384
let fullCookie;
8485
let fullFlags;
8586

@@ -108,6 +109,27 @@ smoke.forEach((smokeConfig) => {
108109
}
109110
}
110111

112+
thisUrl.page.settings = {};
113+
114+
if (smokeConfig.method) thisUrl.page.settings.operation = smokeConfig.method;
115+
116+
if (smokeConfig.body) {
117+
118+
thisUrl.page.settings.data = (contentType => {
119+
switch(contentType) {
120+
case 'application/x-www-form-urlencoded':
121+
return querystring.stringify(smokeConfig.body);
122+
case 'application/json':
123+
return JSON.stringify(smokeConfig.body);
124+
default:
125+
return smokeConfig.body;
126+
}
127+
})(smokeConfig.headers['Content-Type']);
128+
129+
thisUrl.page.settings.encoding = 'utf8';
130+
131+
}
132+
111133
urls.push(thisUrl);
112134
}
113135
});

0 commit comments

Comments
 (0)