@appium/base-driver 8.5.7 → 8.7.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.
Files changed (74) hide show
  1. package/build/lib/basedriver/capabilities.js +2 -2
  2. package/build/lib/basedriver/commands/execute.d.ts +11 -0
  3. package/build/lib/basedriver/commands/execute.d.ts.map +1 -0
  4. package/build/lib/basedriver/commands/execute.js +62 -0
  5. package/build/lib/basedriver/commands/index.d.ts +1 -1
  6. package/build/lib/basedriver/commands/index.d.ts.map +1 -1
  7. package/build/lib/basedriver/commands/index.js +5 -2
  8. package/build/lib/basedriver/commands/log.js +2 -4
  9. package/build/lib/basedriver/core.d.ts +11 -0
  10. package/build/lib/basedriver/core.d.ts.map +1 -1
  11. package/build/lib/basedriver/core.js +6 -1
  12. package/build/lib/basedriver/helpers.js +2 -2
  13. package/build/lib/express/server.d.ts +70 -7
  14. package/build/lib/express/server.d.ts.map +1 -1
  15. package/build/lib/express/server.js +19 -16
  16. package/build/lib/express/websocket.d.ts +12 -30
  17. package/build/lib/express/websocket.d.ts.map +1 -1
  18. package/build/lib/express/websocket.js +6 -4
  19. package/build/lib/index.d.ts +12 -180
  20. package/build/lib/index.d.ts.map +1 -1
  21. package/build/lib/index.js +107 -80
  22. package/build/lib/jsonwp-proxy/protocol-converter.js +2 -4
  23. package/build/lib/jsonwp-proxy/proxy.js +3 -7
  24. package/build/lib/protocol/index.d.ts +3 -1
  25. package/build/lib/protocol/index.js +13 -1
  26. package/build/lib/protocol/protocol.d.ts +8 -4
  27. package/build/lib/protocol/protocol.d.ts.map +1 -1
  28. package/build/lib/protocol/protocol.js +7 -7
  29. package/build/lib/protocol/routes.js +2 -6
  30. package/build/tsconfig.tsbuildinfo +1 -1
  31. package/lib/basedriver/commands/execute.js +65 -0
  32. package/lib/basedriver/commands/index.js +3 -1
  33. package/lib/basedriver/core.js +15 -0
  34. package/lib/express/server.js +126 -36
  35. package/lib/express/websocket.js +13 -11
  36. package/lib/index.js +19 -61
  37. package/lib/protocol/index.js +4 -0
  38. package/lib/protocol/protocol.js +10 -3
  39. package/package.json +17 -15
  40. package/build/test/basedriver/README.md +0 -5
  41. package/build/test/basedriver/driver-e2e-tests.js +0 -413
  42. package/build/test/basedriver/driver-tests.js +0 -572
  43. package/build/test/basedriver/index.js +0 -26
  44. package/build/test/e2e/basedriver/driver.e2e.spec.js +0 -15
  45. package/build/test/e2e/basedriver/helpers.e2e.spec.js +0 -192
  46. package/build/test/e2e/basedriver/websockets.e2e.spec.js +0 -87
  47. package/build/test/e2e/express/server.e2e.spec.js +0 -159
  48. package/build/test/e2e/jsonwp-proxy/proxy.e2e.spec.js +0 -59
  49. package/build/test/e2e/protocol/fake-driver.js +0 -163
  50. package/build/test/e2e/protocol/helpers.js +0 -25
  51. package/build/test/e2e/protocol/protocol.e2e.spec.js +0 -1186
  52. package/build/test/helpers.js +0 -55
  53. package/build/test/unit/basedriver/capabilities.spec.js +0 -672
  54. package/build/test/unit/basedriver/capability.spec.js +0 -353
  55. package/build/test/unit/basedriver/commands/event.spec.js +0 -110
  56. package/build/test/unit/basedriver/commands/log.spec.js +0 -92
  57. package/build/test/unit/basedriver/device-settings.spec.js +0 -97
  58. package/build/test/unit/basedriver/driver.spec.js +0 -15
  59. package/build/test/unit/basedriver/helpers.spec.js +0 -151
  60. package/build/test/unit/basedriver/timeout.spec.js +0 -135
  61. package/build/test/unit/express/server.spec.js +0 -155
  62. package/build/test/unit/express/static.spec.js +0 -26
  63. package/build/test/unit/jsonwp-proxy/mock-request.js +0 -91
  64. package/build/test/unit/jsonwp-proxy/protocol-converter.spec.js +0 -171
  65. package/build/test/unit/jsonwp-proxy/proxy.spec.js +0 -292
  66. package/build/test/unit/jsonwp-proxy/url.spec.js +0 -165
  67. package/build/test/unit/jsonwp-status/status.spec.js +0 -34
  68. package/build/test/unit/protocol/errors.spec.js +0 -390
  69. package/build/test/unit/protocol/routes.spec.js +0 -80
  70. package/build/test/unit/protocol/validator.spec.js +0 -149
  71. package/test/basedriver/README.md +0 -5
  72. package/test/basedriver/driver-e2e-tests.js +0 -386
  73. package/test/basedriver/driver-tests.js +0 -624
  74. package/test/basedriver/index.js +0 -6
@@ -1,624 +0,0 @@
1
- import _ from 'lodash';
2
- import B from 'bluebird';
3
- import {DeviceSettings} from '../../lib';
4
- import {createSandbox} from 'sinon';
5
-
6
- // wrap these tests in a function so we can export the tests and re-use them
7
- // for actual driver implementations
8
- function baseDriverUnitTests(DriverClass, defaultCaps = {}) {
9
- // to display the driver under test in report
10
- const className = DriverClass.name || '(unknown driver)';
11
-
12
- describe('static property', function () {
13
- describe('baseVersion', function () {
14
- it('should exist', function () {
15
- DriverClass.baseVersion.should.exist;
16
- });
17
- });
18
- });
19
-
20
- describe('Log prefix', function () {
21
- it('should setup log prefix', async function () {
22
- const d = new DriverClass();
23
- const previousPrefix = d.log.prefix;
24
- await d.createSession({
25
- alwaysMatch: Object.assign({}, defaultCaps, {
26
- platformName: 'Fake',
27
- 'appium:deviceName': 'Commodore 64',
28
- }),
29
- firstMatch: [{}],
30
- });
31
- try {
32
- previousPrefix.should.not.eql(d.log.prefix);
33
- } finally {
34
- await d.deleteSession();
35
- previousPrefix.should.eql(d.log.prefix);
36
- }
37
- });
38
- });
39
-
40
- describe(`BaseDriver (as ${className})`, function () {
41
- let d, w3cCaps;
42
-
43
- let sandbox;
44
-
45
- beforeEach(function () {
46
- sandbox = createSandbox();
47
- d = new DriverClass();
48
- w3cCaps = {
49
- alwaysMatch: Object.assign({}, defaultCaps, {
50
- platformName: 'Fake',
51
- 'appium:deviceName': 'Commodore 64',
52
- }),
53
- firstMatch: [{}],
54
- };
55
- });
56
- afterEach(async function () {
57
- await d.deleteSession();
58
- sandbox.restore();
59
- });
60
-
61
- it('should report the version of BaseDriver used', function () {
62
- should.exist(DriverClass.baseVersion);
63
- });
64
-
65
- it('should return an empty status object', async function () {
66
- let status = await d.getStatus();
67
- status.should.eql({});
68
- });
69
-
70
- it('should return a sessionId from createSession', async function () {
71
- let [sessId] = await d.createSession(null, null, w3cCaps);
72
- should.exist(sessId);
73
- sessId.should.be.a('string');
74
- sessId.length.should.be.above(5);
75
- });
76
-
77
- it('should not be able to start two sessions without closing the first', async function () {
78
- await d.createSession(null, null, _.cloneDeep(w3cCaps));
79
- await d
80
- .createSession(null, null, _.cloneDeep(w3cCaps))
81
- .should.eventually.be.rejectedWith('session');
82
- });
83
-
84
- it('should be able to delete a session', async function () {
85
- let sessionId1 = await d.createSession(null, null, _.cloneDeep(w3cCaps));
86
- await d.deleteSession();
87
- should.equal(d.sessionId, null);
88
- let sessionId2 = await d.createSession(null, null, _.cloneDeep(w3cCaps));
89
- sessionId1.should.not.eql(sessionId2);
90
- });
91
-
92
- it('should get the current session', async function () {
93
- let [, caps] = await d.createSession(null, null, w3cCaps);
94
- caps.should.equal(await d.getSession());
95
- });
96
-
97
- it('should return sessions if no session exists', async function () {
98
- let sessions = await d.getSessions();
99
- sessions.length.should.equal(0);
100
- });
101
-
102
- it('should return sessions', async function () {
103
- const caps = _.clone(w3cCaps);
104
- caps.a = 'cap';
105
- await d.createSession(null, null, caps);
106
- let sessions = await d.getSessions();
107
-
108
- sessions.length.should.equal(1);
109
- sessions[0].should.include({
110
- id: d.sessionId,
111
- });
112
- sessions[0].capabilities.should.include({
113
- deviceName: 'Commodore 64',
114
- platformName: 'Fake',
115
- });
116
- });
117
-
118
- it('should fulfill an unexpected driver quit promise', async function () {
119
- // make a command that will wait a bit so we can crash while it's running
120
- d.getStatus = async function () {
121
- await B.delay(1000);
122
- return 'good status';
123
- }.bind(d);
124
- let cmdPromise = d.executeCommand('getStatus');
125
- await B.delay(10);
126
- const p = new B((resolve, reject) => {
127
- setTimeout(
128
- () =>
129
- reject(
130
- new Error(
131
- 'onUnexpectedShutdown event is expected to be fired within 5 seconds timeout'
132
- )
133
- ),
134
- 5000
135
- );
136
- d.onUnexpectedShutdown(resolve);
137
- });
138
- d.startUnexpectedShutdown(new Error('We crashed'));
139
- await cmdPromise.should.be.rejectedWith(/We crashed/);
140
- await p;
141
- });
142
-
143
- it('should not allow commands in middle of unexpected shutdown', async function () {
144
- // make a command that will wait a bit so we can crash while it's running
145
- d.oldDeleteSession = d.deleteSession;
146
- d.deleteSession = async function () {
147
- await B.delay(100);
148
- await this.oldDeleteSession();
149
- }.bind(d);
150
- await d.createSession(null, null, w3cCaps);
151
- const p = new B((resolve, reject) => {
152
- setTimeout(
153
- () =>
154
- reject(
155
- new Error(
156
- 'onUnexpectedShutdown event is expected to be fired within 5 seconds timeout'
157
- )
158
- ),
159
- 5000
160
- );
161
- d.onUnexpectedShutdown(resolve);
162
- });
163
- d.startUnexpectedShutdown(new Error('We crashed'));
164
- await p;
165
- await d.executeCommand('getSession').should.be.rejectedWith(/shut down/);
166
- });
167
-
168
- it('should allow new commands after done shutting down', async function () {
169
- // make a command that will wait a bit so we can crash while it's running
170
- d.oldDeleteSession = d.deleteSession;
171
- d.deleteSession = async function () {
172
- await B.delay(100);
173
- await this.oldDeleteSession();
174
- }.bind(d);
175
-
176
- await d.createSession(null, null, _.cloneDeep(w3cCaps));
177
- const p = new B((resolve, reject) => {
178
- setTimeout(
179
- () =>
180
- reject(
181
- new Error(
182
- 'onUnexpectedShutdown event is expected to be fired within 5 seconds timeout'
183
- )
184
- ),
185
- 5000
186
- );
187
- d.onUnexpectedShutdown(resolve);
188
- });
189
- d.startUnexpectedShutdown(new Error('We crashed'));
190
- await p;
191
-
192
- await d.executeCommand('getSession').should.be.rejectedWith(/shut down/);
193
- await B.delay(500);
194
-
195
- await d.executeCommand('createSession', null, null, _.cloneDeep(w3cCaps));
196
- await d.deleteSession();
197
- });
198
-
199
- it('should distinguish between W3C and JSONWP session', async function () {
200
- // Test W3C (leave first 2 args null because those are the JSONWP args)
201
- await d.executeCommand('createSession', null, null, {
202
- alwaysMatch: Object.assign({}, defaultCaps, {
203
- platformName: 'Fake',
204
- 'appium:deviceName': 'Commodore 64',
205
- }),
206
- firstMatch: [{}],
207
- });
208
-
209
- d.protocol.should.equal('W3C');
210
- });
211
-
212
- describe('protocol detection', function () {
213
- it('should use W3C if only W3C caps are provided', async function () {
214
- await d.createSession(null, null, {
215
- alwaysMatch: _.clone(defaultCaps),
216
- firstMatch: [{}],
217
- });
218
- d.protocol.should.equal('W3C');
219
- });
220
- });
221
-
222
- it('should have a method to get driver for a session', async function () {
223
- let [sessId] = await d.createSession(null, null, w3cCaps);
224
- d.driverForSession(sessId).should.eql(d);
225
- });
226
-
227
- describe('command queue', function () {
228
- let d = new DriverClass();
229
-
230
- let waitMs = 10;
231
- d.getStatus = async function () {
232
- await B.delay(waitMs);
233
- return Date.now();
234
- }.bind(d);
235
-
236
- d.getSessions = async function () {
237
- await B.delay(waitMs);
238
- throw new Error('multipass');
239
- }.bind(d);
240
-
241
- afterEach(async function () {
242
- await d.clearNewCommandTimeout();
243
- });
244
-
245
- it('should queue commands and.executeCommand/respond in the order received', async function () {
246
- let numCmds = 10;
247
- let cmds = [];
248
- for (let i = 0; i < numCmds; i++) {
249
- cmds.push(d.executeCommand('getStatus'));
250
- }
251
- let results = await B.all(cmds);
252
- for (let i = 1; i < numCmds; i++) {
253
- if (results[i] <= results[i - 1]) {
254
- throw new Error('Got result out of order');
255
- }
256
- }
257
- });
258
-
259
- it('should handle errors correctly when queuing', async function () {
260
- let numCmds = 10;
261
- let cmds = [];
262
- for (let i = 0; i < numCmds; i++) {
263
- if (i === 5) {
264
- cmds.push(d.executeCommand('getSessions'));
265
- } else {
266
- cmds.push(d.executeCommand('getStatus'));
267
- }
268
- }
269
- let results = await B.settle(cmds);
270
- for (let i = 1; i < 5; i++) {
271
- if (results[i].value() <= results[i - 1].value()) {
272
- throw new Error('Got result out of order');
273
- }
274
- }
275
- results[5].reason().message.should.contain('multipass');
276
- for (let i = 7; i < numCmds; i++) {
277
- if (results[i].value() <= results[i - 1].value()) {
278
- throw new Error('Got result out of order');
279
- }
280
- }
281
- });
282
-
283
- it('should not care if queue empties for a bit', async function () {
284
- let numCmds = 10;
285
- let cmds = [];
286
- for (let i = 0; i < numCmds; i++) {
287
- cmds.push(d.executeCommand('getStatus'));
288
- }
289
- let results = await B.all(cmds);
290
- cmds = [];
291
- for (let i = 0; i < numCmds; i++) {
292
- cmds.push(d.executeCommand('getStatus'));
293
- }
294
- results = await B.all(cmds);
295
- for (let i = 1; i < numCmds; i++) {
296
- if (results[i] <= results[i - 1]) {
297
- throw new Error('Got result out of order');
298
- }
299
- }
300
- });
301
- });
302
-
303
- describe('timeouts', function () {
304
- before(async function () {
305
- await d.createSession(null, null, w3cCaps);
306
- });
307
- describe('command', function () {
308
- it('should exist by default', function () {
309
- d.newCommandTimeoutMs.should.equal(60000);
310
- });
311
- it('should be settable through `timeouts`', async function () {
312
- await d.timeouts('command', 20);
313
- d.newCommandTimeoutMs.should.equal(20);
314
- });
315
- });
316
- describe('implicit', function () {
317
- it('should not exist by default', function () {
318
- d.implicitWaitMs.should.equal(0);
319
- });
320
- it('should be settable through `timeouts`', async function () {
321
- await d.timeouts('implicit', 20);
322
- d.implicitWaitMs.should.equal(20);
323
- });
324
- });
325
- });
326
-
327
- describe('timeouts (W3C)', function () {
328
- beforeEach(async function () {
329
- await d.createSession(null, null, w3cCaps);
330
- });
331
- afterEach(async function () {
332
- await d.deleteSession();
333
- });
334
- it('should get timeouts that we set', async function () {
335
- await d.timeouts(undefined, undefined, undefined, undefined, 1000);
336
- await d.getTimeouts().should.eventually.have.property('implicit', 1000);
337
- await d.timeouts('command', 2000);
338
- await d.getTimeouts().should.eventually.deep.equal({
339
- implicit: 1000,
340
- command: 2000,
341
- });
342
- await d.timeouts(undefined, undefined, undefined, undefined, 3000);
343
- await d.getTimeouts().should.eventually.deep.equal({
344
- implicit: 3000,
345
- command: 2000,
346
- });
347
- });
348
- });
349
-
350
- describe('reset compatibility', function () {
351
- it('should not allow both fullReset and noReset to be true', async function () {
352
- const newCaps = {
353
- alwaysMatch: Object.assign({}, defaultCaps, {
354
- platformName: 'Fake',
355
- 'appium:deviceName': 'Commodore 64',
356
- 'appium:fullReset': true,
357
- 'appium:noReset': true,
358
- }),
359
- };
360
- await d
361
- .createSession(null, null, newCaps)
362
- .should.eventually.be.rejectedWith(/noReset.+fullReset/);
363
- });
364
- });
365
-
366
- describe('proxying', function () {
367
- let sessId;
368
- beforeEach(async function () {
369
- [sessId] = await d.createSession(null, null, w3cCaps);
370
- });
371
- describe('#proxyActive', function () {
372
- it('should exist', function () {
373
- d.proxyActive.should.be.an.instanceof(Function);
374
- });
375
- it('should return false', function () {
376
- d.proxyActive(sessId).should.be.false;
377
- });
378
- it('should throw an error when sessionId is wrong', function () {
379
- (() => {
380
- d.proxyActive('aaa');
381
- }).should.throw;
382
- });
383
- });
384
-
385
- describe('#getProxyAvoidList', function () {
386
- it('should exist', function () {
387
- d.getProxyAvoidList.should.be.an.instanceof(Function);
388
- });
389
- it('should return an array', function () {
390
- d.getProxyAvoidList(sessId).should.be.an.instanceof(Array);
391
- });
392
- it('should throw an error when sessionId is wrong', function () {
393
- (() => {
394
- d.getProxyAvoidList('aaa');
395
- }).should.throw;
396
- });
397
- });
398
-
399
- describe('#canProxy', function () {
400
- it('should have a #canProxy method', function () {
401
- d.canProxy.should.be.an.instanceof(Function);
402
- });
403
- it('should return a boolean from #canProxy', function () {
404
- d.canProxy(sessId).should.be.a('boolean');
405
- });
406
- it('should throw an error when sessionId is wrong', function () {
407
- (() => {
408
- d.canProxy();
409
- }).should.throw;
410
- });
411
- });
412
-
413
- describe('#proxyRouteIsAvoided', function () {
414
- it('should validate form of avoidance list', function () {
415
- const avoidStub = sandbox.stub(d, 'getProxyAvoidList');
416
- avoidStub.returns([['POST', /\/foo/], ['GET']]);
417
- (() => {
418
- d.proxyRouteIsAvoided();
419
- }).should.throw;
420
- avoidStub.returns([
421
- ['POST', /\/foo/],
422
- ['GET', /^foo/, 'bar'],
423
- ]);
424
- (() => {
425
- d.proxyRouteIsAvoided();
426
- }).should.throw;
427
- avoidStub.restore();
428
- });
429
- it('should reject bad http methods', function () {
430
- const avoidStub = sandbox.stub(d, 'getProxyAvoidList');
431
- avoidStub.returns([
432
- ['POST', /^foo/],
433
- ['BAZETE', /^bar/],
434
- ]);
435
- (() => {
436
- d.proxyRouteIsAvoided();
437
- }).should.throw;
438
- avoidStub.restore();
439
- });
440
- it('should reject non-regex routes', function () {
441
- const avoidStub = sandbox.stub(d, 'getProxyAvoidList');
442
- avoidStub.returns([
443
- ['POST', /^foo/],
444
- ['GET', '/bar'],
445
- ]);
446
- (() => {
447
- d.proxyRouteIsAvoided();
448
- }).should.throw;
449
- avoidStub.restore();
450
- });
451
- it('should return true for routes in the avoid list', function () {
452
- const avoidStub = sandbox.stub(d, 'getProxyAvoidList');
453
- avoidStub.returns([['POST', /^\/foo/]]);
454
- d.proxyRouteIsAvoided(null, 'POST', '/foo/bar').should.be.true;
455
- avoidStub.restore();
456
- });
457
- it('should strip away any wd/hub prefix', function () {
458
- const avoidStub = sandbox.stub(d, 'getProxyAvoidList');
459
- avoidStub.returns([['POST', /^\/foo/]]);
460
- d.proxyRouteIsAvoided(null, 'POST', '/foo/bar').should.be.true;
461
- avoidStub.restore();
462
- });
463
- it('should return false for routes not in the avoid list', function () {
464
- const avoidStub = sandbox.stub(d, 'getProxyAvoidList');
465
- avoidStub.returns([['POST', /^\/foo/]]);
466
- d.proxyRouteIsAvoided(null, 'GET', '/foo/bar').should.be.false;
467
- d.proxyRouteIsAvoided(null, 'POST', '/boo').should.be.false;
468
- avoidStub.restore();
469
- });
470
- });
471
- });
472
-
473
- describe('event timing framework', function () {
474
- let beforeStartTime;
475
- beforeEach(async function () {
476
- beforeStartTime = Date.now();
477
- d.shouldValidateCaps = false;
478
- await d.executeCommand('createSession', null, null, {
479
- alwaysMatch: {...defaultCaps},
480
- firstMatch: [{}],
481
- });
482
- });
483
- describe('#eventHistory', function () {
484
- it('should have an eventHistory property', function () {
485
- should.exist(d.eventHistory);
486
- should.exist(d.eventHistory.commands);
487
- });
488
-
489
- it('should have a session start timing after session start', function () {
490
- let {newSessionRequested, newSessionStarted} = d.eventHistory;
491
- newSessionRequested.should.have.length(1);
492
- newSessionStarted.should.have.length(1);
493
- newSessionRequested[0].should.be.a('number');
494
- newSessionStarted[0].should.be.a('number');
495
- (newSessionRequested[0] >= beforeStartTime).should.be.true;
496
- (newSessionStarted[0] >= newSessionRequested[0]).should.be.true;
497
- });
498
-
499
- it('should include a commands list', async function () {
500
- await d.executeCommand('getStatus', []);
501
- d.eventHistory.commands.length.should.equal(2);
502
- d.eventHistory.commands[1].cmd.should.equal('getStatus');
503
- d.eventHistory.commands[1].startTime.should.be.a('number');
504
- d.eventHistory.commands[1].endTime.should.be.a('number');
505
- });
506
- });
507
- describe('#logEvent', function () {
508
- it('should allow logging arbitrary events', function () {
509
- d.logEvent('foo');
510
- d.eventHistory.foo[0].should.be.a('number');
511
- (d.eventHistory.foo[0] >= beforeStartTime).should.be.true;
512
- });
513
- it('should not allow reserved or oddly formed event names', function () {
514
- (() => {
515
- d.logEvent('commands');
516
- }).should.throw();
517
- (() => {
518
- d.logEvent(1);
519
- }).should.throw();
520
- (() => {
521
- d.logEvent({});
522
- }).should.throw();
523
- });
524
- });
525
- it('should allow logging the same event multiple times', function () {
526
- d.logEvent('bar');
527
- d.logEvent('bar');
528
- d.eventHistory.bar.should.have.length(2);
529
- d.eventHistory.bar[1].should.be.a('number');
530
- (d.eventHistory.bar[1] >= d.eventHistory.bar[0]).should.be.true;
531
- });
532
- describe('getSession decoration', function () {
533
- it('should decorate getSession response if opt-in cap is provided', async function () {
534
- let res = await d.getSession();
535
- should.not.exist(res.events);
536
-
537
- d.caps.eventTimings = true;
538
- res = await d.getSession();
539
- should.exist(res.events);
540
- should.exist(res.events.newSessionRequested);
541
- res.events.newSessionRequested[0].should.be.a('number');
542
- });
543
- });
544
- });
545
- describe('.reset', function () {
546
- it('should reset as W3C if the original session was W3C', async function () {
547
- const caps = {
548
- alwaysMatch: Object.assign(
549
- {},
550
- {
551
- 'appium:app': 'Fake',
552
- 'appium:deviceName': 'Fake',
553
- 'appium:automationName': 'Fake',
554
- platformName: 'Fake',
555
- },
556
- defaultCaps
557
- ),
558
- firstMatch: [{}],
559
- };
560
- await d.createSession(undefined, undefined, caps);
561
- d.protocol.should.equal('W3C');
562
- await d.reset();
563
- d.protocol.should.equal('W3C');
564
- });
565
- });
566
- });
567
-
568
- describe('DeviceSettings', function () {
569
- it('should not hold on to reference of defaults in constructor', function () {
570
- let obj = {foo: 'bar'};
571
- let d1 = new DeviceSettings(obj);
572
- let d2 = new DeviceSettings(obj);
573
- d1._settings.foo = 'baz';
574
- d1._settings.should.not.eql(d2._settings);
575
- });
576
- });
577
-
578
- describe('.isFeatureEnabled', function () {
579
- const d = new DriverClass();
580
-
581
- afterEach(function () {
582
- d.denyInsecure = null;
583
- d.allowInsecure = null;
584
- d.relaxedSecurityEnabled = null;
585
- });
586
-
587
- it('should say a feature is enabled when it is explicitly allowed', function () {
588
- d.allowInsecure = ['foo', 'bar'];
589
- d.isFeatureEnabled('foo').should.be.true;
590
- d.isFeatureEnabled('bar').should.be.true;
591
- d.isFeatureEnabled('baz').should.be.false;
592
- });
593
-
594
- it('should say a feature is not enabled if it is not enabled', function () {
595
- d.allowInsecure = [];
596
- d.isFeatureEnabled('foo').should.be.false;
597
- });
598
-
599
- it('should prefer denyInsecure to allowInsecure', function () {
600
- d.allowInsecure = ['foo', 'bar'];
601
- d.denyInsecure = ['foo'];
602
- d.isFeatureEnabled('foo').should.be.false;
603
- d.isFeatureEnabled('bar').should.be.true;
604
- d.isFeatureEnabled('baz').should.be.false;
605
- });
606
-
607
- it('should allow global setting for insecurity', function () {
608
- d.relaxedSecurityEnabled = true;
609
- d.isFeatureEnabled('foo').should.be.true;
610
- d.isFeatureEnabled('bar').should.be.true;
611
- d.isFeatureEnabled('baz').should.be.true;
612
- });
613
-
614
- it('global setting should be overrideable', function () {
615
- d.relaxedSecurityEnabled = true;
616
- d.denyInsecure = ['foo', 'bar'];
617
- d.isFeatureEnabled('foo').should.be.false;
618
- d.isFeatureEnabled('bar').should.be.false;
619
- d.isFeatureEnabled('baz').should.be.true;
620
- });
621
- });
622
- }
623
-
624
- export default baseDriverUnitTests;
@@ -1,6 +0,0 @@
1
- // transpile:main
2
-
3
- import baseDriverUnitTests from './driver-tests';
4
- import baseDriverE2ETests from './driver-e2e-tests';
5
-
6
- export {baseDriverUnitTests, baseDriverE2ETests};