forked from wix/react-native-navigation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBottomTabs.test.js
More file actions
192 lines (163 loc) · 7.88 KB
/
BottomTabs.test.js
File metadata and controls
192 lines (163 loc) · 7.88 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
import Utils from './Utils';
import TestIDs from '../src/testIDs';
import Android from './AndroidUtils';
const { elementByLabel, elementById, expectImagesToBeEqual } = Utils;
describe('BottomTabs', () => {
beforeEach(async () => {
await device.launchApp({ newInstance: true });
await elementById(TestIDs.BOTTOM_TABS_BTN).tap();
await expect(elementByLabel('First Tab')).toBeVisible();
});
it.e2e('should mount first tab first', async () => {
await expect(elementById(TestIDs.MOUNTED_SCREENS_TEXT)).toHaveText(
'Mounted screens: FirstBottomTabScreen, SecondBottomTabScreen'
);
});
it('switch to tab by index', async () => {
await elementById(TestIDs.SWITCH_TAB_BY_INDEX_BTN).tap();
await expect(elementByLabel('First Tab')).toBeNotVisible();
await expect(elementByLabel('Second Tab')).toBeVisible();
});
it('switch to tab by componentId', async () => {
await elementById(TestIDs.SWITCH_TAB_BY_COMPONENT_ID_BTN).tap();
await expect(elementByLabel('First Tab')).toBeNotVisible();
await expect(elementByLabel('Second Tab')).toBeVisible();
});
it('push bottom tabs', async () => {
await elementById(TestIDs.SWITCH_TAB_BY_INDEX_BTN).tap();
await elementById(TestIDs.PUSH_BTN).tap();
await expect(elementById(TestIDs.PUSHED_BOTTOM_TABS)).toBeVisible();
});
it('set Tab Bar badge on current Tab', async () => {
await elementById(TestIDs.SET_BADGE_BTN).tap();
await expect(element(by.text('NEW')).atIndex(0)).toBeVisible();
});
it('Badge not cleared after showing/dismissing modal', async () => {
await elementById(TestIDs.SECOND_TAB_BAR_BTN).tap();
await elementById(TestIDs.SET_BADGE_BTN).tap();
await expect(element(by.text('Badge')).atIndex(0)).toBeVisible();
await elementById(TestIDs.MODAL_BTN).tap();
await elementById(TestIDs.MODAL_BTN).tap();
await elementById(TestIDs.DISMISS_MODAL_BTN).tap();
await expect(element(by.text('Badge')).atIndex(0)).toBeVisible();
});
it('set empty string badge on a current Tab should clear badge', async () => {
await elementById(TestIDs.SET_BADGE_BTN).tap();
await expect(element(by.text('NEW')).atIndex(0)).toBeVisible();
await elementById(TestIDs.CLEAR_BADGE_BTN).tap();
await expect(element(by.text('NEW'))).toBeNotVisible();
});
it.e2e('merge options correctly in SideMenu inside BottomTabs layout', async () => {
await elementById(TestIDs.SWITCH_TAB_BY_INDEX_BTN).tap();
await elementById(TestIDs.SIDE_MENU_INSIDE_BOTTOM_TABS_BTN).tap();
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(':android: hide Tab Bar', async () => {
await expect(elementById(TestIDs.BOTTOM_TABS)).toBeVisible();
await elementById(TestIDs.HIDE_TABS_BTN).tap();
await expect(elementById(TestIDs.BOTTOM_TABS)).toBeNotVisible();
});
it(':android: show Tab Bar', async () => {
await elementById(TestIDs.HIDE_TABS_BTN).tap();
await expect(elementById(TestIDs.BOTTOM_TABS)).toBeNotVisible();
await elementById(TestIDs.SHOW_TABS_BTN).tap();
await expect(elementById(TestIDs.BOTTOM_TABS)).toBeVisible();
});
it.e2e(':android: should set special stylizing options in root bottom-tabs', async () => {
await elementById(TestIDs.SCREEN_ROOT_LIST).scrollTo('bottom');
await elementById(TestIDs.SET_ROOT_BTN).tap();
const snapshotImagePath = `./e2e/assets/bottom_tabs.stylized-root.png`;
const actual =
await elementById('RNN.BottomTabsLayoutRoot').takeScreenshot(`bottom_tabs_stylized-root`);
expectImagesToBeEqual(actual, snapshotImagePath);
});
it.e2e(':android: should merge special stylizing options', async () => {
await elementById(TestIDs.SCREEN_ROOT_LIST).scrollTo('bottom');
await elementById(TestIDs.STYLIZE_TABS_BTN).tap();
const snapshotImagePath = `./e2e/assets/bottom_tabs.stylized.png`;
const actual =
await elementById('RNN.BottomTabsLayoutRoot').takeScreenshot(`bottom_tabs_stylized`);
expectImagesToBeEqual(actual, snapshotImagePath);
});
it('hide Tab Bar on push', async () => {
await elementById(TestIDs.HIDE_TABS_PUSH_BTN).tap();
await expect(elementById(TestIDs.BOTTOM_TABS)).toBeNotVisible();
await elementById(TestIDs.POP_BTN).tap();
await expect(elementById(TestIDs.BOTTOM_TABS)).toBeVisible();
});
it('hide Tab Bar on push from second bottomTabs screen', async () => {
await elementById(TestIDs.SWITCH_TAB_BY_INDEX_BTN).tap();
await elementById(TestIDs.HIDE_TABS_PUSH_BTN).tap();
await expect(elementById(TestIDs.BOTTOM_TABS)).toBeNotVisible();
await elementById(TestIDs.POP_BTN).tap();
await expect(elementById(TestIDs.BOTTOM_TABS)).toBeVisible();
});
it('hide Tab Bar on push from second bottomTabs screen - deep stack', async () => {
await elementById(TestIDs.SWITCH_TAB_BY_INDEX_BTN).tap();
await elementById(TestIDs.HIDE_TABS_PUSH_BTN).tap();
await expect(elementById(TestIDs.BOTTOM_TABS)).toBeNotVisible();
await elementById(TestIDs.PUSH_BTN).tap();
await expect(elementById(TestIDs.BOTTOM_TABS)).toBeVisible();
await elementById(TestIDs.POP_BTN).tap();
await expect(elementById(TestIDs.BOTTOM_TABS)).toBeNotVisible();
await elementById(TestIDs.POP_BTN).tap();
await expect(elementById(TestIDs.BOTTOM_TABS)).toBeVisible();
});
it('hide Tab Bar on second tab after pressing the tab', async () => {
await elementById(TestIDs.SECOND_TAB_BAR_BTN).tap();
await elementById(TestIDs.HIDE_TABS_PUSH_BTN).tap();
await expect(elementById(TestIDs.BOTTOM_TABS)).toBeNotVisible();
await elementById(TestIDs.POP_BTN).tap();
await expect(elementById(TestIDs.BOTTOM_TABS)).toBeVisible();
});
it('invoke bottomTabPressed event', async () => {
await elementById(TestIDs.THIRD_TAB_BAR_BTN).tap();
await expect(elementByLabel('BottomTabPressed')).toBeVisible();
await elementByLabel('OK').tap();
await expect(elementByLabel('First Tab')).toBeVisible();
});
it.e2e(':android: hardware back tab selection history', async () => {
await elementById(TestIDs.SECOND_TAB_BAR_BTN).tap();
await elementById(TestIDs.FIRST_TAB_BAR_BUTTON).tap();
await elementById(TestIDs.SECOND_TAB_BAR_BTN).tap();
await elementById(TestIDs.SECOND_TAB_BAR_BTN).tap();
await elementById(TestIDs.FIRST_TAB_BAR_BUTTON).tap();
await Android.pressBack();
await expect(elementByLabel('Second Tab')).toBeVisible();
await Android.pressBack();
await expect(elementByLabel('First Tab')).toBeVisible();
await Android.pressBack();
await expect(elementByLabel('Second Tab')).toBeVisible();
await Android.pressBack();
await expect(elementByLabel('First Tab')).toBeVisible();
await Android.pressBack();
await expect(elementByLabel('First Tab')).toBeNotVisible();
await expect(elementByLabel('Second Tab')).toBeNotVisible();
});
it.e2e('Switch tab should send lifecycle events', async () => {
await elementById(TestIDs.SECOND_TAB_BAR_BTN).tap();
await elementById(TestIDs.STATIC_EVENTS_OVERLAY_BTN).tap();
await elementById(TestIDs.CLEAR_OVERLAY_EVENTS_BTN).tap();
await elementById(TestIDs.FIRST_TAB_BAR_BUTTON).tap();
await expect(
elementByLabel('componentWillAppear | FirstBottomTabsScreen | Component')
).toBeVisible();
await expect(
elementByLabel('componentDidDisappear | SecondBottomTabsScreen | Component')
).toBeVisible();
await expect(
elementByLabel('componentDidAppear | FirstBottomTabsScreen | Component')
).toBeVisible();
});
describe(':ios: BottomTab Role', () => {
beforeEach(async () => {
await device.launchApp({ newInstance: true });
await elementById(TestIDs.BOTTOM_TABS_ROLE_BTN).tap();
});
it('should render a search role tab', async () => {
await expect(elementById(TestIDs.BOTTOM_TABS_ROLE_SEARCH_TAB)).toExist();
});
});
});