@appium/base-driver 8.2.4 → 8.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/lib/basedriver/commands/find.js +4 -11
- package/build/lib/basedriver/commands/log.js +3 -6
- package/build/lib/basedriver/commands/session.js +18 -27
- package/build/lib/basedriver/commands/settings.js +4 -8
- package/build/lib/basedriver/commands/timeout.js +10 -15
- package/build/lib/basedriver/device-settings.js +14 -2
- package/build/lib/basedriver/driver.js +22 -20
- package/build/lib/basedriver/helpers.js +9 -9
- package/build/lib/express/express-logging.js +2 -2
- package/build/lib/express/idempotency.js +2 -2
- package/build/lib/helpers/capabilities.js +39 -0
- package/build/lib/index.js +3 -5
- package/build/lib/jsonwp-proxy/protocol-converter.js +18 -12
- package/build/lib/jsonwp-proxy/proxy.js +19 -12
- package/build/lib/protocol/protocol.js +36 -27
- package/build/lib/protocol/routes.js +67 -1
- package/build/test/basedriver/capabilities-specs.js +43 -1
- package/build/test/basedriver/capability-specs.js +126 -167
- package/build/test/basedriver/commands/log-specs.js +12 -5
- package/build/test/basedriver/driver-tests.js +11 -14
- package/build/test/basedriver/timeout-specs.js +7 -9
- package/build/test/express/server-e2e-specs.js +10 -5
- package/build/test/express/server-specs.js +22 -16
- package/build/test/express/static-specs.js +10 -5
- package/build/test/protocol/fake-driver.js +12 -15
- package/build/test/protocol/protocol-e2e-specs.js +16 -10
- package/build/test/protocol/routes-specs.js +2 -2
- package/lib/basedriver/commands/find.js +3 -6
- package/lib/basedriver/commands/log.js +2 -4
- package/lib/basedriver/commands/session.js +21 -22
- package/lib/basedriver/commands/settings.js +3 -5
- package/lib/basedriver/commands/timeout.js +9 -10
- package/lib/basedriver/device-settings.js +10 -1
- package/lib/basedriver/driver.js +25 -12
- package/lib/basedriver/helpers.js +13 -11
- package/lib/express/express-logging.js +1 -1
- package/lib/express/idempotency.js +1 -1
- package/lib/helpers/capabilities.js +25 -0
- package/lib/index.js +2 -2
- package/lib/jsonwp-proxy/protocol-converter.js +14 -13
- package/lib/jsonwp-proxy/proxy.js +16 -12
- package/lib/protocol/protocol.js +34 -29
- package/lib/protocol/routes.js +60 -1
- package/package.json +29 -22
- package/test/basedriver/capabilities-specs.js +34 -2
- package/test/basedriver/capability-specs.js +120 -146
- package/test/basedriver/commands/log-specs.js +12 -3
- package/test/basedriver/driver-tests.js +12 -7
- package/test/basedriver/timeout-specs.js +6 -11
- package/build/lib/protocol/sessions-cache.js +0 -88
- package/lib/protocol/sessions-cache.js +0 -74
|
@@ -1,54 +1,47 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
import B from 'bluebird';
|
|
1
4
|
import { default as BaseDriver, errors } from '../../lib';
|
|
2
5
|
import logger from '../../lib/basedriver/logger';
|
|
3
|
-
import
|
|
4
|
-
|
|
6
|
+
import { createSandbox } from 'sinon';
|
|
5
7
|
|
|
6
8
|
describe('Desired Capabilities', function () {
|
|
7
9
|
let d;
|
|
10
|
+
let sandbox;
|
|
8
11
|
|
|
9
12
|
beforeEach(function () {
|
|
10
13
|
d = new BaseDriver();
|
|
11
|
-
|
|
14
|
+
sandbox = createSandbox();
|
|
15
|
+
sandbox.spy(d.log, 'warn');
|
|
16
|
+
sandbox.spy(logger, 'warn');
|
|
12
17
|
});
|
|
13
18
|
|
|
14
19
|
afterEach(function () {
|
|
15
|
-
|
|
20
|
+
sandbox.restore();
|
|
16
21
|
});
|
|
17
22
|
|
|
18
23
|
it('should require platformName and deviceName', async function () {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
e.should.be.instanceof(errors.SessionNotCreatedError);
|
|
23
|
-
e.message.should.contain('platformName');
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
should.fail('error should have been thrown');
|
|
24
|
+
await d.createSession({
|
|
25
|
+
firstMatch: [{}]
|
|
26
|
+
}).should.eventually.be.rejectedWith(errors.SessionNotCreatedError, /platformName/);
|
|
28
27
|
});
|
|
29
28
|
|
|
30
29
|
|
|
31
30
|
it('should require platformName', async function () {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
should.fail('error should have been thrown');
|
|
31
|
+
await d.createSession({
|
|
32
|
+
alwaysMatch: {
|
|
33
|
+
'appium:deviceName': 'Delorean'
|
|
34
|
+
}
|
|
35
|
+
}).should.eventually.be.rejectedWith(errors.SessionNotCreatedError, /platformName/);
|
|
41
36
|
});
|
|
42
37
|
|
|
43
38
|
it('should not care about cap order', async function () {
|
|
44
|
-
|
|
45
39
|
await d.createSession(null, null, {
|
|
46
40
|
alwaysMatch: {
|
|
47
41
|
'appium:deviceName': 'Delorean',
|
|
48
42
|
platformName: 'iOS'
|
|
49
43
|
}
|
|
50
|
-
});
|
|
51
|
-
|
|
44
|
+
}).should.eventually.be.fulfilled;
|
|
52
45
|
});
|
|
53
46
|
|
|
54
47
|
it('should check required caps which are added to driver', async function () {
|
|
@@ -63,21 +56,12 @@ describe('Desired Capabilities', function () {
|
|
|
63
56
|
}
|
|
64
57
|
};
|
|
65
58
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
});
|
|
73
|
-
} catch (e) {
|
|
74
|
-
e.should.be.instanceof(errors.SessionNotCreatedError);
|
|
75
|
-
e.message.should.contain('necessary');
|
|
76
|
-
e.message.should.contain('proper');
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
should.fail('error should have been thrown');
|
|
59
|
+
await d.createSession(null, null, {
|
|
60
|
+
alwaysMatch: {
|
|
61
|
+
'platformName': 'iOS',
|
|
62
|
+
'appium:deviceName': 'Delorean'
|
|
63
|
+
}
|
|
64
|
+
}).should.eventually.be.rejectedWith(errors.SessionNotCreatedError, /necessary.*proper/);
|
|
81
65
|
});
|
|
82
66
|
|
|
83
67
|
it('should check added required caps in addition to base', async function () {
|
|
@@ -92,19 +76,11 @@ describe('Desired Capabilities', function () {
|
|
|
92
76
|
}
|
|
93
77
|
};
|
|
94
78
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
});
|
|
101
|
-
} catch (e) {
|
|
102
|
-
e.should.be.instanceof(errors.SessionNotCreatedError);
|
|
103
|
-
e.message.should.contain('platformName');
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
should.fail('error should have been thrown');
|
|
79
|
+
await d.createSession(null, null, {
|
|
80
|
+
alwaysMatch: {
|
|
81
|
+
'appium:necessary': 'yup'
|
|
82
|
+
}
|
|
83
|
+
}).should.eventually.be.rejectedWith(errors.SessionNotCreatedError, /platformName/);
|
|
108
84
|
});
|
|
109
85
|
|
|
110
86
|
it('should accept extra capabilities', async function () {
|
|
@@ -115,7 +91,7 @@ describe('Desired Capabilities', function () {
|
|
|
115
91
|
'appium:extra': 'cheese',
|
|
116
92
|
'appium:hold the': 'sauce'
|
|
117
93
|
}
|
|
118
|
-
});
|
|
94
|
+
}).should.eventually.be.fulfilled;
|
|
119
95
|
});
|
|
120
96
|
|
|
121
97
|
it('should log the use of extra caps', async function () {
|
|
@@ -130,24 +106,16 @@ describe('Desired Capabilities', function () {
|
|
|
130
106
|
}
|
|
131
107
|
});
|
|
132
108
|
|
|
133
|
-
|
|
109
|
+
d.log.warn.should.have.been.called;
|
|
134
110
|
});
|
|
135
111
|
|
|
136
112
|
it('should be sensitive to the case of caps', async function () {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
});
|
|
144
|
-
} catch (e) {
|
|
145
|
-
e.should.be.instanceof(errors.SessionNotCreatedError);
|
|
146
|
-
e.message.should.contain('platformName');
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
should.fail('error should have been thrown');
|
|
113
|
+
await d.createSession(null, null, {
|
|
114
|
+
alwaysMatch: {
|
|
115
|
+
'platformname': 'iOS',
|
|
116
|
+
'appium:deviceName': 'Delorean'
|
|
117
|
+
}
|
|
118
|
+
}).should.eventually.be.rejectedWith(errors.SessionNotCreatedError, /platformName/);
|
|
151
119
|
});
|
|
152
120
|
|
|
153
121
|
describe('boolean capabilities', function () {
|
|
@@ -159,7 +127,7 @@ describe('Desired Capabilities', function () {
|
|
|
159
127
|
'appium:noReset': 'false'
|
|
160
128
|
}
|
|
161
129
|
});
|
|
162
|
-
|
|
130
|
+
d.log.warn.should.have.been.called;
|
|
163
131
|
|
|
164
132
|
let sessions = await d.getSessions();
|
|
165
133
|
sessions[0].capabilities.noReset.should.eql(false);
|
|
@@ -173,7 +141,7 @@ describe('Desired Capabilities', function () {
|
|
|
173
141
|
'appium:noReset': 'true'
|
|
174
142
|
}
|
|
175
143
|
});
|
|
176
|
-
|
|
144
|
+
d.log.warn.should.have.been.called;
|
|
177
145
|
|
|
178
146
|
let sessions = await d.getSessions();
|
|
179
147
|
sessions[0].capabilities.noReset.should.eql(true);
|
|
@@ -187,7 +155,7 @@ describe('Desired Capabilities', function () {
|
|
|
187
155
|
'appium:language': 'true'
|
|
188
156
|
}
|
|
189
157
|
});
|
|
190
|
-
|
|
158
|
+
d.log.warn.should.not.have.been.called;
|
|
191
159
|
|
|
192
160
|
let sessions = await d.getSessions();
|
|
193
161
|
sessions[0].capabilities.language.should.eql('true');
|
|
@@ -203,7 +171,7 @@ describe('Desired Capabilities', function () {
|
|
|
203
171
|
'appium:newCommandTimeout': '1'
|
|
204
172
|
}
|
|
205
173
|
});
|
|
206
|
-
|
|
174
|
+
d.log.warn.should.have.been.called;
|
|
207
175
|
|
|
208
176
|
let sessions = await d.getSessions();
|
|
209
177
|
sessions[0].capabilities.newCommandTimeout.should.eql(1);
|
|
@@ -217,7 +185,7 @@ describe('Desired Capabilities', function () {
|
|
|
217
185
|
'appium:newCommandTimeout': '1.1'
|
|
218
186
|
}
|
|
219
187
|
});
|
|
220
|
-
|
|
188
|
+
d.log.warn.should.have.been.called;
|
|
221
189
|
|
|
222
190
|
let sessions = await d.getSessions();
|
|
223
191
|
sessions[0].capabilities.newCommandTimeout.should.eql(1.1);
|
|
@@ -231,7 +199,7 @@ describe('Desired Capabilities', function () {
|
|
|
231
199
|
'appium:language': '1'
|
|
232
200
|
}
|
|
233
201
|
});
|
|
234
|
-
|
|
202
|
+
d.log.warn.should.not.have.been.called;
|
|
235
203
|
|
|
236
204
|
let sessions = await d.getSessions();
|
|
237
205
|
sessions[0].capabilities.language.should.eql('1');
|
|
@@ -239,20 +207,12 @@ describe('Desired Capabilities', function () {
|
|
|
239
207
|
});
|
|
240
208
|
|
|
241
209
|
it ('should error if objects in caps', async function () {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
});
|
|
249
|
-
} catch (e) {
|
|
250
|
-
e.should.be.instanceof(errors.SessionNotCreatedError);
|
|
251
|
-
e.message.should.contain('platformName');
|
|
252
|
-
return;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
should.fail('error should have been thrown');
|
|
210
|
+
await d.createSession(null, null, {
|
|
211
|
+
alwaysMatch: {
|
|
212
|
+
'platformName': {a: 'iOS'},
|
|
213
|
+
'appium:deviceName': 'Delorean'
|
|
214
|
+
}
|
|
215
|
+
}).should.eventually.be.rejectedWith(errors.SessionNotCreatedError, /platformName/i);
|
|
256
216
|
});
|
|
257
217
|
|
|
258
218
|
it('should check for deprecated caps', async function () {
|
|
@@ -272,7 +232,7 @@ describe('Desired Capabilities', function () {
|
|
|
272
232
|
}
|
|
273
233
|
});
|
|
274
234
|
|
|
275
|
-
logger.warn.
|
|
235
|
+
logger.warn.should.have.been.called;
|
|
276
236
|
});
|
|
277
237
|
|
|
278
238
|
it('should not warn if deprecated=false', async function () {
|
|
@@ -292,7 +252,7 @@ describe('Desired Capabilities', function () {
|
|
|
292
252
|
}
|
|
293
253
|
});
|
|
294
254
|
|
|
295
|
-
|
|
255
|
+
d.log.warn.should.not.have.been.called;
|
|
296
256
|
});
|
|
297
257
|
|
|
298
258
|
it('should not validate against null/undefined caps', async function () {
|
|
@@ -302,14 +262,17 @@ describe('Desired Capabilities', function () {
|
|
|
302
262
|
}
|
|
303
263
|
};
|
|
304
264
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
265
|
+
try {
|
|
266
|
+
await d.createSession(null, null, {
|
|
267
|
+
alwaysMatch: {
|
|
268
|
+
platformName: 'iOS',
|
|
269
|
+
'appium:deviceName': 'Dumb',
|
|
270
|
+
'appium:foo': null
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
} finally {
|
|
274
|
+
await d.deleteSession();
|
|
275
|
+
}
|
|
313
276
|
|
|
314
277
|
await d.createSession(null, null, {
|
|
315
278
|
alwaysMatch: {
|
|
@@ -319,23 +282,29 @@ describe('Desired Capabilities', function () {
|
|
|
319
282
|
}
|
|
320
283
|
}).should.eventually.be.rejectedWith(/'foo' must be of type string/);
|
|
321
284
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
285
|
+
try {
|
|
286
|
+
await d.createSession(null, null, {
|
|
287
|
+
alwaysMatch: {
|
|
288
|
+
platformName: 'iOS',
|
|
289
|
+
'appium:deviceName': 'Dumb',
|
|
290
|
+
'appium:foo': undefined
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
} finally {
|
|
294
|
+
await d.deleteSession();
|
|
295
|
+
}
|
|
330
296
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
297
|
+
try {
|
|
298
|
+
await d.createSession(null, null, {
|
|
299
|
+
alwaysMatch: {
|
|
300
|
+
platformName: 'iOS',
|
|
301
|
+
'appium:deviceName': 'Dumb',
|
|
302
|
+
'appium:foo': ''
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
} finally {
|
|
306
|
+
await d.deleteSession();
|
|
307
|
+
}
|
|
339
308
|
});
|
|
340
309
|
|
|
341
310
|
it('should still validate null/undefined/empty caps whose presence is required', async function () {
|
|
@@ -353,28 +322,36 @@ describe('Desired Capabilities', function () {
|
|
|
353
322
|
}
|
|
354
323
|
}).should.eventually.be.rejectedWith(/blank/);
|
|
355
324
|
|
|
356
|
-
await d.createSession(null,
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
325
|
+
await d.createSession(null, {
|
|
326
|
+
alwaysMatch: {
|
|
327
|
+
platformName: 'iOS',
|
|
328
|
+
'appium:deviceName': 'Dumb',
|
|
329
|
+
'appium:foo': ''
|
|
330
|
+
}
|
|
360
331
|
}).should.eventually.be.rejectedWith(/blank/);
|
|
361
332
|
|
|
362
|
-
await d.createSession(
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
333
|
+
await d.createSession({
|
|
334
|
+
firstMatch: [{
|
|
335
|
+
platformName: 'iOS',
|
|
336
|
+
'appium:deviceName': 'Dumb',
|
|
337
|
+
'appium:foo': {}
|
|
338
|
+
}]
|
|
366
339
|
}).should.eventually.be.rejectedWith(/blank/);
|
|
367
340
|
|
|
368
|
-
await d.createSession(
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
341
|
+
await d.createSession({
|
|
342
|
+
alwaysMatch: {
|
|
343
|
+
platformName: 'iOS',
|
|
344
|
+
'appium:deviceName': 'Dumb',
|
|
345
|
+
'appium:foo': []
|
|
346
|
+
}
|
|
372
347
|
}).should.eventually.be.rejectedWith(/blank/);
|
|
373
348
|
|
|
374
|
-
await d.createSession(
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
349
|
+
await d.createSession({
|
|
350
|
+
alwaysMatch: {
|
|
351
|
+
platformName: 'iOS',
|
|
352
|
+
'appium:deviceName': 'Dumb',
|
|
353
|
+
'appium:foo': ' '
|
|
354
|
+
}
|
|
378
355
|
}).should.eventually.be.rejectedWith(/blank/);
|
|
379
356
|
});
|
|
380
357
|
|
|
@@ -386,24 +363,21 @@ describe('Desired Capabilities', function () {
|
|
|
386
363
|
'appium:deviceName': 'Delorean'
|
|
387
364
|
}, firstMatch: [{}],
|
|
388
365
|
});
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
366
|
+
try {
|
|
367
|
+
sessionId.should.exist;
|
|
368
|
+
caps.should.eql({
|
|
369
|
+
platformName: 'iOS',
|
|
370
|
+
deviceName: 'Delorean',
|
|
371
|
+
});
|
|
372
|
+
} finally {
|
|
373
|
+
await d.deleteSession();
|
|
374
|
+
}
|
|
395
375
|
});
|
|
396
376
|
|
|
397
377
|
it('should raise an error if w3c capabilities is not a plain JSON object', async function () {
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
} catch (e) {
|
|
402
|
-
e.should.be.instanceof(errors.SessionNotCreatedError);
|
|
403
|
-
continue;
|
|
404
|
-
}
|
|
405
|
-
should.fail('error should have been thrown');
|
|
406
|
-
}
|
|
378
|
+
const testValues = [true, 'string', [], 100];
|
|
379
|
+
// this loop runs in parallel, and does not guarantee all assertions will be made
|
|
380
|
+
await B.map(testValues, (val) => d.createSession(null, null, val).should.eventually.be.rejectedWith(errors.SessionNotCreatedError));
|
|
407
381
|
});
|
|
408
382
|
});
|
|
409
383
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import logCommands from '../../../lib/basedriver/commands/log';
|
|
2
|
-
import
|
|
2
|
+
import { createSandbox } from 'sinon';
|
|
3
3
|
import _ from 'lodash';
|
|
4
4
|
|
|
5
5
|
|
|
@@ -19,10 +19,19 @@ const SUPPORTED_LOG_TYPES = {
|
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
describe('log commands -', function () {
|
|
22
|
+
let sandbox;
|
|
23
|
+
|
|
22
24
|
beforeEach(function () {
|
|
25
|
+
sandbox = createSandbox();
|
|
23
26
|
// reset the supported log types
|
|
24
27
|
logCommands.supportedLogTypes = {};
|
|
28
|
+
logCommands.log = {debug: _.noop};
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
afterEach(function () {
|
|
32
|
+
sandbox.restore();
|
|
25
33
|
});
|
|
34
|
+
|
|
26
35
|
describe('getLogTypes', function () {
|
|
27
36
|
it('should return empty array when no supported log types', async function () {
|
|
28
37
|
(await logCommands.getLogTypes()).should.eql([]);
|
|
@@ -34,8 +43,8 @@ describe('log commands -', function () {
|
|
|
34
43
|
});
|
|
35
44
|
describe('getLog', function () {
|
|
36
45
|
beforeEach(function () {
|
|
37
|
-
|
|
38
|
-
|
|
46
|
+
sandbox.spy(SUPPORTED_LOG_TYPES.one, 'getter');
|
|
47
|
+
sandbox.spy(SUPPORTED_LOG_TYPES.two, 'getter');
|
|
39
48
|
});
|
|
40
49
|
afterEach(function () {
|
|
41
50
|
SUPPORTED_LOG_TYPES.one.getter.restore();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import B from 'bluebird';
|
|
3
3
|
import { DeviceSettings } from '../../lib';
|
|
4
|
-
import
|
|
4
|
+
import { createSandbox } from 'sinon';
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
// wrap these tests in a function so we can export the tests and re-use them
|
|
@@ -10,10 +10,14 @@ function baseDriverUnitTests (DriverClass, defaultCaps = {}) {
|
|
|
10
10
|
// to display the driver under test in report
|
|
11
11
|
const className = DriverClass.name || '(unknown driver)';
|
|
12
12
|
|
|
13
|
+
|
|
13
14
|
describe(`BaseDriver (as ${className})`, function () {
|
|
14
15
|
let d, w3cCaps;
|
|
15
16
|
|
|
17
|
+
let sandbox;
|
|
18
|
+
|
|
16
19
|
beforeEach(function () {
|
|
20
|
+
sandbox = createSandbox();
|
|
17
21
|
d = new DriverClass();
|
|
18
22
|
w3cCaps = {
|
|
19
23
|
alwaysMatch: Object.assign({}, defaultCaps, {
|
|
@@ -25,6 +29,7 @@ function baseDriverUnitTests (DriverClass, defaultCaps = {}) {
|
|
|
25
29
|
});
|
|
26
30
|
afterEach(async function () {
|
|
27
31
|
await d.deleteSession();
|
|
32
|
+
sandbox.restore();
|
|
28
33
|
});
|
|
29
34
|
|
|
30
35
|
it('should report the version of BaseDriver used', function () {
|
|
@@ -345,7 +350,7 @@ function baseDriverUnitTests (DriverClass, defaultCaps = {}) {
|
|
|
345
350
|
|
|
346
351
|
describe('#proxyRouteIsAvoided', function () {
|
|
347
352
|
it('should validate form of avoidance list', function () {
|
|
348
|
-
const avoidStub =
|
|
353
|
+
const avoidStub = sandbox.stub(d, 'getProxyAvoidList');
|
|
349
354
|
avoidStub.returns([['POST', /\/foo/], ['GET']]);
|
|
350
355
|
(() => { d.proxyRouteIsAvoided(); }).should.throw;
|
|
351
356
|
avoidStub.returns([['POST', /\/foo/], ['GET', /^foo/, 'bar']]);
|
|
@@ -353,31 +358,31 @@ function baseDriverUnitTests (DriverClass, defaultCaps = {}) {
|
|
|
353
358
|
avoidStub.restore();
|
|
354
359
|
});
|
|
355
360
|
it('should reject bad http methods', function () {
|
|
356
|
-
const avoidStub =
|
|
361
|
+
const avoidStub = sandbox.stub(d, 'getProxyAvoidList');
|
|
357
362
|
avoidStub.returns([['POST', /^foo/], ['BAZETE', /^bar/]]);
|
|
358
363
|
(() => { d.proxyRouteIsAvoided(); }).should.throw;
|
|
359
364
|
avoidStub.restore();
|
|
360
365
|
});
|
|
361
366
|
it('should reject non-regex routes', function () {
|
|
362
|
-
const avoidStub =
|
|
367
|
+
const avoidStub = sandbox.stub(d, 'getProxyAvoidList');
|
|
363
368
|
avoidStub.returns([['POST', /^foo/], ['GET', '/bar']]);
|
|
364
369
|
(() => { d.proxyRouteIsAvoided(); }).should.throw;
|
|
365
370
|
avoidStub.restore();
|
|
366
371
|
});
|
|
367
372
|
it('should return true for routes in the avoid list', function () {
|
|
368
|
-
const avoidStub =
|
|
373
|
+
const avoidStub = sandbox.stub(d, 'getProxyAvoidList');
|
|
369
374
|
avoidStub.returns([['POST', /^\/foo/]]);
|
|
370
375
|
d.proxyRouteIsAvoided(null, 'POST', '/foo/bar').should.be.true;
|
|
371
376
|
avoidStub.restore();
|
|
372
377
|
});
|
|
373
378
|
it('should strip away any wd/hub prefix', function () {
|
|
374
|
-
const avoidStub =
|
|
379
|
+
const avoidStub = sandbox.stub(d, 'getProxyAvoidList');
|
|
375
380
|
avoidStub.returns([['POST', /^\/foo/]]);
|
|
376
381
|
d.proxyRouteIsAvoided(null, 'POST', '/foo/bar').should.be.true;
|
|
377
382
|
avoidStub.restore();
|
|
378
383
|
});
|
|
379
384
|
it('should return false for routes not in the avoid list', function () {
|
|
380
|
-
const avoidStub =
|
|
385
|
+
const avoidStub = sandbox.stub(d, 'getProxyAvoidList');
|
|
381
386
|
avoidStub.returns([['POST', /^\/foo/]]);
|
|
382
387
|
d.proxyRouteIsAvoided(null, 'GET', '/foo/bar').should.be.false;
|
|
383
388
|
d.proxyRouteIsAvoided(null, 'POST', '/boo').should.be.false;
|
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
import BaseDriver from '../../lib';
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { createSandbox } from 'sinon';
|
|
6
3
|
|
|
7
4
|
describe('timeout', function () {
|
|
8
5
|
let driver = new BaseDriver();
|
|
9
|
-
let implicitWaitSpy
|
|
10
|
-
|
|
11
|
-
implicitWaitSpy = sinon.spy(driver, 'setImplicitWait');
|
|
12
|
-
newCommandTimeoutSpy = sinon.spy(driver, 'setNewCommandTimeout');
|
|
13
|
-
});
|
|
6
|
+
let implicitWaitSpy;
|
|
7
|
+
let sandbox;
|
|
14
8
|
beforeEach(function () {
|
|
9
|
+
sandbox = createSandbox();
|
|
15
10
|
driver.implicitWaitMs = 0;
|
|
11
|
+
implicitWaitSpy = sandbox.spy(driver, 'setImplicitWait');
|
|
16
12
|
});
|
|
17
13
|
afterEach(function () {
|
|
18
|
-
|
|
19
|
-
newCommandTimeoutSpy.resetHistory();
|
|
14
|
+
sandbox.restore();
|
|
20
15
|
});
|
|
21
16
|
describe('timeouts', function () {
|
|
22
17
|
describe('errors', function () {
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
|
|
10
|
-
require("source-map-support/register");
|
|
11
|
-
|
|
12
|
-
var _lruCache = _interopRequireDefault(require("lru-cache"));
|
|
13
|
-
|
|
14
|
-
var _support = require("@appium/support");
|
|
15
|
-
|
|
16
|
-
var _constants = require("../constants");
|
|
17
|
-
|
|
18
|
-
const GENERIC_PROTOCOL = 'GENERIC';
|
|
19
|
-
|
|
20
|
-
const mjsonwpLog = _support.logger.getLogger('MJSONWP');
|
|
21
|
-
|
|
22
|
-
const w3cLog = _support.logger.getLogger('W3C');
|
|
23
|
-
|
|
24
|
-
const genericProtocolLog = _support.logger.getLogger(GENERIC_PROTOCOL);
|
|
25
|
-
|
|
26
|
-
class SessionsCache {
|
|
27
|
-
constructor(max) {
|
|
28
|
-
this._cache = new _lruCache.default({
|
|
29
|
-
max
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
getLogger(sessionId, protocol) {
|
|
34
|
-
if (sessionId) {
|
|
35
|
-
if (this._cache.has(sessionId)) {
|
|
36
|
-
const value = this._cache.get(sessionId);
|
|
37
|
-
|
|
38
|
-
if (value.logger) {
|
|
39
|
-
return value.logger;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
protocol = protocol || value.protocol;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return _support.logger.getLogger(`${protocol || GENERIC_PROTOCOL} ` + `(${sessionId.substring(0, Math.min(sessionId.length, 8))})`);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
switch (protocol) {
|
|
49
|
-
case _constants.PROTOCOLS.W3C:
|
|
50
|
-
return w3cLog;
|
|
51
|
-
|
|
52
|
-
case _constants.PROTOCOLS.MJSONWP:
|
|
53
|
-
return mjsonwpLog;
|
|
54
|
-
|
|
55
|
-
default:
|
|
56
|
-
return genericProtocolLog;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
getProtocol(sessionId) {
|
|
61
|
-
return (this._cache.get(sessionId) || {}).protocol;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
putSession(sessionId, value) {
|
|
65
|
-
if (sessionId && value) {
|
|
66
|
-
this._cache.set(sessionId, {
|
|
67
|
-
protocol: value,
|
|
68
|
-
logger: this.getLogger(sessionId, value)
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return value;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
resetLogger(sessionId) {
|
|
76
|
-
if (this._cache.has(sessionId)) {
|
|
77
|
-
this._cache.get(sessionId).logger = null;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const SESSIONS_CACHE = new SessionsCache(100);
|
|
84
|
-
var _default = SESSIONS_CACHE;
|
|
85
|
-
exports.default = _default;require('source-map-support').install();
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImxpYi9wcm90b2NvbC9zZXNzaW9ucy1jYWNoZS5qcyJdLCJuYW1lcyI6WyJHRU5FUklDX1BST1RPQ09MIiwibWpzb253cExvZyIsImxvZ2dlciIsImdldExvZ2dlci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