浏览代码

feat: Adds id to the notifications and buttons so we can check for them in the integration tests.

master
damencho 5 年前
父节点
当前提交
b106e51a10

+ 7
- 0
react/features/base/avatar/components/Avatar.js 查看文件

58
      */
58
      */
59
     status?: ?string,
59
     status?: ?string,
60
 
60
 
61
+    /**
62
+     * TestId of the element, if any.
63
+     */
64
+    testId?: string,
65
+
61
     /**
66
     /**
62
      * URL of the avatar, if any.
67
      * URL of the avatar, if any.
63
      */
68
      */
122
             id,
127
             id,
123
             size,
128
             size,
124
             status,
129
             status,
130
+            testId,
125
             url
131
             url
126
         } = this.props;
132
         } = this.props;
127
         const { avatarFailed } = this.state;
133
         const { avatarFailed } = this.state;
134
             onAvatarLoadError: undefined,
140
             onAvatarLoadError: undefined,
135
             size,
141
             size,
136
             status,
142
             status,
143
+            testId,
137
             url: undefined
144
             url: undefined
138
         };
145
         };
139
 
146
 

+ 10
- 1
react/features/base/avatar/components/web/StatelessAvatar.js 查看文件

25
     /**
25
     /**
26
      * One of the expected status strings (e.g. 'available') to render a badge on the avatar, if necessary.
26
      * One of the expected status strings (e.g. 'available') to render a badge on the avatar, if necessary.
27
      */
27
      */
28
-    status?: ?string
28
+    status?: ?string,
29
+
30
+    /**
31
+     * TestId of the element, if any.
32
+     */
33
+    testId?: string
29
 };
34
 };
30
 
35
 
31
 /**
36
 /**
45
             return (
50
             return (
46
                 <div
51
                 <div
47
                     className = { `${this._getAvatarClassName()} ${this._getBadgeClassName()}` }
52
                     className = { `${this._getAvatarClassName()} ${this._getBadgeClassName()}` }
53
+                    data-testid = { this.props.testId }
48
                     id = { this.props.id }
54
                     id = { this.props.id }
49
                     style = { this._getAvatarStyle(this.props.color) }>
55
                     style = { this._getAvatarStyle(this.props.color) }>
50
                     <Icon
56
                     <Icon
59
                 <div className = { this._getBadgeClassName() }>
65
                 <div className = { this._getBadgeClassName() }>
60
                     <img
66
                     <img
61
                         className = { this._getAvatarClassName() }
67
                         className = { this._getAvatarClassName() }
68
+                        data-testid = { this.props.testId }
62
                         id = { this.props.id }
69
                         id = { this.props.id }
63
                         onError = { this.props.onAvatarLoadError }
70
                         onError = { this.props.onAvatarLoadError }
64
                         src = { url }
71
                         src = { url }
71
             return (
78
             return (
72
                 <div
79
                 <div
73
                     className = { `${this._getAvatarClassName()} ${this._getBadgeClassName()}` }
80
                     className = { `${this._getAvatarClassName()} ${this._getBadgeClassName()}` }
81
+                    data-testid = { this.props.testId }
74
                     id = { this.props.id }
82
                     id = { this.props.id }
75
                     style = { this._getAvatarStyle(this.props.color) }>
83
                     style = { this._getAvatarStyle(this.props.color) }>
76
                     <svg
84
                     <svg
97
             <div className = { this._getBadgeClassName() }>
105
             <div className = { this._getBadgeClassName() }>
98
                 <img
106
                 <img
99
                     className = { this._getAvatarClassName('defaultAvatar') }
107
                     className = { this._getAvatarClassName('defaultAvatar') }
108
+                    data-testid = { this.props.testId }
100
                     id = { this.props.id }
109
                     id = { this.props.id }
101
                     src = { this.props.defaultAvatar || 'images/avatar.png' }
110
                     src = { this.props.defaultAvatar || 'images/avatar.png' }
102
                     style = { this._getAvatarStyle() } />
111
                     style = { this._getAvatarStyle() } />

+ 7
- 0
react/features/base/premeeting/components/web/ActionButton.js 查看文件

26
      */
26
      */
27
     hasOptions?: boolean,
27
     hasOptions?: boolean,
28
 
28
 
29
+    /**
30
+     * TestId of the button. Can be used to locate element when testing UI.
31
+     */
32
+    testId?: string,
33
+
29
     /**
34
     /**
30
      * The type of th button: primary, secondary, text.
35
      * The type of th button: primary, secondary, text.
31
      */
36
      */
52
     className = '',
57
     className = '',
53
     disabled,
58
     disabled,
54
     hasOptions,
59
     hasOptions,
60
+    testId,
55
     type = 'primary',
61
     type = 'primary',
56
     onClick,
62
     onClick,
57
     onOptionsClick
63
     onOptionsClick
59
     return (
65
     return (
60
         <div
66
         <div
61
             className = { `action-btn ${className} ${type} ${disabled ? 'disabled' : ''}` }
67
             className = { `action-btn ${className} ${type} ${disabled ? 'disabled' : ''}` }
68
+            data-testid = { testId ? testId : undefined }
62
             onClick = { disabled ? undefined : onClick }>
69
             onClick = { disabled ? undefined : onClick }>
63
             {children}
70
             {children}
64
             {hasOptions && <div
71
             {hasOptions && <div

+ 6
- 0
react/features/base/premeeting/components/web/InputField.js 查看文件

11
      */
11
      */
12
     className?: string,
12
     className?: string,
13
 
13
 
14
+    /**
15
+     * TestId of the button. Can be used to locate element when testing UI.
16
+     */
17
+    testId?: string,
18
+
14
     /**
19
     /**
15
      * Callback for the onChange event of the field.
20
      * Callback for the onChange event of the field.
16
      */
21
      */
105
         return (
110
         return (
106
             <input
111
             <input
107
                 className = { `field ${this.state.focused ? 'focused' : ''} ${this.props.className || ''}` }
112
                 className = { `field ${this.state.focused ? 'focused' : ''} ${this.props.className || ''}` }
113
+                data-testid = { this.props.testId ? this.props.testId : undefined }
108
                 onBlur = { this._onBlur }
114
                 onBlur = { this._onBlur }
109
                 onChange = { this._onChange }
115
                 onChange = { this._onChange }
110
                 onFocus = { this._onFocus }
116
                 onFocus = { this._onFocus }

+ 5
- 2
react/features/lobby/components/web/KnockingParticipantList.js 查看文件

48
                             <Avatar
48
                             <Avatar
49
                                 displayName = { p.name }
49
                                 displayName = { p.name }
50
                                 size = { 48 }
50
                                 size = { 48 }
51
+                                testId = 'knockingParticipant.avatar'
51
                                 url = { p.loadableAvatarUrl } />
52
                                 url = { p.loadableAvatarUrl } />
52
                             <div className = 'details'>
53
                             <div className = 'details'>
53
-                                <span>
54
+                                <span data-testid = 'knockingParticipant.name'>
54
                                     { p.name }
55
                                     { p.name }
55
                                 </span>
56
                                 </span>
56
                                 { p.email && (
57
                                 { p.email && (
57
-                                    <span>
58
+                                    <span data-testid = 'knockingParticipant.email'>
58
                                         { p.email }
59
                                         { p.email }
59
                                     </span>
60
                                     </span>
60
                                 ) }
61
                                 ) }
61
                             </div>
62
                             </div>
62
                             <button
63
                             <button
63
                                 className = 'primary'
64
                                 className = 'primary'
65
+                                data-testid = 'lobby.allow'
64
                                 onClick = { this._onRespondToParticipant(p.id, true) }
66
                                 onClick = { this._onRespondToParticipant(p.id, true) }
65
                                 type = 'button'>
67
                                 type = 'button'>
66
                                 { t('lobby.allow') }
68
                                 { t('lobby.allow') }
67
                             </button>
69
                             </button>
68
                             <button
70
                             <button
69
                                 className = 'borderLess'
71
                                 className = 'borderLess'
72
+                                data-testid = 'lobby.reject'
70
                                 onClick = { this._onRespondToParticipant(p.id, false) }
73
                                 onClick = { this._onRespondToParticipant(p.id, false) }
71
                                 type = 'button'>
74
                                 type = 'button'>
72
                                 { t('lobby.reject') }
75
                                 { t('lobby.reject') }

+ 6
- 0
react/features/lobby/components/web/LobbyScreen.js 查看文件

97
                     <InputField
97
                     <InputField
98
                         onChange = { this._onChangeDisplayName }
98
                         onChange = { this._onChangeDisplayName }
99
                         placeHolder = { t('lobby.nameField') }
99
                         placeHolder = { t('lobby.nameField') }
100
+                        testId = 'lobby.nameField'
100
                         value = { displayName } />
101
                         value = { displayName } />
101
                 </div>
102
                 </div>
102
             </div>
103
             </div>
117
                     className = { _passwordJoinFailed ? 'error' : '' }
118
                     className = { _passwordJoinFailed ? 'error' : '' }
118
                     onChange = { this._onChangePassword }
119
                     onChange = { this._onChangePassword }
119
                     placeHolder = { _passwordJoinFailed ? t('lobby.invalidPassword') : t('lobby.passwordField') }
120
                     placeHolder = { _passwordJoinFailed ? t('lobby.invalidPassword') : t('lobby.passwordField') }
121
+                    testId = 'lobby.password'
120
                     type = 'password'
122
                     type = 'password'
121
                     value = { this.state.password } />
123
                     value = { this.state.password } />
122
             </div>
124
             </div>
136
                 <ActionButton
138
                 <ActionButton
137
                     disabled = { !this.state.password }
139
                     disabled = { !this.state.password }
138
                     onClick = { this._onJoinWithPassword }
140
                     onClick = { this._onJoinWithPassword }
141
+                    testId = 'lobby.passwordJoinButton'
139
                     type = 'primary'>
142
                     type = 'primary'>
140
                     { t('lobby.passwordJoinButton') }
143
                     { t('lobby.passwordJoinButton') }
141
                 </ActionButton>
144
                 </ActionButton>
142
                 <ActionButton
145
                 <ActionButton
143
                     onClick = { this._onSwitchToKnockMode }
146
                     onClick = { this._onSwitchToKnockMode }
147
+                    testId = 'lobby.backToKnockModeButton'
144
                     type = 'secondary'>
148
                     type = 'secondary'>
145
                     { t('lobby.backToKnockModeButton') }
149
                     { t('lobby.backToKnockModeButton') }
146
                 </ActionButton>
150
                 </ActionButton>
161
                 { _knocking || <ActionButton
165
                 { _knocking || <ActionButton
162
                     disabled = { !this.state.displayName }
166
                     disabled = { !this.state.displayName }
163
                     onClick = { this._onAskToJoin }
167
                     onClick = { this._onAskToJoin }
168
+                    testId = 'lobby.knockButton'
164
                     type = 'primary'>
169
                     type = 'primary'>
165
                     { t('lobby.knockButton') }
170
                     { t('lobby.knockButton') }
166
                 </ActionButton> }
171
                 </ActionButton> }
167
                 <ActionButton
172
                 <ActionButton
168
                     onClick = { this._onSwitchToPasswordMode }
173
                     onClick = { this._onSwitchToPasswordMode }
174
+                    testId = 'lobby.enterPasswordButton'
169
                     type = 'secondary'>
175
                     type = 'secondary'>
170
                     { t('lobby.enterPasswordButton') }
176
                     { t('lobby.enterPasswordButton') }
171
                 </ActionButton>
177
                 </ActionButton>

+ 2
- 1
react/features/notifications/components/web/Notification.js 查看文件

62
                 id = { uid }
62
                 id = { uid }
63
                 isDismissAllowed = { isDismissAllowed }
63
                 isDismissAllowed = { isDismissAllowed }
64
                 onDismissed = { onDismissed }
64
                 onDismissed = { onDismissed }
65
+                testId = { titleKey }
65
                 title = { title || t(titleKey, titleArguments) } />
66
                 title = { title || t(titleKey, titleArguments) } />
66
         );
67
         );
67
     }
68
     }
84
 
85
 
85
         // the id is used for testing the UI
86
         // the id is used for testing the UI
86
         return (
87
         return (
87
-            <div id = { this._getDescriptionKey() || description || this.props.titleKey || this.props.title } >
88
+            <div data-testid = { this._getDescriptionKey() } >
88
                 { description }
89
                 { description }
89
             </div>
90
             </div>
90
         );
91
         );

+ 1
- 0
react/features/prejoin/components/Prejoin.js 查看文件

313
                                         hasOptions = { true }
313
                                         hasOptions = { true }
314
                                         onClick = { joinConference }
314
                                         onClick = { joinConference }
315
                                         onOptionsClick = { _onOptionsClick }
315
                                         onOptionsClick = { _onOptionsClick }
316
+                                        testId = 'prejoin.joinMeeting'
316
                                         type = 'primary'>
317
                                         type = 'primary'>
317
                                         { t('prejoin.joinMeeting') }
318
                                         { t('prejoin.joinMeeting') }
318
                                     </ActionButton>
319
                                     </ActionButton>

正在加载...
取消
保存