-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expand file tree
/
Copy pathSideMenu.test.js
More file actions
107 lines (90 loc) · 5.14 KB
/
SideMenu.test.js
File metadata and controls
107 lines (90 loc) · 5.14 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import Utils from './Utils';
import TestIDs from '../playground/src/testIDs';
const {elementByLabel, elementById, expectImagesToBeEqual} = Utils;
describe('SideMenu', () => {
beforeEach(async () => {
await device.launchApp({newInstance : true});
await elementById(TestIDs.SIDE_MENU_BTN).tap();
});
describe.each(['aboveContent', 'pushContent'])('Open mode %s', (openMode) => {
beforeEach(async () => {
if (openMode === 'pushContent') {
await elementById(TestIDs.TOGGLE_SIDE_MENU_OPEN_MODE_BTN).tap();
}
});
it('close SideMenu and push to stack with static id', async () => {
await elementById(TestIDs.OPEN_LEFT_SIDE_MENU_BTN).tap();
await elementById(TestIDs.LEFT_SIDE_MENU_PUSH_BTN).tap();
await elementById(TestIDs.CLOSE_LEFT_SIDE_MENU_BTN).tap();
await expect(elementById(TestIDs.PUSHED_SCREEN_HEADER)).toBeVisible();
await elementById(TestIDs.POP_BTN).tap();
await expect(elementById(TestIDs.CENTER_SCREEN_HEADER)).toBeVisible();
});
it('Push to stack with static id and close SideMenu with screen options', async () => {
await elementById(TestIDs.OPEN_LEFT_SIDE_MENU_BTN).tap();
await elementById(TestIDs.LEFT_SIDE_MENU_PUSH_AND_CLOSE_BTN).tap();
await expect(elementById(TestIDs.PUSHED_SCREEN_HEADER)).toBeVisible();
await elementById(TestIDs.POP_BTN).tap();
await expect(elementById(TestIDs.CENTER_SCREEN_HEADER)).toBeVisible();
});
it('side menu visibility - left', async () => {
await elementById(TestIDs.OPEN_LEFT_SIDE_MENU_BTN).tap();
await elementById(TestIDs.CLOSE_LEFT_SIDE_MENU_BTN).tap();
await expect(elementById(TestIDs.CLOSE_LEFT_SIDE_MENU_BTN)).toBeNotVisible();
});
it('side menu visibility - right', async () => {
await elementById(TestIDs.OPEN_RIGHT_SIDE_MENU_BTN).tap();
await elementById(TestIDs.CLOSE_RIGHT_SIDE_MENU_BTN).tap();
await expect(elementById(TestIDs.CLOSE_RIGHT_SIDE_MENU_BTN)).toBeNotVisible();
});
it.e2e('should rotate', async () => {
await elementById(TestIDs.OPEN_LEFT_SIDE_MENU_BTN).tap();
await device.setOrientation('landscape');
await expect(elementById(TestIDs.LEFT_SIDE_MENU_PUSH_BTN)).toBeVisible();
});
it.e2e(':ios: rotation should update drawer height', async () => {
await elementById(TestIDs.OPEN_LEFT_SIDE_MENU_BTN).tap();
await expect(elementByLabel('left drawer height: 869')).toBeVisible();
await device.setOrientation('landscape');
await expect(elementByLabel('left drawer height: 428')).toBeVisible();
await device.setOrientation('portrait');
await expect(elementByLabel('left drawer height: 869')).toBeVisible();
});
it.e2e('should set left drawer width', async () => {
await elementById(TestIDs.OPEN_LEFT_SIDE_MENU_BTN).tap();
await expect(elementById(TestIDs.SIDE_MENU_LEFT_DRAWER_HEIGHT_TEXT)).toBeVisible();
await expect(elementByLabel('left drawer width: 250')).toBeVisible();
});
it.e2e('should change left drawer width', async () => {
await elementById(TestIDs.CHANGE_LEFT_SIDE_MENU_WIDTH_BTN).tap();
await elementById(TestIDs.OPEN_LEFT_SIDE_MENU_BTN).tap();
await expect(elementByLabel('left drawer width: 100')).toBeVisible();
});
it.e2e('should set right drawer width', async () => {
await elementById(TestIDs.OPEN_RIGHT_SIDE_MENU_BTN).tap();
await expect(elementByLabel('right drawer width: 250')).toBeVisible();
});
it.e2e('should change right drawer width', async () => {
await elementById(TestIDs.CHANGE_RIGHT_SIDE_MENU_WIDTH_BTN).tap();
await elementById(TestIDs.OPEN_RIGHT_SIDE_MENU_BTN).tap();
await expect(elementByLabel('right drawer width: 50')).toBeVisible();
});
it.e2e(':ios: should render side menu correctly', async () => {
await elementById(TestIDs.OPEN_LEFT_SIDE_MENU_BTN).tap();
const snapshottedImagePath = `./e2e/assets/side_menu.${openMode}.png`;
const actual =
await elementById('SideMenuContainer').takeScreenshot(`side_menu_${openMode}`);
expectImagesToBeEqual(actual, snapshottedImagePath);
});
});
it.e2e(':ios: should open above-content by default', async () => {
await elementById(TestIDs.TOGGLE_SIDE_MENU_OPEN_MODE_BTN).tap(); // aboveContent --> pushContent
await elementById(TestIDs.TOGGLE_SIDE_MENU_OPEN_MODE_BTN).tap(); // pushContent --> undefined
await expect(elementByLabel('Open mode: undefined')).toBeVisible();
await elementById(TestIDs.OPEN_LEFT_SIDE_MENU_BTN).tap();
const snapshottedImagePath = `./e2e/assets/side_menu.undefined.png`;
const actual =
await elementById('SideMenuContainer').takeScreenshot(`side_menu_undefined`);
expectImagesToBeEqual(actual, snapshottedImagePath);
});
});