-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expand file tree
/
Copy pathStaticLifecycleEvents.test.js
More file actions
112 lines (102 loc) · 5.44 KB
/
Copy pathStaticLifecycleEvents.test.js
File metadata and controls
112 lines (102 loc) · 5.44 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
import Utils from './Utils';
import TestIDs from '../playground/src/testIDs';
const { elementByLabel, elementById } = Utils;
describe('static lifecycle events', () => {
beforeEach(async () => {
await device.launchApp({ newInstance: true });
await elementById(TestIDs.NAVIGATION_TAB).tap();
await elementById(TestIDs.SHOW_STATIC_EVENTS_SCREEN).tap();
await elementById(TestIDs.STATIC_EVENTS_OVERLAY_BTN).tap();
await expect(elementByLabel('Static Lifecycle Events Overlay')).toBeVisible();
await expect(elementByLabel('componentWillAppear | EventsOverlay | Component')).toBeVisible();
await expect(elementByLabel('componentDidAppear | EventsOverlay | Component')).toBeVisible();
await elementById(TestIDs.CLEAR_OVERLAY_EVENTS_BTN).tap();
});
it('willAppear didAppear didDisappear', async () => {
await elementById(TestIDs.PUSH_BTN).tap();
await expect(elementByLabel('componentWillAppear | Pushed | Component')).toBeVisible();
await expect(elementByLabel('componentDidAppear | Pushed | Component')).toBeVisible();
await expect(elementByLabel('componentDidDisappear | EventsScreen | Component')).toBeVisible();
});
it('pushing and popping screen dispatch static event', async () => {
await elementById(TestIDs.PUSH_BTN).tap();
await expect(elementByLabel('command started: push')).toBeVisible();
await expect(elementByLabel('command completed: push')).toBeVisible();
await elementById(TestIDs.CLEAR_OVERLAY_EVENTS_BTN).tap();
await elementById(TestIDs.POP_BTN).tap();
await expect(elementByLabel('command started: pop')).toBeVisible();
await expect(elementByLabel('command completed: pop')).toBeVisible();
});
it('showModal and dismissModal dispatch static event', async () => {
await elementById(TestIDs.MODAL_BTN).tap();
await expect(elementByLabel('command started: showModal')).toBeVisible();
await expect(elementByLabel('command completed: showModal')).toBeVisible();
await expect(elementByLabel('componentWillAppear | Modal | Component')).toBeVisible();
await expect(elementByLabel('componentDidAppear | Modal | Component')).toBeVisible();
await expect(elementByLabel('componentDidDisappear | EventsScreen | Component')).toBeVisible();
await elementById(TestIDs.CLEAR_OVERLAY_EVENTS_BTN).tap();
await elementById(TestIDs.DISMISS_MODAL_BTN).tap();
await expect(elementByLabel('command started: dismissModal')).toBeVisible();
await expect(elementByLabel('command completed: dismissModal')).toBeVisible();
await expect(elementByLabel('componentWillAppear | EventsScreen | Component')).toBeVisible();
await expect(elementByLabel('componentDidAppear | EventsScreen | Component')).toBeVisible();
await expect(elementByLabel('componentDidDisappear | Modal | Component')).toBeVisible();
});
it('unmounts when dismissed', async () => {
await elementById(TestIDs.PUSH_BTN).tap();
await elementById(TestIDs.DISMISS_BTN).tap();
await expect(elementByLabel('Overlay Unmounted')).toBeVisible();
await elementByLabel('OK').tap();
});
it('top bar buttons willAppear didAppear didDisappear', async () => {
await elementById(TestIDs.PUSH_BTN).tap();
await elementById(TestIDs.PUSH_OPTIONS_BUTTON).tap();
await elementById(TestIDs.CLEAR_OVERLAY_EVENTS_BTN).tap();
await elementById(TestIDs.GOTO_BUTTONS_SCREEN).tap();
await expect(
elementByLabel('componentWillAppear | CustomRoundedButton | TopBarButton')
).toBeVisible();
await expect(
elementByLabel('componentDidAppear | CustomRoundedButton | TopBarButton')
).toBeVisible();
await elementById(TestIDs.CLEAR_OVERLAY_EVENTS_BTN).tap();
await elementById(TestIDs.RESET_BUTTONS).tap();
await expect(
elementByLabel('componentDidDisappear | CustomRoundedButton | TopBarButton')
).toBeVisible();
});
it('top bar title willAppear didAppear didDisappear', async () => {
await elementById(TestIDs.PUSH_BTN).tap();
await elementById(TestIDs.PUSH_OPTIONS_BUTTON).tap();
await elementById(TestIDs.CLEAR_OVERLAY_EVENTS_BTN).tap();
await elementById(TestIDs.SET_REACT_TITLE_VIEW).tap();
await expect(
elementByLabel('componentWillAppear | ReactTitleView | TopBarTitle')
).toBeVisible();
await expect(elementByLabel('componentDidAppear | ReactTitleView | TopBarTitle')).toBeVisible();
await elementById(TestIDs.CLEAR_OVERLAY_EVENTS_BTN).tap();
await elementById(TestIDs.PUSH_BTN).tap();
await expect(
elementByLabel('componentDidDisappear | ReactTitleView | TopBarTitle')
).toBeVisible();
});
it.e2e('unmounts previous root before resolving setRoot promise', async () => {
await elementById(TestIDs.SET_ROOT_BTN).tap();
await elementById(TestIDs.CLEAR_OVERLAY_EVENTS_BTN).tap();
await elementById(TestIDs.SET_ROOT_BTN).tap();
await expect(elementByLabel('setRoot complete')).toBeVisible();
await expect(elementByLabel('component unmounted')).toBeVisible();
});
it('top bar custom button willAppear didAppear after pop, on a root screen', async () => {
await elementById(TestIDs.SHOW_RIGHT_BUTTON).tap();
await elementById(TestIDs.PUSH_BTN).tap();
await elementById(TestIDs.CLEAR_OVERLAY_EVENTS_BTN).tap();
await elementById(TestIDs.BACK_BUTTON).tap();
await expect(
elementByLabel('componentWillAppear | CustomRoundedButton | TopBarButton')
).toBeVisible();
await expect(
elementByLabel('componentDidAppear | CustomRoundedButton | TopBarButton')
).toBeVisible();
});
});