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,6 +1,7 @@
1 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 6
 describe('modal', () => {
6 7
   beforeEach(async () => {
@@ -8,87 +9,87 @@ describe('modal', () => {
8 9
   });
9 10
 
10 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 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 23
   it('show multiple modals', async () => {
23
-    await elementByLabel('Show Modal').tap();
24
+    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
24 25
     await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
25
-    await elementByLabel('Show Modal').tap();
26
+    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
26 27
     await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
27
-    await elementByLabel('Dismiss Modal').tap();
28
+    await elementById(testIDs.DISMISS_MODAL_BUTTON).tap();
28 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 34
   it('dismiss unknown screen id', async () => {
34
-    await elementByLabel('Show Modal').tap();
35
+    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
35 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 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 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 45
     await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
45
-    await elementByLabel('Show Modal').tap();
46
+    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
46 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 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 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 56
     await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
56
-    await elementByLabel('Show Modal').tap();
57
+    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
57 58
     await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
58
-    await elementByLabel('Show Modal').tap();
59
+    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
59 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 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 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 71
     await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
71
-    await elementByLabel('Show Modal').tap();
72
+    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
72 73
     await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
73
-    await elementByLabel('Show Modal').tap();
74
+    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
74 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 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 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 87
   it('dismissAllModals', async () => {
87
-    await elementByLabel('Show Modal').tap();
88
+    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
88 89
     await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
89
-    await elementByLabel('Show Modal').tap();
90
+    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
90 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,7 +1,8 @@
1 1
 
2 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 7
 describe('orientation', () => {
7 8
   beforeEach(async () => {
@@ -14,45 +15,45 @@ describe('orientation', () => {
14 15
   });
15 16
 
16 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 20
     await expect(element(by.id('currentOrientation'))).toHaveText('Portrait');
20 21
     await device.setOrientation('landscape');
21 22
     await expect(element(by.id('currentOrientation'))).toHaveText('Landscape');
22 23
     await device.setOrientation('portrait');
23 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 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 31
     await expect(element(by.id('currentOrientation'))).toHaveText('Portrait');
31 32
     await device.setOrientation('landscape');
32 33
     await expect(element(by.id('currentOrientation'))).toHaveText('Landscape');
33 34
     await device.setOrientation('portrait');
34 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 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 42
     await expect(element(by.id('currentOrientation'))).toHaveText('Portrait');
42 43
     await device.setOrientation('landscape');
43 44
     await expect(element(by.id('currentOrientation'))).toHaveText('Portrait');
44 45
     await device.setOrientation('portrait');
45 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 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 53
     await device.setOrientation('landscape');
53 54
     await expect(element(by.id('currentOrientation'))).toHaveText('Landscape');
54 55
     await device.setOrientation('portrait');
55 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,6 +1,7 @@
1 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 6
 describe('screen stack', () => {
6 7
   beforeEach(async () => {
@@ -8,44 +9,44 @@ describe('screen stack', () => {
8 9
   });
9 10
 
10 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 18
   it('pop screen deep in the stack', async () => {
18
-    await elementByLabel('Push').tap();
19
+    await elementById(testIDs.PUSH_BUTTON).tap();
19 20
     await expect(elementByLabel('Stack Position: 1')).toBeVisible();
20
-    await elementByLabel('Push').tap();
21
+    await elementById(testIDs.PUSH_BUTTON).tap();
21 22
     await expect(elementByLabel('Stack Position: 2')).toBeVisible();
22
-    await elementByLabel('Pop Previous').tap();
23
+    await elementById(testIDs.POP_PREVIOUS_BUTTON).tap();
23 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 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 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 35
     await expect(elementByLabel('Stack Position: 1')).toBeVisible();
35 36
   });
36 37
 
37 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 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 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 50
     await expect(elementByLabel('This is tab 1')).toBeNotVisible();
50 51
     await expect(elementByLabel('This is tab 2')).toBeVisible();
51 52
   });

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

@@ -1,6 +1,7 @@
1 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 6
 describe('screen style', () => {
6 7
   beforeEach(async () => {
@@ -8,40 +9,40 @@ describe('screen style', () => {
8 9
   });
9 10
 
10 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 13
     await expect(element(by.label('Static Title').and(by.type('UILabel')))).toBeVisible();
13 14
   });
14 15
 
15 16
   it('change title on container component', async () => {
16
-    await elementByLabel('Push Options Screen').tap();
17
+    await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
17 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 20
     await expect(element(by.label('Dynamic Title').and(by.type('UILabel')))).toBeVisible();
20 21
   });
21 22
 
22 23
   it('set dynamic options with valid options will do something and not crash', async () => {
23 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 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 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 35
     await expect(element(by.type('UINavigationBar'))).toBeVisible();
35 36
   });
36 37
 
37 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 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 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 46
     await expect(element(by.type('UINavigationBar'))).toBeVisible();
46 47
   });
47 48
 
@@ -54,8 +55,8 @@ describe('screen style', () => {
54 55
   });
55 56
 
56 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 60
     await expect(element(by.text('TeSt'))).toBeVisible();
60 61
   });
61 62
 
@@ -75,7 +76,7 @@ describe('screen style', () => {
75 76
   });
76 77
 
77 78
   it('set right buttons', async () => {
78
-    await elementByLabel('Push Options Screen').tap();
79
+    await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
79 80
     await expect(elementById('buttonOne')).toBeVisible();
80 81
     await elementById('buttonOne').tap();
81 82
     await expect(elementById('buttonTwo')).toBeVisible();
@@ -84,7 +85,7 @@ describe('screen style', () => {
84 85
   });
85 86
 
86 87
   it('set left buttons', async () => {
87
-    await elementByLabel('Push Options Screen').tap();
88
+    await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
88 89
     await expect(elementById('buttonLeft')).toBeVisible();
89 90
   });
90 91
 });

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

@@ -1,6 +1,7 @@
1 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 6
 describe('top level api', () => {
6 7
   beforeEach(async () => {
@@ -8,31 +9,31 @@ describe('top level api', () => {
8 9
   });
9 10
 
10 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 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 17
     await expect(elementByLabel('This is tab 1')).toBeVisible();
17 18
     await expect(elementByLabel('Hello from a function!')).toBeVisible();
18 19
   });
19 20
 
20 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 23
     await elementByLabel('This is a side menu center screen tab 1').swipe('right');
23 24
     await expect(elementByLabel('This is a left side menu screen')).toBeVisible();
24 25
   });
25 26
 
26 27
   it('screen lifecycle', async () => {
27
-    await elementByLabel('Push Lifecycle Screen').tap();
28
+    await elementById(testIDs.PUSH_LIFECYCLE_BUTTON).tap();
28 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 31
     await expect(elementByLabel('Alert')).toBeVisible();
31 32
     await expect(elementByLabel('didDisappear')).toBeVisible();
32 33
   });
33 34
 
34 35
   it('unmount is called on pop', async () => {
35
-    await elementByLabel('Push Lifecycle Screen').tap();
36
+    await elementById(testIDs.PUSH_LIFECYCLE_BUTTON).tap();
36 37
     await expect(elementByLabel('didAppear')).toBeVisible();
37 38
     await Utils.tapBackIos();
38 39
     await expect(elementByLabel('componentWillUnmount')).toBeVisible();
@@ -47,9 +48,9 @@ describe('reload app', async () => {
47 48
   });
48 49
 
49 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 52
     await expect(elementByLabel('Pushed Screen')).toBeVisible();
52 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,6 +1,6 @@
1 1
 module.exports = {
2 2
   elementByLabel: (label) => {
3
-    return element(by.label(label));
3
+    return element(by.text(label));
4 4
   },
5 5
   elementById: (id) => {
6 6
     return element(by.id(id));

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

@@ -81,7 +81,7 @@ public class NavigationModule extends ReactContextBaseJavaModule {
81 81
 	}
82 82
 
83 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 85
 		handle(new Runnable() {
86 86
 			@Override
87 87
 			public void run() {

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

@@ -4,6 +4,7 @@ const { Component } = require('react');
4 4
 const { View, Text, Button, Platform } = require('react-native');
5 5
 
6 6
 const Navigation = require('react-native-navigation');
7
+const testIDs = require('../testIDs');
7 8
 
8 9
 class LifecycleScreen extends Component {
9 10
   constructor(props) {
@@ -53,7 +54,7 @@ class LifecycleScreen extends Component {
53 54
       <View style={styles.root}>
54 55
         <Text style={styles.h1}>{`Lifecycle Screen`}</Text>
55 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 58
         <Text style={styles.footer}>{`this.props.containerId = ${this.props.containerId}`}</Text>
58 59
       </View>
59 60
     );

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

@@ -6,6 +6,7 @@ const { Component } = require('react');
6 6
 const { View, Text, Button } = require('react-native');
7 7
 
8 8
 const Navigation = require('react-native-navigation');
9
+const testIDs = require('../testIDs');
9 10
 
10 11
 class ModalScreen extends Component {
11 12
   static get navigationOptions() {
@@ -28,15 +29,15 @@ class ModalScreen extends Component {
28 29
   render() {
29 30
     return (
30 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 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 41
         <Text style={styles.footer}>{`this.props.containerId = ${this.props.containerId}`}</Text>
41 42
       </View>
42 43
     );

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

@@ -4,6 +4,7 @@ const { Component } = require('react');
4 4
 const { View, Text, Button } = require('react-native');
5 5
 
6 6
 const Navigation = require('react-native-navigation');
7
+const testIDs = require('../testIDs');
7 8
 
8 9
 const BUTTON_ONE = 'buttonOne';
9 10
 const BUTTON_TWO = 'buttonTwo';
@@ -49,16 +50,16 @@ class OptionsScreen extends Component {
49 50
   render() {
50 51
     return (
51 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 57
         <Button title="Top Bar Transparent" onPress={this.onClickTopBarTransparent} />
57 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 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 63
         <Text style={styles.footer}>{`this.props.containerId = ${this.props.containerId}`}</Text>
63 64
       </View>
64 65
     );

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

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

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

@@ -3,6 +3,7 @@ const { Component } = require('react');
3 3
 const { View, Text, Button } = require('react-native');
4 4
 
5 5
 const Navigation = require('react-native-navigation');
6
+const testIDs = require('../testIDs');
6 7
 
7 8
 class OrientationSelectScreen extends Component {
8 9
 
@@ -10,10 +11,10 @@ class OrientationSelectScreen extends Component {
10 11
     return (
11 12
       <View style={styles.root}>
12 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 18
       </View>
18 19
     );
19 20
   }

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

@@ -6,6 +6,7 @@ const { Component } = require('react');
6 6
 const { View, Text, Button } = require('react-native');
7 7
 
8 8
 const Navigation = require('react-native-navigation');
9
+const testIDs = require('../testIDs');
9 10
 
10 11
 class PushedScreen extends Component {
11 12
   constructor(props) {
@@ -21,13 +22,13 @@ class PushedScreen extends Component {
21 22
     const stackPosition = this.getStackPosition();
22 23
     return (
23 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 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 32
         <Text style={styles.footer}>{`this.props.containerId = ${this.props.containerId}`}</Text>
32 33
       </View>
33 34
     );

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

@@ -4,6 +4,7 @@ const { Component } = require('react');
4 4
 const { StyleSheet, ScrollView, View, Button } = require('react-native');
5 5
 
6 6
 const Navigation = require('react-native-navigation');
7
+const testIDs = require('../testIDs');
7 8
 
8 9
 class ScrollViewScreen extends Component {
9 10
   static get navigationOptions() {
@@ -25,9 +26,9 @@ class ScrollViewScreen extends Component {
25 26
   render() {
26 27
     return (
27 28
       <View>
28
-        <ScrollView testID="scrollView" contentContainerStyle={styles.contentContainer}>
29
+        <ScrollView testID={testIDs.SCROLLVIEW_ELEMENT} contentContainerStyle={styles.contentContainer}>
29 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 32
           </View>
32 33
         </ScrollView>
33 34
       </View>

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

@@ -4,6 +4,7 @@ const { Component } = require('react');
4 4
 const { View, Text, Button } = require('react-native');
5 5
 
6 6
 const Navigation = require('react-native-navigation');
7
+const testIDs = require('../testIDs');
7 8
 
8 9
 class TextScreen extends Component {
9 10
 
@@ -13,8 +14,8 @@ class TextScreen extends Component {
13 14
         <Text style={styles.h1}>{this.props.text || 'Text Screen'}</Text>
14 15
         {this.renderTextFromFunctionInProps()}
15 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 19
         <Button title="Hide Tab Bar" onPress={() => this.hideTabBar(true)} />
19 20
         <Button title="Show Tab Bar" onPress={() => this.hideTabBar(false)} />
20 21
       </View>

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

@@ -1,6 +1,9 @@
1 1
 const React = require('react');
2 2
 const { Component } = require('react');
3 3
 const { View, Text, Button } = require('react-native');
4
+
5
+const testIDs = require('../testIDs');
6
+
4 7
 const Navigation = require('react-native-navigation');
5 8
 
6 9
 class WelcomeScreen extends Component {
@@ -24,16 +27,16 @@ class WelcomeScreen extends Component {
24 27
   render() {
25 28
     return (
26 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 40
         <Text style={styles.footer}>{`this.props.containerId = ${this.props.containerId}`}</Text>
38 41
       </View>
39 42
     );

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

@@ -0,0 +1,48 @@
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
+};