status is not always successful.

This commit is contained in:
rafael.chavez
2016-05-19 16:25:01 -07:00
committed by Rafael Chavez
parent f4c55b969c
commit c3071eb9db
3 changed files with 7 additions and 14 deletions
+1 -1
View File
@@ -129,7 +129,7 @@ class JWProxy {
if (_.includes(statusCodesWithRes, response.statusCode)) {
if (response.statusCode === 200 && resBody.status === 0) {
return resBody.value;
} else if (response.statusCode === 200 && _.isUndefined(resBody.status)) {
} else if (response.statusCode === 200) {
return resBody;
}
let message = getSummaryByCode(resBody.status);
+2 -2
View File
@@ -245,8 +245,8 @@ function buildHandler (app, method, path, spec, driver, isSessCmd) {
driverRes = null;
}
// assuming everything worked, set up the json response object
httpResBody.status = JSONWP_SUCCESS_STATUS_CODE;
// Response status should be the status set by the driver response.
httpResBody.status = (_.isNil(driverRes) || _.isUndefined(driverRes.status)) ? JSONWP_SUCCESS_STATUS_CODE : driverRes.status;
httpResBody.value = driverRes;
log.info(`Responding to client with driver.${spec.command}() ` +
`result: ${_.truncate(JSON.stringify(driverRes), LOG_OBJ_LENGTH)}`);
+4 -11
View File
@@ -134,18 +134,11 @@ describe('proxy', () => {
e.value.should.eql({message: 'Invisible element'});
e.status.should.equal(11);
});
it('should throw when a command fails with a 200', async () => {
it('should return response body when a command fails with a 200', async () => {
let j = mockProxy({sessionId: '123'});
let e = null;
try {
await j.command('/element/200/text', 'GET');
} catch (err) {
e = err;
}
should.exist(e);
e.message.should.contain('Original error: Invisible element');
e.value.should.eql({message: 'Invisible element'});
e.status.should.equal(11);
let res = await j.command('/element/200/text', 'GET');
res.value.should.eql({message: 'Invisible element'});
res.status.should.eql(11);
});
it('should throw when a command fails with a 100', async () => {
let j = mockProxy({sessionId: '123'});