浏览代码

Add e2e for title/react view use case

Guy Carmeli 5 年前
父节点
当前提交
1b5bd6811e
共有 3 个文件被更改,包括 17 次插入0 次删除
  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 查看文件

74
     await expect(elementByLabel('Press Me')).toBeVisible();
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
   it('Popping screen with yellow box should not crash', async () => {
84
   it('Popping screen with yellow box should not crash', async () => {
78
     await elementById(TestIDs.SHOW_YELLOW_BOX_BTN).tap();
85
     await elementById(TestIDs.SHOW_YELLOW_BOX_BTN).tap();
79
     await elementById(TestIDs.PUSH_BTN).tap();
86
     await elementById(TestIDs.PUSH_BTN).tap();

+ 9
- 0
playground/src/screens/OptionsScreen.js 查看文件

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

+ 1
- 0
playground/src/testIDs.js 查看文件

54
   SET_TOPBAR_REACT_VIEW: 'SET_TOPBAR_REACT_VIEW',
54
   SET_TOPBAR_REACT_VIEW: 'SET_TOPBAR_REACT_VIEW',
55
   SHOW_YELLOW_BOX_BTN: 'SHOW_YELLOW_BOX_BTN',
55
   SHOW_YELLOW_BOX_BTN: 'SHOW_YELLOW_BOX_BTN',
56
   SET_REACT_TITLE_VIEW: 'SET_REACT_TITLE_VIEW',
56
   SET_REACT_TITLE_VIEW: 'SET_REACT_TITLE_VIEW',
57
+  SET_TITLE: 'SET_TITLE',
57
   STATIC_EVENTS_OVERLAY_BTN: 'STATIC_EVENTS_OVERLAY_BTN',
58
   STATIC_EVENTS_OVERLAY_BTN: 'STATIC_EVENTS_OVERLAY_BTN',
58
   PUSH_LIFECYCLE_BTN: 'PUSH_LIFECYCLE_BTN',
59
   PUSH_LIFECYCLE_BTN: 'PUSH_LIFECYCLE_BTN',
59
   MODAL_LIFECYCLE_BTN: 'MODAL_LIFECYCLE_BTN',
60
   MODAL_LIFECYCLE_BTN: 'MODAL_LIFECYCLE_BTN',