-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
36.system.test.js
79 lines (61 loc) · 2.82 KB
/
36.system.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
const {expectToThrow} = require('./utils/custom-expects');
describe('System Dialogs', () => {
describe(':ios: supported', () => {
beforeAll(async () => {
await device.reloadReactNative();
});
describe('request permission dialog', () => {
beforeEach(async () => {
await device.launchApp({
delete: true,
newInstance: true,
});
await element(by.text('System Dialogs')).tap();
});
const permissionStatus = element(by.id('permissionStatus'));
const requestPermissionButton = element(by.id('requestPermissionButton'));
it('should start with `denied` permission status', async () => {
await expect(permissionStatus).toHaveText('denied');
});
it('should tap on permission request alert button by label ("Allow")', async () => {
await requestPermissionButton.tap();
const allowButton = system.element(by.system.label('Allow'));
await expect(allowButton).toExist();
await allowButton.tap();
await expect(permissionStatus).toHaveText('granted');
});
it('should tap on permission request alert button by type and index ("Deny")', async () => {
await requestPermissionButton.tap();
const denyButton = system.element(by.system.type('button')).atIndex(0);
await expect(denyButton).toExist();
await denyButton.tap();
await expect(permissionStatus).toHaveText('blocked');
});
});
it('should not find elements that does not exist', async () => {
await expect(system.element(by.system.label('NonExistent'))).not.toExist();
});
it('should raise when trying to match system element that does not exist', async () => {
await expectToThrow(async () => {
await expect(system.element(by.system.label('NonExistent'))).toExist();
}, 'Expectation failed, element with matcher `label == "NonExistent"` does not exist');
});
it('should raise when trying to tap on system element that does not exist', async () => {
await expectToThrow(async () => {
await system.element(by.system.label('NonExistent')).tap();
}, 'Tap failed, element with matcher `label == "NonExistent"` does not exist');
});
});
describe(':android: not supported on Android', () => {
it('should throw on expectation call', async () => {
await expectToThrow(async () => {
await expect(system.element(by.system.label('Allow'))).toExist();
}, 'System interactions are not supported on Android, use UiDevice APIs directly instead');
});
it('should throw on action call', async () => {
await expectToThrow(async () => {
await system.element(by.system.type('button')).atIndex(0).tap();
}, 'System interactions are not supported on Android, use UiDevice APIs directly instead');
});
});
});