mirror of
https://github.com/appium/appium.git
synced 2026-10-28 20:31:51 +08:00
status is not always successful.
This commit is contained in:
committed by
Rafael Chavez
parent
f4c55b969c
commit
c3071eb9db
@@ -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);
|
||||
|
||||
@@ -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)}`);
|
||||
|
||||
@@ -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'});
|
||||
|
||||
Reference in New Issue
Block a user