Browse Source

V2 e2e Test IDs (#2304)

* refactored e2e tests to work with testIDs

* lint fix

* android e2e fixed
yogevbd 6 years ago
parent
commit
04c578cc4e

+ 39
- 38
e2e/Modals.test.js View File

1
 const Utils = require('./Utils');
1
 const Utils = require('./Utils');
2
+const testIDs = require('../playground/src/testIDs');
2
 
3
 
3
-const elementByLabel = Utils.elementByLabel;
4
+const { elementByLabel, elementById } = Utils;
4
 
5
 
5
 describe('modal', () => {
6
 describe('modal', () => {
6
   beforeEach(async () => {
7
   beforeEach(async () => {
8
   });
9
   });
9
 
10
 
10
   it('show modal', async () => {
11
   it('show modal', async () => {
11
-    await elementByLabel('Show Modal').tap();
12
-    await expect(elementByLabel('Modal Screen')).toBeVisible();
12
+    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
13
+    await expect(elementById(testIDs.MODAL_SCREEN)).toBeVisible();
13
   });
14
   });
14
 
15
 
15
   it('dismiss modal', async () => {
16
   it('dismiss modal', async () => {
16
-    await elementByLabel('Show Modal').tap();
17
-    await expect(elementByLabel('Modal Screen')).toBeVisible();
18
-    await elementByLabel('Dismiss Modal').tap();
19
-    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
17
+    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
18
+    await expect(elementById(testIDs.MODAL_SCREEN)).toBeVisible();
19
+    await elementById(testIDs.DISMISS_MODAL_BUTTON).tap();
20
+    await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
20
   });
21
   });
21
 
22
 
22
   it('show multiple modals', async () => {
23
   it('show multiple modals', async () => {
23
-    await elementByLabel('Show Modal').tap();
24
+    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
24
     await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
25
     await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
25
-    await elementByLabel('Show Modal').tap();
26
+    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
26
     await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
27
     await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
27
-    await elementByLabel('Dismiss Modal').tap();
28
+    await elementById(testIDs.DISMISS_MODAL_BUTTON).tap();
28
     await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
29
     await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
29
-    await elementByLabel('Dismiss Modal').tap();
30
-    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
30
+    await elementById(testIDs.DISMISS_MODAL_BUTTON).tap();
31
+    await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
31
   });
32
   });
32
 
33
 
33
   it('dismiss unknown screen id', async () => {
34
   it('dismiss unknown screen id', async () => {
34
-    await elementByLabel('Show Modal').tap();
35
+    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
35
     await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
36
     await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
36
-    await elementByLabel('Dismiss Unknown Modal').tap();
37
+    await elementById(testIDs.DISMISS_UNKNOWN_MODAL_BUTTON).tap();
37
     await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
38
     await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
38
-    await elementByLabel('Dismiss Modal').tap();
39
-    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
39
+    await elementById(testIDs.DISMISS_MODAL_BUTTON).tap();
40
+    await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
40
   });
41
   });
41
 
42
 
42
   it('dismiss modal by id which is not the top most', async () => {
43
   it('dismiss modal by id which is not the top most', async () => {
43
-    await elementByLabel('Show Modal').tap();
44
+    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
44
     await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
45
     await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
45
-    await elementByLabel('Show Modal').tap();
46
+    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
46
     await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
47
     await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
47
-    await elementByLabel('Dismiss Previous Modal').tap();
48
+    await elementById(testIDs.DISMISS_PREVIOUS_MODAL_BUTTON).tap();
48
     await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
49
     await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
49
-    await elementByLabel('Dismiss Modal').tap();
50
-    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
50
+    await elementById(testIDs.DISMISS_MODAL_BUTTON).tap();
51
+    await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
51
   });
52
   });
52
 
53
 
53
   it('dismiss all previous modals by id when they are below top presented modal', async () => {
54
   it('dismiss all previous modals by id when they are below top presented modal', async () => {
54
-    await elementByLabel('Show Modal').tap();
55
+    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
55
     await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
56
     await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
56
-    await elementByLabel('Show Modal').tap();
57
+    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
57
     await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
58
     await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
58
-    await elementByLabel('Show Modal').tap();
59
+    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
59
     await expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
60
     await expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
60
 
61
 
61
-    await elementByLabel('Dismiss ALL Previous Modals').tap();
62
+    await elementById(testIDs.DISMISS_ALL_PREVIOUS_MODAL_BUTTON).tap();
62
     await expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
63
     await expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
63
 
64
 
64
-    await elementByLabel('Dismiss Modal').tap();
65
-    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
65
+    await elementById(testIDs.DISMISS_MODAL_BUTTON).tap();
66
+    await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
66
   });
67
   });
67
 
68
 
68
   it('dismiss some modal by id deep in the stack', async () => {
69
   it('dismiss some modal by id deep in the stack', async () => {
69
-    await elementByLabel('Show Modal').tap();
70
+    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
70
     await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
71
     await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
71
-    await elementByLabel('Show Modal').tap();
72
+    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
72
     await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
73
     await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
73
-    await elementByLabel('Show Modal').tap();
74
+    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
74
     await expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
75
     await expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
75
 
76
 
76
-    await elementByLabel('Dismiss First In Stack').tap();
77
+    await elementById(testIDs.DISMISS_FIRST_MODAL_BUTTON).tap();
77
     await expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
78
     await expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
78
 
79
 
79
-    await elementByLabel('Dismiss Modal').tap();
80
+    await elementById(testIDs.DISMISS_MODAL_BUTTON).tap();
80
     await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
81
     await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
81
 
82
 
82
-    await elementByLabel('Dismiss Modal').tap();
83
-    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
83
+    await elementById(testIDs.DISMISS_MODAL_BUTTON).tap();
84
+    await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
84
   });
85
   });
85
 
86
 
86
   it('dismissAllModals', async () => {
87
   it('dismissAllModals', async () => {
87
-    await elementByLabel('Show Modal').tap();
88
+    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
88
     await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
89
     await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
89
-    await elementByLabel('Show Modal').tap();
90
+    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
90
     await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
91
     await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
91
-    await elementByLabel('Dismiss All Modals').tap();
92
-    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
92
+    await elementById(testIDs.DISMISS_ALL_MODALS_BUTTON).tap();
93
+    await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
93
   });
94
   });
94
 });
95
 });

+ 14
- 13
e2e/Orientations.test.js View File

1
 
1
 
2
 const Utils = require('./Utils');
2
 const Utils = require('./Utils');
3
+const testIDs = require('../playground/src/testIDs');
3
 
4
 
4
-const elementByLabel = Utils.elementByLabel;
5
+const { elementById } = Utils;
5
 
6
 
6
 describe('orientation', () => {
7
 describe('orientation', () => {
7
   beforeEach(async () => {
8
   beforeEach(async () => {
14
   });
15
   });
15
 
16
 
16
   it('default allows all', async () => {
17
   it('default allows all', async () => {
17
-    await elementByLabel('Orientation').tap();
18
-    await elementByLabel('default').tap();
18
+    await elementById(testIDs.ORIENTATION_BUTTON).tap();
19
+    await elementById(testIDs.DEFAULT_ORIENTATION_BUTTON).tap();
19
     await expect(element(by.id('currentOrientation'))).toHaveText('Portrait');
20
     await expect(element(by.id('currentOrientation'))).toHaveText('Portrait');
20
     await device.setOrientation('landscape');
21
     await device.setOrientation('landscape');
21
     await expect(element(by.id('currentOrientation'))).toHaveText('Landscape');
22
     await expect(element(by.id('currentOrientation'))).toHaveText('Landscape');
22
     await device.setOrientation('portrait');
23
     await device.setOrientation('portrait');
23
     await expect(element(by.id('currentOrientation'))).toHaveText('Portrait');
24
     await expect(element(by.id('currentOrientation'))).toHaveText('Portrait');
24
-    await elementByLabel('Dismiss').tap();
25
+    await elementById(testIDs.DISMISS_BUTTON).tap();
25
   });
26
   });
26
 
27
 
27
   it('landscape and portrait array', async () => {
28
   it('landscape and portrait array', async () => {
28
-    await elementByLabel('Orientation').tap();
29
-    await elementByLabel('landscape and portrait').tap();
29
+    await elementById(testIDs.ORIENTATION_BUTTON).tap();
30
+    await elementById(testIDs.LANDSCAPE_PORTRAIT_ORIENTATION_BUTTON).tap();
30
     await expect(element(by.id('currentOrientation'))).toHaveText('Portrait');
31
     await expect(element(by.id('currentOrientation'))).toHaveText('Portrait');
31
     await device.setOrientation('landscape');
32
     await device.setOrientation('landscape');
32
     await expect(element(by.id('currentOrientation'))).toHaveText('Landscape');
33
     await expect(element(by.id('currentOrientation'))).toHaveText('Landscape');
33
     await device.setOrientation('portrait');
34
     await device.setOrientation('portrait');
34
     await expect(element(by.id('currentOrientation'))).toHaveText('Portrait');
35
     await expect(element(by.id('currentOrientation'))).toHaveText('Portrait');
35
-    await elementByLabel('Dismiss').tap();
36
+    await elementById(testIDs.DISMISS_BUTTON).tap();
36
   });
37
   });
37
 
38
 
38
   it('portrait only', async () => {
39
   it('portrait only', async () => {
39
-    await elementByLabel('Orientation').tap();
40
-    await elementByLabel('portrait only').tap();
40
+    await elementById(testIDs.ORIENTATION_BUTTON).tap();
41
+    await elementById(testIDs.PORTRAIT_ORIENTATION_BUTTON).tap();
41
     await expect(element(by.id('currentOrientation'))).toHaveText('Portrait');
42
     await expect(element(by.id('currentOrientation'))).toHaveText('Portrait');
42
     await device.setOrientation('landscape');
43
     await device.setOrientation('landscape');
43
     await expect(element(by.id('currentOrientation'))).toHaveText('Portrait');
44
     await expect(element(by.id('currentOrientation'))).toHaveText('Portrait');
44
     await device.setOrientation('portrait');
45
     await device.setOrientation('portrait');
45
     await expect(element(by.id('currentOrientation'))).toHaveText('Portrait');
46
     await expect(element(by.id('currentOrientation'))).toHaveText('Portrait');
46
-    await elementByLabel('Dismiss').tap();
47
+    await elementById(testIDs.DISMISS_BUTTON).tap();
47
   });
48
   });
48
 
49
 
49
   it('landscape only', async () => {
50
   it('landscape only', async () => {
50
-    await elementByLabel('Orientation').tap();
51
-    await elementByLabel('landscape only').tap();
51
+    await elementById(testIDs.ORIENTATION_BUTTON).tap();
52
+    await elementById(testIDs.LANDSCAPE_ORIENTATION_BUTTON).tap();
52
     await device.setOrientation('landscape');
53
     await device.setOrientation('landscape');
53
     await expect(element(by.id('currentOrientation'))).toHaveText('Landscape');
54
     await expect(element(by.id('currentOrientation'))).toHaveText('Landscape');
54
     await device.setOrientation('portrait');
55
     await device.setOrientation('portrait');
55
     await expect(element(by.id('currentOrientation'))).toHaveText('Landscape');
56
     await expect(element(by.id('currentOrientation'))).toHaveText('Landscape');
56
-    await elementByLabel('Dismiss').tap();
57
+    await elementById(testIDs.DISMISS_BUTTON).tap();
57
   });
58
   });
58
 });
59
 });

+ 22
- 21
e2e/ScreenStack.test.js View File

1
 const Utils = require('./Utils');
1
 const Utils = require('./Utils');
2
+const testIDs = require('../playground/src/testIDs');
2
 
3
 
3
-const elementByLabel = Utils.elementByLabel;
4
+const { elementByLabel, elementById } = Utils;
4
 
5
 
5
 describe('screen stack', () => {
6
 describe('screen stack', () => {
6
   beforeEach(async () => {
7
   beforeEach(async () => {
8
   });
9
   });
9
 
10
 
10
   it('push and pop screen', async () => {
11
   it('push and pop screen', async () => {
11
-    await elementByLabel('Push').tap();
12
-    await expect(elementByLabel('Pushed Screen')).toBeVisible();
13
-    await elementByLabel('Pop').tap();
14
-    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
12
+    await elementById(testIDs.PUSH_BUTTON).tap();
13
+    await expect(elementById(testIDs.PUSHED_SCREEN_HEADER)).toBeVisible();
14
+    await elementById(testIDs.POP_BUTTON).tap();
15
+    await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
15
   });
16
   });
16
 
17
 
17
   it('pop screen deep in the stack', async () => {
18
   it('pop screen deep in the stack', async () => {
18
-    await elementByLabel('Push').tap();
19
+    await elementById(testIDs.PUSH_BUTTON).tap();
19
     await expect(elementByLabel('Stack Position: 1')).toBeVisible();
20
     await expect(elementByLabel('Stack Position: 1')).toBeVisible();
20
-    await elementByLabel('Push').tap();
21
+    await elementById(testIDs.PUSH_BUTTON).tap();
21
     await expect(elementByLabel('Stack Position: 2')).toBeVisible();
22
     await expect(elementByLabel('Stack Position: 2')).toBeVisible();
22
-    await elementByLabel('Pop Previous').tap();
23
+    await elementById(testIDs.POP_PREVIOUS_BUTTON).tap();
23
     await expect(elementByLabel('Stack Position: 2')).toBeVisible();
24
     await expect(elementByLabel('Stack Position: 2')).toBeVisible();
24
-    await elementByLabel('Pop').tap();
25
-    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
25
+    await elementById(testIDs.POP_BUTTON).tap();
26
+    await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
26
   });
27
   });
27
 
28
 
28
   it('pop to specific id', async () => {
29
   it('pop to specific id', async () => {
29
-    await elementByLabel('Push').tap();
30
-    await elementByLabel('Push').tap();
31
-    await elementByLabel('Push').tap();
30
+    await elementById(testIDs.PUSH_BUTTON).tap();
31
+    await elementById(testIDs.PUSH_BUTTON).tap();
32
+    await elementById(testIDs.PUSH_BUTTON).tap();
32
     await expect(elementByLabel('Stack Position: 3')).toBeVisible();
33
     await expect(elementByLabel('Stack Position: 3')).toBeVisible();
33
-    await elementByLabel('Pop To Stack Position 1').tap();
34
+    await elementById(testIDs.POP_STACK_POSITION_ONE_BUTTON).tap();
34
     await expect(elementByLabel('Stack Position: 1')).toBeVisible();
35
     await expect(elementByLabel('Stack Position: 1')).toBeVisible();
35
   });
36
   });
36
 
37
 
37
   it('pop to root', async () => {
38
   it('pop to root', async () => {
38
-    await elementByLabel('Push').tap();
39
-    await elementByLabel('Push').tap();
40
-    await elementByLabel('Push').tap();
41
-    await elementByLabel('Pop To Root').tap();
42
-    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
39
+    await elementById(testIDs.PUSH_BUTTON).tap();
40
+    await elementById(testIDs.PUSH_BUTTON).tap();
41
+    await elementById(testIDs.PUSH_BUTTON).tap();
42
+    await elementById(testIDs.POP_TO_ROOT).tap();
43
+    await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
43
   });
44
   });
44
 
45
 
45
   it('switch to tab', async () => {
46
   it('switch to tab', async () => {
46
-    await elementByLabel('Switch to tab based app').tap();
47
+    await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
47
     await expect(elementByLabel('This is tab 1')).toBeVisible();
48
     await expect(elementByLabel('This is tab 1')).toBeVisible();
48
-    await elementByLabel('Switch To Tab 2').tap();
49
+    await elementById(testIDs.SWITCH_SECOND_TAB_BUTTON).tap();
49
     await expect(elementByLabel('This is tab 1')).toBeNotVisible();
50
     await expect(elementByLabel('This is tab 1')).toBeNotVisible();
50
     await expect(elementByLabel('This is tab 2')).toBeVisible();
51
     await expect(elementByLabel('This is tab 2')).toBeVisible();
51
   });
52
   });

+ 20
- 19
e2e/ScreenStyle.test.js View File

1
 const Utils = require('./Utils');
1
 const Utils = require('./Utils');
2
+const testIDs = require('../playground/src/testIDs');
2
 
3
 
3
-const { elementByLabel, elementById } = Utils;
4
+const { elementById, elementByLabel } = Utils;
4
 
5
 
5
 describe('screen style', () => {
6
 describe('screen style', () => {
6
   beforeEach(async () => {
7
   beforeEach(async () => {
8
   });
9
   });
9
 
10
 
10
   it('declare a navigationOptions on container component', async () => {
11
   it('declare a navigationOptions on container component', async () => {
11
-    await elementByLabel('Push Options Screen').tap();
12
+    await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
12
     await expect(element(by.label('Static Title').and(by.type('UILabel')))).toBeVisible();
13
     await expect(element(by.label('Static Title').and(by.type('UILabel')))).toBeVisible();
13
   });
14
   });
14
 
15
 
15
   it('change title on container component', async () => {
16
   it('change title on container component', async () => {
16
-    await elementByLabel('Push Options Screen').tap();
17
+    await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
17
     await expect(element(by.label('Static Title').and(by.type('UILabel')))).toBeVisible();
18
     await expect(element(by.label('Static Title').and(by.type('UILabel')))).toBeVisible();
18
-    await elementByLabel('Dynamic Options').tap();
19
+    await elementById(testIDs.DYNAMIC_OPTIONS_BUTTON).tap();
19
     await expect(element(by.label('Dynamic Title').and(by.type('UILabel')))).toBeVisible();
20
     await expect(element(by.label('Dynamic Title').and(by.type('UILabel')))).toBeVisible();
20
   });
21
   });
21
 
22
 
22
   it('set dynamic options with valid options will do something and not crash', async () => {
23
   it('set dynamic options with valid options will do something and not crash', async () => {
23
     // we have no way of testing individual styles for the screen
24
     // we have no way of testing individual styles for the screen
24
-    await elementByLabel('Push Options Screen').tap();
25
-    await elementByLabel('Dynamic Options').tap();
26
-    await expect(element(by.label('Options Screen'))).toBeVisible();
25
+    await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
26
+    await elementById(testIDs.DYNAMIC_OPTIONS_BUTTON).tap();
27
+    await expect(elementById(testIDs.OPTIONS_SCREEN_HEADER)).toBeVisible();
27
   });
28
   });
28
 
29
 
29
   it('hides Tab Bar when pressing on Hide Top Bar and shows it when pressing on Show Top Bar', async () => {
30
   it('hides Tab Bar when pressing on Hide Top Bar and shows it when pressing on Show Top Bar', async () => {
30
-    await elementByLabel('Push Options Screen').tap();
31
-    await elementByLabel('Hide Top Bar').tap();
31
+    await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
32
+    await elementById(testIDs.HIDE_TOP_BAR_BUTTON).tap();
32
     await expect(element(by.type('UINavigationBar'))).toBeNotVisible();
33
     await expect(element(by.type('UINavigationBar'))).toBeNotVisible();
33
-    await elementByLabel('Show Top Bar').tap();
34
+    await elementById(testIDs.SHOW_TOP_BAR_BUTTON).tap();
34
     await expect(element(by.type('UINavigationBar'))).toBeVisible();
35
     await expect(element(by.type('UINavigationBar'))).toBeVisible();
35
   });
36
   });
36
 
37
 
37
   it('hides topBar onScroll down and shows it on scroll up', async () => {
38
   it('hides topBar onScroll down and shows it on scroll up', async () => {
38
-    await elementByLabel('Push Options Screen').tap();
39
-    await elementByLabel('scrollView Screen').tap();
40
-    await elementByLabel('Toggle Top Bar Hide On Scroll').tap();
39
+    await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
40
+    await elementById(testIDs.SCROLLVIEW_SCREEN_BUTTON).tap();
41
+    await elementById(testIDs.TOGGLE_TOP_BAR_HIDE_ON_SCROLL).tap();
41
     await expect(element(by.type('UINavigationBar'))).toBeVisible();
42
     await expect(element(by.type('UINavigationBar'))).toBeVisible();
42
-    await element(by.id('scrollView')).swipe('up', 'fast');
43
+    await element(by.id(testIDs.SCROLLVIEW_ELEMENT)).swipe('up', 'fast');
43
     await expect(element(by.type('UINavigationBar'))).toBeNotVisible();
44
     await expect(element(by.type('UINavigationBar'))).toBeNotVisible();
44
-    await element(by.id('scrollView')).swipe('down', 'fast');
45
+    await element(by.id(testIDs.SCROLLVIEW_ELEMENT)).swipe('down', 'fast');
45
     await expect(element(by.type('UINavigationBar'))).toBeVisible();
46
     await expect(element(by.type('UINavigationBar'))).toBeVisible();
46
   });
47
   });
47
 
48
 
54
   });
55
   });
55
 
56
 
56
   it('set Tab Bar badge on a current Tab', async () => {
57
   it('set Tab Bar badge on a current Tab', async () => {
57
-    await elementByLabel('Switch to tab based app').tap();
58
-    await elementByLabel('Set Tab Badge').tap();
58
+    await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
59
+    await elementById(testIDs.SET_TAB_BADGE_BUTTON).tap();
59
     await expect(element(by.text('TeSt'))).toBeVisible();
60
     await expect(element(by.text('TeSt'))).toBeVisible();
60
   });
61
   });
61
 
62
 
75
   });
76
   });
76
 
77
 
77
   it('set right buttons', async () => {
78
   it('set right buttons', async () => {
78
-    await elementByLabel('Push Options Screen').tap();
79
+    await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
79
     await expect(elementById('buttonOne')).toBeVisible();
80
     await expect(elementById('buttonOne')).toBeVisible();
80
     await elementById('buttonOne').tap();
81
     await elementById('buttonOne').tap();
81
     await expect(elementById('buttonTwo')).toBeVisible();
82
     await expect(elementById('buttonTwo')).toBeVisible();
84
   });
85
   });
85
 
86
 
86
   it('set left buttons', async () => {
87
   it('set left buttons', async () => {
87
-    await elementByLabel('Push Options Screen').tap();
88
+    await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
88
     await expect(elementById('buttonLeft')).toBeVisible();
89
     await expect(elementById('buttonLeft')).toBeVisible();
89
   });
90
   });
90
 });
91
 });

+ 10
- 9
e2e/TopLevelApi.test.js View File

1
 const Utils = require('./Utils');
1
 const Utils = require('./Utils');
2
+const testIDs = require('../playground/src/testIDs');
2
 
3
 
3
-const elementByLabel = Utils.elementByLabel;
4
+const { elementByLabel, elementById } = Utils;
4
 
5
 
5
 describe('top level api', () => {
6
 describe('top level api', () => {
6
   beforeEach(async () => {
7
   beforeEach(async () => {
8
   });
9
   });
9
 
10
 
10
   it('shows welcome screen', async () => {
11
   it('shows welcome screen', async () => {
11
-    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
12
+    await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
12
   });
13
   });
13
 
14
 
14
   it('switch to tab based app, passProps and functions', async () => {
15
   it('switch to tab based app, passProps and functions', async () => {
15
-    await elementByLabel('Switch to tab based app').tap();
16
+    await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
16
     await expect(elementByLabel('This is tab 1')).toBeVisible();
17
     await expect(elementByLabel('This is tab 1')).toBeVisible();
17
     await expect(elementByLabel('Hello from a function!')).toBeVisible();
18
     await expect(elementByLabel('Hello from a function!')).toBeVisible();
18
   });
19
   });
19
 
20
 
20
   it('switch to tabs with side menus', async () => {
21
   it('switch to tabs with side menus', async () => {
21
-    await elementByLabel('Switch to app with side menus').tap();
22
+    await elementById(testIDs.TAB_BASED_APP_SIDE_BUTTON).tap();
22
     await elementByLabel('This is a side menu center screen tab 1').swipe('right');
23
     await elementByLabel('This is a side menu center screen tab 1').swipe('right');
23
     await expect(elementByLabel('This is a left side menu screen')).toBeVisible();
24
     await expect(elementByLabel('This is a left side menu screen')).toBeVisible();
24
   });
25
   });
25
 
26
 
26
   it('screen lifecycle', async () => {
27
   it('screen lifecycle', async () => {
27
-    await elementByLabel('Push Lifecycle Screen').tap();
28
+    await elementById(testIDs.PUSH_LIFECYCLE_BUTTON).tap();
28
     await expect(elementByLabel('didAppear')).toBeVisible();
29
     await expect(elementByLabel('didAppear')).toBeVisible();
29
-    await elementByLabel('Push to test didDisappear').tap();
30
+    await elementById(testIDs.PUSH_TO_TEST_DID_DISAPPEAR_BUTTON).tap();
30
     await expect(elementByLabel('Alert')).toBeVisible();
31
     await expect(elementByLabel('Alert')).toBeVisible();
31
     await expect(elementByLabel('didDisappear')).toBeVisible();
32
     await expect(elementByLabel('didDisappear')).toBeVisible();
32
   });
33
   });
33
 
34
 
34
   it('unmount is called on pop', async () => {
35
   it('unmount is called on pop', async () => {
35
-    await elementByLabel('Push Lifecycle Screen').tap();
36
+    await elementById(testIDs.PUSH_LIFECYCLE_BUTTON).tap();
36
     await expect(elementByLabel('didAppear')).toBeVisible();
37
     await expect(elementByLabel('didAppear')).toBeVisible();
37
     await Utils.tapBackIos();
38
     await Utils.tapBackIos();
38
     await expect(elementByLabel('componentWillUnmount')).toBeVisible();
39
     await expect(elementByLabel('componentWillUnmount')).toBeVisible();
47
   });
48
   });
48
 
49
 
49
   it('push a screen to ensure its not there after reload', async () => {
50
   it('push a screen to ensure its not there after reload', async () => {
50
-    await elementByLabel('Push').tap();
51
+    await elementById(testIDs.PUSH_BUTTON).tap();
51
     await expect(elementByLabel('Pushed Screen')).toBeVisible();
52
     await expect(elementByLabel('Pushed Screen')).toBeVisible();
52
     await device.reloadReactNative();
53
     await device.reloadReactNative();
53
-    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
54
+    await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
54
   });
55
   });
55
 });
56
 });

+ 1
- 1
e2e/Utils.js View File

1
 module.exports = {
1
 module.exports = {
2
   elementByLabel: (label) => {
2
   elementByLabel: (label) => {
3
-    return element(by.label(label));
3
+    return element(by.text(label));
4
   },
4
   },
5
   elementById: (id) => {
5
   elementById: (id) => {
6
     return element(by.id(id));
6
     return element(by.id(id));

+ 1
- 1
lib/android/app/src/main/java/com/reactnativenavigation/react/NavigationModule.java View File

81
 	}
81
 	}
82
 
82
 
83
 	@ReactMethod
83
 	@ReactMethod
84
-	public void pop(final String onContainerId, final Promise promise) {
84
+	public void pop(final String onContainerId, final ReadableMap options, final Promise promise) {
85
 		handle(new Runnable() {
85
 		handle(new Runnable() {
86
 			@Override
86
 			@Override
87
 			public void run() {
87
 			public void run() {

+ 2
- 1
playground/src/containers/LifecycleScreen.js View File

4
 const { View, Text, Button, Platform } = require('react-native');
4
 const { View, Text, Button, Platform } = require('react-native');
5
 
5
 
6
 const Navigation = require('react-native-navigation');
6
 const Navigation = require('react-native-navigation');
7
+const testIDs = require('../testIDs');
7
 
8
 
8
 class LifecycleScreen extends Component {
9
 class LifecycleScreen extends Component {
9
   constructor(props) {
10
   constructor(props) {
53
       <View style={styles.root}>
54
       <View style={styles.root}>
54
         <Text style={styles.h1}>{`Lifecycle Screen`}</Text>
55
         <Text style={styles.h1}>{`Lifecycle Screen`}</Text>
55
         <Text style={styles.h1}>{this.state.text}</Text>
56
         <Text style={styles.h1}>{this.state.text}</Text>
56
-        <Button title="Push to test didDisappear" onPress={this.onClickPush} />
57
+        <Button title="Push to test didDisappear" testID={testIDs.PUSH_TO_TEST_DID_DISAPPEAR_BUTTON} onPress={this.onClickPush} />
57
         <Text style={styles.footer}>{`this.props.containerId = ${this.props.containerId}`}</Text>
58
         <Text style={styles.footer}>{`this.props.containerId = ${this.props.containerId}`}</Text>
58
       </View>
59
       </View>
59
     );
60
     );

+ 9
- 8
playground/src/containers/ModalScreen.js View File

6
 const { View, Text, Button } = require('react-native');
6
 const { View, Text, Button } = require('react-native');
7
 
7
 
8
 const Navigation = require('react-native-navigation');
8
 const Navigation = require('react-native-navigation');
9
+const testIDs = require('../testIDs');
9
 
10
 
10
 class ModalScreen extends Component {
11
 class ModalScreen extends Component {
11
   static get navigationOptions() {
12
   static get navigationOptions() {
28
   render() {
29
   render() {
29
     return (
30
     return (
30
       <View style={styles.root}>
31
       <View style={styles.root}>
31
-        <Text style={styles.h1}>{`Modal Screen`}</Text>
32
+        <Text style={styles.h1} testID={testIDs.MODAL_SCREEN}>{`Modal Screen`}</Text>
32
         <Text style={styles.footer}>{`Modal Stack Position: ${this.getModalPosition()}`}</Text>
33
         <Text style={styles.footer}>{`Modal Stack Position: ${this.getModalPosition()}`}</Text>
33
-        <Button title="Show Modal" onPress={this.onClickShowModal} />
34
-        <Button title="Dismiss Modal" onPress={this.onClickDismissModal} />
35
-        <Button title="Dismiss Unknown Modal" onPress={this.onClickDismissUnknownModal} />
36
-        <Button title="Dismiss All Modals" onPress={this.onClickDismissAllModals} />
37
-        {this.getPreviousModalId() ? (<Button title="Dismiss Previous Modal" onPress={this.onClickDismissPreviousModal} />) : undefined}
38
-        {this.props.previousModalIds ? (<Button title="Dismiss ALL Previous Modals" onPress={this.onClickDismissAllPreviousModals} />) : undefined}
39
-        {this.props.previousModalIds ? (<Button title="Dismiss First In Stack" onPress={this.onClickDismissFirstInStack} />) : undefined}
34
+        <Button title="Show Modal" testID={testIDs.SHOW_MODAL_BUTTON} onPress={this.onClickShowModal} />
35
+        <Button title="Dismiss Modal" testID={testIDs.DISMISS_MODAL_BUTTON} onPress={this.onClickDismissModal} />
36
+        <Button title="Dismiss Unknown Modal" testID={testIDs.DISMISS_UNKNOWN_MODAL_BUTTON} onPress={this.onClickDismissUnknownModal} />
37
+        <Button title="Dismiss All Modals" testID={testIDs.DISMISS_ALL_MODALS_BUTTON} onPress={this.onClickDismissAllModals} />
38
+        {this.getPreviousModalId() ? (<Button title="Dismiss Previous Modal" testID={testIDs.DISMISS_PREVIOUS_MODAL_BUTTON} onPress={this.onClickDismissPreviousModal} />) : undefined}
39
+        {this.props.previousModalIds ? (<Button title="Dismiss ALL Previous Modals" testID={testIDs.DISMISS_ALL_PREVIOUS_MODAL_BUTTON} onPress={this.onClickDismissAllPreviousModals} />) : undefined}
40
+        {this.props.previousModalIds ? (<Button title="Dismiss First In Stack" testID={testIDs.DISMISS_FIRST_MODAL_BUTTON} onPress={this.onClickDismissFirstInStack} />) : undefined}
40
         <Text style={styles.footer}>{`this.props.containerId = ${this.props.containerId}`}</Text>
41
         <Text style={styles.footer}>{`this.props.containerId = ${this.props.containerId}`}</Text>
41
       </View>
42
       </View>
42
     );
43
     );

+ 8
- 7
playground/src/containers/OptionsScreen.js View File

4
 const { View, Text, Button } = require('react-native');
4
 const { View, Text, Button } = require('react-native');
5
 
5
 
6
 const Navigation = require('react-native-navigation');
6
 const Navigation = require('react-native-navigation');
7
+const testIDs = require('../testIDs');
7
 
8
 
8
 const BUTTON_ONE = 'buttonOne';
9
 const BUTTON_ONE = 'buttonOne';
9
 const BUTTON_TWO = 'buttonTwo';
10
 const BUTTON_TWO = 'buttonTwo';
49
   render() {
50
   render() {
50
     return (
51
     return (
51
       <View style={styles.root}>
52
       <View style={styles.root}>
52
-        <Text style={styles.h1}>{`Options Screen`}</Text>
53
-        <Button title="Dynamic Options" onPress={this.onClickDynamicOptions} />
54
-        <Button title="Show Top Bar" onPress={this.onClickShowTopBar} />
55
-        <Button title="Hide Top Bar" onPress={this.onClickHideTopBar} />
53
+        <Text style={styles.h1} testID={testIDs.OPTIONS_SCREEN_HEADER}>{`Options Screen`}</Text>
54
+        <Button title="Dynamic Options" testID={testIDs.DYNAMIC_OPTIONS_BUTTON} onPress={this.onClickDynamicOptions} />
55
+        <Button title="Show Top Bar" testID={testIDs.SHOW_TOP_BAR_BUTTON} onPress={this.onClickShowTopBar} />
56
+        <Button title="Hide Top Bar" testID={testIDs.HIDE_TOP_BAR_BUTTON} onPress={this.onClickHideTopBar} />
56
         <Button title="Top Bar Transparent" onPress={this.onClickTopBarTransparent} />
57
         <Button title="Top Bar Transparent" onPress={this.onClickTopBarTransparent} />
57
         <Button title="Top Bar Opaque" onPress={this.onClickTopBarOpaque} />
58
         <Button title="Top Bar Opaque" onPress={this.onClickTopBarOpaque} />
58
-        <Button title="scrollView Screen" onPress={this.onClickScrollViewScreen} />
59
+        <Button title="scrollView Screen" testID={testIDs.SCROLLVIEW_SCREEN_BUTTON} onPress={this.onClickScrollViewScreen} />
59
         <Button title="Custom Transition" onPress={this.onClickCustomTranstition} />
60
         <Button title="Custom Transition" onPress={this.onClickCustomTranstition} />
60
-        <Button title="Show custom alert" onPress={this.onClickAlert} />
61
-        <Button title="Show snackbar" onPress={this.onClickSnackbar} />
61
+        <Button title="Show custom alert" testID={testIDs.SHOW_CUSTOM_ALERT_BUTTON} onPress={this.onClickAlert} />
62
+        <Button title="Show snackbar" testID={testIDs.SHOW_SNACKBAR_BUTTON} onPress={this.onClickSnackbar} />
62
         <Text style={styles.footer}>{`this.props.containerId = ${this.props.containerId}`}</Text>
63
         <Text style={styles.footer}>{`this.props.containerId = ${this.props.containerId}`}</Text>
63
       </View>
64
       </View>
64
     );
65
     );

+ 2
- 1
playground/src/containers/OrientationDetectScreen.js View File

4
 const { View, Text, Button } = require('react-native');
4
 const { View, Text, Button } = require('react-native');
5
 
5
 
6
 const Navigation = require('react-native-navigation');
6
 const Navigation = require('react-native-navigation');
7
+const testIDs = require('../testIDs');
7
 
8
 
8
 class OrientationDetectScreen extends Component {
9
 class OrientationDetectScreen extends Component {
9
   constructor(props) {
10
   constructor(props) {
20
     return (
21
     return (
21
       <View style={styles.root} onLayout={this.detectHorizontal}>
22
       <View style={styles.root} onLayout={this.detectHorizontal}>
22
         <Text style={styles.h1}>{`Orientation Screen`}</Text>
23
         <Text style={styles.h1}>{`Orientation Screen`}</Text>
23
-        <Button title="Dismiss" onPress={() => Navigation.dismissModal(this.props.containerId)} />
24
+        <Button title="Dismiss" testID={testIDs.DISMISS_BUTTON} onPress={() => Navigation.dismissModal(this.props.containerId)} />
24
         <Text style={styles.footer}>{`this.props.containerId = ${this.props.containerId}`}</Text>
25
         <Text style={styles.footer}>{`this.props.containerId = ${this.props.containerId}`}</Text>
25
         <Text style={styles.footer} testID="currentOrientation">{this.state.horizontal ? 'Landscape' : 'Portrait'}</Text>
26
         <Text style={styles.footer} testID="currentOrientation">{this.state.horizontal ? 'Landscape' : 'Portrait'}</Text>
26
       </View>
27
       </View>

+ 5
- 4
playground/src/containers/OrientationSelectScreen.js View File

3
 const { View, Text, Button } = require('react-native');
3
 const { View, Text, Button } = require('react-native');
4
 
4
 
5
 const Navigation = require('react-native-navigation');
5
 const Navigation = require('react-native-navigation');
6
+const testIDs = require('../testIDs');
6
 
7
 
7
 class OrientationSelectScreen extends Component {
8
 class OrientationSelectScreen extends Component {
8
 
9
 
10
     return (
11
     return (
11
       <View style={styles.root}>
12
       <View style={styles.root}>
12
         <Text style={styles.h1}>{`Orientation Menu`}</Text>
13
         <Text style={styles.h1}>{`Orientation Menu`}</Text>
13
-        <Button title="default" onPress={() => this.onClickOrientationScreen('default')} />
14
-        <Button title="landscape and portrait" onPress={() => this.onClickOrientationScreen(['landscape', 'portrait'])} />
15
-        <Button title="portrait only" onPress={() => this.onClickOrientationScreen('portrait')} />
16
-        <Button title="landscape only" onPress={() => this.onClickOrientationScreen(['landscape'])} />
14
+        <Button title="default" testID={testIDs.DEFAULT_ORIENTATION_BUTTON} onPress={() => this.onClickOrientationScreen('default')} />
15
+        <Button title="landscape and portrait" testID={testIDs.LANDSCAPE_PORTRAIT_ORIENTATION_BUTTON} onPress={() => this.onClickOrientationScreen(['landscape', 'portrait'])} />
16
+        <Button title="portrait only" testID={testIDs.PORTRAIT_ORIENTATION_BUTTON} onPress={() => this.onClickOrientationScreen('portrait')} />
17
+        <Button title="landscape only" testID={testIDs.LANDSCAPE_ORIENTATION_BUTTON} onPress={() => this.onClickOrientationScreen(['landscape'])} />
17
       </View>
18
       </View>
18
     );
19
     );
19
   }
20
   }

+ 7
- 6
playground/src/containers/PushedScreen.js View File

6
 const { View, Text, Button } = require('react-native');
6
 const { View, Text, Button } = require('react-native');
7
 
7
 
8
 const Navigation = require('react-native-navigation');
8
 const Navigation = require('react-native-navigation');
9
+const testIDs = require('../testIDs');
9
 
10
 
10
 class PushedScreen extends Component {
11
 class PushedScreen extends Component {
11
   constructor(props) {
12
   constructor(props) {
21
     const stackPosition = this.getStackPosition();
22
     const stackPosition = this.getStackPosition();
22
     return (
23
     return (
23
       <View style={styles.root}>
24
       <View style={styles.root}>
24
-        <Text style={styles.h1}>{`Pushed Screen`}</Text>
25
+        <Text testID={testIDs.PUSHED_SCREEN_HEADER} style={styles.h1}>{`Pushed Screen`}</Text>
25
         <Text style={styles.h2}>{`Stack Position: ${stackPosition}`}</Text>
26
         <Text style={styles.h2}>{`Stack Position: ${stackPosition}`}</Text>
26
-        <Button title="Push" onPress={this.onClickPush} />
27
-        <Button title="Pop" onPress={this.onClickPop} />
28
-        <Button title="Pop Previous" onPress={this.onClickPopPrevious} />
29
-        <Button title="Pop To Root" onPress={this.onClickPopToRoot} />
30
-        {stackPosition > 2 && <Button title="Pop To Stack Position 1" onPress={this.onClickPopToFirstPosition} />}
27
+        <Button title="Push" testID={testIDs.PUSH_BUTTON} onPress={this.onClickPush} />
28
+        <Button title="Pop" testID={testIDs.POP_BUTTON} onPress={this.onClickPop} />
29
+        <Button title="Pop Previous" testID={testIDs.POP_PREVIOUS_BUTTON} onPress={this.onClickPopPrevious} />
30
+        <Button title="Pop To Root" testID={testIDs.POP_TO_ROOT} onPress={this.onClickPopToRoot} />
31
+        {stackPosition > 2 && <Button title="Pop To Stack Position 1" testID={testIDs.POP_STACK_POSITION_ONE_BUTTON} onPress={this.onClickPopToFirstPosition} />}
31
         <Text style={styles.footer}>{`this.props.containerId = ${this.props.containerId}`}</Text>
32
         <Text style={styles.footer}>{`this.props.containerId = ${this.props.containerId}`}</Text>
32
       </View>
33
       </View>
33
     );
34
     );

+ 3
- 2
playground/src/containers/ScrollViewScreen.js View File

4
 const { StyleSheet, ScrollView, View, Button } = require('react-native');
4
 const { StyleSheet, ScrollView, View, Button } = require('react-native');
5
 
5
 
6
 const Navigation = require('react-native-navigation');
6
 const Navigation = require('react-native-navigation');
7
+const testIDs = require('../testIDs');
7
 
8
 
8
 class ScrollViewScreen extends Component {
9
 class ScrollViewScreen extends Component {
9
   static get navigationOptions() {
10
   static get navigationOptions() {
25
   render() {
26
   render() {
26
     return (
27
     return (
27
       <View>
28
       <View>
28
-        <ScrollView testID="scrollView" contentContainerStyle={styles.contentContainer}>
29
+        <ScrollView testID={testIDs.SCROLLVIEW_ELEMENT} contentContainerStyle={styles.contentContainer}>
29
           <View>
30
           <View>
30
-            <Button title="Toggle Top Bar Hide On Scroll" onPress={this.onClickToggleTopBarHideOnScroll} />
31
+            <Button title="Toggle Top Bar Hide On Scroll" testID={testIDs.TOGGLE_TOP_BAR_HIDE_ON_SCROLL} onPress={this.onClickToggleTopBarHideOnScroll} />
31
           </View>
32
           </View>
32
         </ScrollView>
33
         </ScrollView>
33
       </View>
34
       </View>

+ 3
- 2
playground/src/containers/TextScreen.js View File

4
 const { View, Text, Button } = require('react-native');
4
 const { View, Text, Button } = require('react-native');
5
 
5
 
6
 const Navigation = require('react-native-navigation');
6
 const Navigation = require('react-native-navigation');
7
+const testIDs = require('../testIDs');
7
 
8
 
8
 class TextScreen extends Component {
9
 class TextScreen extends Component {
9
 
10
 
13
         <Text style={styles.h1}>{this.props.text || 'Text Screen'}</Text>
14
         <Text style={styles.h1}>{this.props.text || 'Text Screen'}</Text>
14
         {this.renderTextFromFunctionInProps()}
15
         {this.renderTextFromFunctionInProps()}
15
         <Text style={styles.footer}>{`this.props.containerId = ${this.props.containerId}`}</Text>
16
         <Text style={styles.footer}>{`this.props.containerId = ${this.props.containerId}`}</Text>
16
-        <Button title={'Set Tab Badge'} onPress={() => this.onButtonPress()} />
17
-        <Button title="Switch To Tab 2" onPress={() => this.onClickSwitchToTab()} />
17
+        <Button title={'Set Tab Badge'} testID={testIDs.SET_TAB_BADGE_BUTTON} onPress={() => this.onButtonPress()} />
18
+        <Button title={'Switch To Tab 2'} testID={testIDs.SWITCH_SECOND_TAB_BUTTON} onPress={() => this.onClickSwitchToTab()} />
18
         <Button title="Hide Tab Bar" onPress={() => this.hideTabBar(true)} />
19
         <Button title="Hide Tab Bar" onPress={() => this.hideTabBar(true)} />
19
         <Button title="Show Tab Bar" onPress={() => this.hideTabBar(false)} />
20
         <Button title="Show Tab Bar" onPress={() => this.hideTabBar(false)} />
20
       </View>
21
       </View>

+ 13
- 10
playground/src/containers/WelcomeScreen.js View File

1
 const React = require('react');
1
 const React = require('react');
2
 const { Component } = require('react');
2
 const { Component } = require('react');
3
 const { View, Text, Button } = require('react-native');
3
 const { View, Text, Button } = require('react-native');
4
+
5
+const testIDs = require('../testIDs');
6
+
4
 const Navigation = require('react-native-navigation');
7
 const Navigation = require('react-native-navigation');
5
 
8
 
6
 class WelcomeScreen extends Component {
9
 class WelcomeScreen extends Component {
24
   render() {
27
   render() {
25
     return (
28
     return (
26
       <View style={styles.root}>
29
       <View style={styles.root}>
27
-        <Text style={styles.h1}>{`React Native Navigation!`}</Text>
28
-        <Button title="Switch to tab based app" onPress={this.onClickSwitchToTabs} />
29
-        <Button title="Switch to app with side menus" onPress={this.onClickSwitchToSideMenus} />
30
-        <Button title="Push Lifecycle Screen" onPress={this.onClickLifecycleScreen} />
31
-        <Button title="Push" onPress={this.onClickPush} />
32
-        <Button title="Push Options Screen" onPress={this.onClickPushOptionsScreen} />
33
-        <Button title="Back Handler" onPress={this.onClickBackHandler} />
34
-        <Button title="Show Modal" onPress={this.onClickShowModal} />
35
-        <Button title="Show Redbox" onPress={this.onClickShowRedbox} />
36
-        <Button title="Orientation" onPress={this.onClickPushOrientationMenuScreen} />
30
+        <Text testID={testIDs.WELCOME_SCREEN_HEADER} style={styles.h1}>{`React Native Navigation!`}</Text>
31
+        <Button title="Switch to tab based app" testID={testIDs.TAB_BASED_APP_BUTTON} onPress={this.onClickSwitchToTabs} />
32
+        <Button title="Switch to app with side menus" testID={testIDs.TAB_BASED_APP_SIDE_BUTTON} onPress={this.onClickSwitchToSideMenus} />
33
+        <Button title="Push Lifecycle Screen" testID={testIDs.PUSH_LIFECYCLE_BUTTON} onPress={this.onClickLifecycleScreen} />
34
+        <Button title="Push" testID={testIDs.PUSH_BUTTON} onPress={this.onClickPush} />
35
+        <Button title="Push Options Screen" testID={testIDs.PUSH_OPTIONS_BUTTON} onPress={this.onClickPushOptionsScreen} />
36
+        <Button title="Back Handler" testID={testIDs.BACK_HANDLER_BUTTON} onPress={this.onClickBackHandler} />
37
+        <Button title="Show Modal" testID={testIDs.SHOW_MODAL_BUTTON} onPress={this.onClickShowModal} />
38
+        <Button title="Show Redbox" testID={testIDs.SHOW_REDBOX_BUTTON} onPress={this.onClickShowRedbox} />
39
+        <Button title="Orientation" testID={testIDs.ORIENTATION_BUTTON} onPress={this.onClickPushOrientationMenuScreen} />
37
         <Text style={styles.footer}>{`this.props.containerId = ${this.props.containerId}`}</Text>
40
         <Text style={styles.footer}>{`this.props.containerId = ${this.props.containerId}`}</Text>
38
       </View>
41
       </View>
39
     );
42
     );

+ 48
- 0
playground/src/testIDs.js View File

1
+
2
+module.exports = {
3
+
4
+  // Buttons
5
+  TAB_BASED_APP_BUTTON: `TAB_BASED_APP_BUTTON`,
6
+  TAB_BASED_APP_SIDE_BUTTON: `TAB_BASED_APP_SIDE_BUTTON`,
7
+  PUSH_LIFECYCLE_BUTTON: `PUSH_LIFECYCLE_BUTTON`,
8
+  PUSH_BUTTON: `PUSH_BUTTON`,
9
+  PUSH_OPTIONS_BUTTON: `PUSH_OPTIONS_BUTTON`,
10
+  BACK_HANDLER_BUTTON: `BACK_HANDLER_BUTTON`,
11
+  SHOW_MODAL_BUTTON: `SHOW_MODAL_BUTTON`,
12
+  SHOW_REDBOX_BUTTON: `SHOW_REDBOX_BUTTON`,
13
+  ORIENTATION_BUTTON: `ORIENTATION_BUTTON`,
14
+  DISMISS_MODAL_BUTTON: `DISMISS_MODAL_BUTTON`,
15
+  DISMISS_UNKNOWN_MODAL_BUTTON: `DISMISS_UNKNOWN_MODAL_BUTTON`,
16
+  DISMISS_ALL_MODALS_BUTTON: `DISMISS_ALL_MODALS_BUTTON`,
17
+  DISMISS_PREVIOUS_MODAL_BUTTON: `DISMISS_PREVIOUS_MODAL_BUTTON`,
18
+  DISMISS_ALL_PREVIOUS_MODAL_BUTTON: `DISMISS_ALL_PREVIOUS_MODAL_BUTTON`,
19
+  DISMISS_FIRST_MODAL_BUTTON: `DISMISS_FIRST_MODAL_BUTTON`,
20
+  DEFAULT_ORIENTATION_BUTTON: `DEFAULT_ORIENTATION_BUTTON`,
21
+  LANDSCAPE_PORTRAIT_ORIENTATION_BUTTON: `LANDSCAPE_PORTRAIT_ORIENTATION_BUTTON`,
22
+  PORTRAIT_ORIENTATION_BUTTON: `PORTRAIT_ORIENTATION_BUTTON`,
23
+  LANDSCAPE_ORIENTATION_BUTTON: `LANDSCAPE_ORIENTATION_BUTTON`,
24
+  DISMISS_BUTTON: `DISMISS_BUTTON`,
25
+  POP_BUTTON: `POP_BUTTON`,
26
+  POP_PREVIOUS_BUTTON: `POP_PREVIOUS_BUTTON`,
27
+  POP_TO_ROOT: `POP_TO_ROOT`,
28
+  POP_STACK_POSITION_ONE_BUTTON: `POP_STACK_POSITION_ONE_BUTTON`,
29
+  SWITCH_SECOND_TAB_BUTTON: `SWITCH_SECOND_TAB_BUTTON`,
30
+  DYNAMIC_OPTIONS_BUTTON: `DYNAMIC_OPTIONS_BUTTON`,
31
+  SHOW_TOP_BAR_BUTTON: `SHOW_TOP_BAR_BUTTON`,
32
+  HIDE_TOP_BAR_BUTTON: `HIDE_TOP_BAR_BUTTON`,
33
+  SCROLLVIEW_SCREEN_BUTTON: `SCROLLVIEW_SCREEN_BUTTON`,
34
+  SHOW_CUSTOM_ALERT_BUTTON: `SHOW_CUSTOM_ALERT_BUTTON`,
35
+  SHOW_SNACKBAR_BUTTON: `SHOW_SNACKBAR_BUTTON`,
36
+  TOGGLE_TOP_BAR_HIDE_ON_SCROLL: `TOGGLE_TOP_BAR_HIDE_ON_SCROLL`,
37
+  SET_TAB_BADGE_BUTTON: `SET_TAB_BADGE_BUTTON`,
38
+  PUSH_TO_TEST_DID_DISAPPEAR_BUTTON: `PUSH_TO_TEST_DID_DISAPPEAR_BUTTON`,
39
+
40
+  // Elements
41
+  SCROLLVIEW_ELEMENT: `SCROLLVIEW_ELEMENT`,
42
+
43
+  // Headers
44
+  WELCOME_SCREEN_HEADER: `WELCOME_SCREEN_HEADER`,
45
+  PUSHED_SCREEN_HEADER: `PUSHED_SCREEN_HEADER`,
46
+  OPTIONS_SCREEN_HEADER: `OPTIONS_SCREEN_HEADER`,
47
+  MODAL_SCREEN: `MODAL_SCREEN`
48
+};