Browse Source

Add e2e for title/react view use case

Guy Carmeli 5 years ago
parent
commit
1b5bd6811e
3 changed files with 17 additions and 0 deletions
  1. 7
    0
      e2e/Options.test.js
  2. 9
    0
      playground/src/screens/OptionsScreen.js
  3. 1
    0
      playground/src/testIDs.js

+ 7
- 0
e2e/Options.test.js View File

@@ -74,6 +74,13 @@ describe('Options', () => {
74 74
     await expect(elementByLabel('Press Me')).toBeVisible();
75 75
   });
76 76
 
77
+  it('set title after setting react component', async () => {
78
+    await elementById(TestIDs.SET_REACT_TITLE_VIEW).tap();
79
+    await expect(elementByLabel('Press Me')).toBeVisible();
80
+    await elementById(TestIDs.SET_TITLE).tap();
81
+    await expect(elementByLabel('Title')).toBeVisible();
82
+  });
83
+
77 84
   it('Popping screen with yellow box should not crash', async () => {
78 85
     await elementById(TestIDs.SHOW_YELLOW_BOX_BTN).tap();
79 86
     await elementById(TestIDs.PUSH_BTN).tap();

+ 9
- 0
playground/src/screens/OptionsScreen.js View File

@@ -67,6 +67,7 @@ class Options extends Component {
67 67
         <Button label='Push' testID={PUSH_BTN} onPress={this.push} />
68 68
         <Button label='Hide TopBar in DefaultOptions' testID={HIDE_TOPBAR_DEFAULT_OPTIONS} onPress={this.hideTopBarInDefaultOptions} />
69 69
         <Button label='Set React Title View' testID={SET_REACT_TITLE_VIEW} onPress={this.setReactTitleView} />
70
+        <Button label='Set Title' testID={SET_REACT_TITLE_VIEW} onPress={this.setTitle} />
70 71
         <Button label='Show Yellow Box' testID={SHOW_YELLOW_BOX_BTN} onPress={() => console.warn('Yellow Box')} />
71 72
         <Button label='StatusBar' onPress={this.statusBarScreen} />
72 73
       </Root>
@@ -120,6 +121,14 @@ class Options extends Component {
120 121
     }
121 122
   });
122 123
 
124
+  setTitle = () => Navigation.mergeOptions(this, {
125
+    topBar: {
126
+      title: {
127
+        text: 'Title'
128
+      }
129
+    }
130
+  });
131
+
123 132
   statusBarScreen = () => Navigation.showModal(Screens.StatusBar);
124 133
 }
125 134
 

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

@@ -54,6 +54,7 @@ module.exports = {
54 54
   SET_TOPBAR_REACT_VIEW: 'SET_TOPBAR_REACT_VIEW',
55 55
   SHOW_YELLOW_BOX_BTN: 'SHOW_YELLOW_BOX_BTN',
56 56
   SET_REACT_TITLE_VIEW: 'SET_REACT_TITLE_VIEW',
57
+  SET_TITLE: 'SET_TITLE',
57 58
   STATIC_EVENTS_OVERLAY_BTN: 'STATIC_EVENTS_OVERLAY_BTN',
58 59
   PUSH_LIFECYCLE_BTN: 'PUSH_LIFECYCLE_BTN',
59 60
   MODAL_LIFECYCLE_BTN: 'MODAL_LIFECYCLE_BTN',