Browse Source

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

master
damencho 5 years ago
parent
commit
b106e51a10

+ 7
- 0
react/features/base/avatar/components/Avatar.js View File

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

+ 10
- 1
react/features/base/avatar/components/web/StatelessAvatar.js View File

@@ -25,7 +25,12 @@ type Props = AbstractProps & {
25 25
     /**
26 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,6 +50,7 @@ export default class StatelessAvatar extends AbstractStatelessAvatar<Props> {
45 50
             return (
46 51
                 <div
47 52
                     className = { `${this._getAvatarClassName()} ${this._getBadgeClassName()}` }
53
+                    data-testid = { this.props.testId }
48 54
                     id = { this.props.id }
49 55
                     style = { this._getAvatarStyle(this.props.color) }>
50 56
                     <Icon
@@ -59,6 +65,7 @@ export default class StatelessAvatar extends AbstractStatelessAvatar<Props> {
59 65
                 <div className = { this._getBadgeClassName() }>
60 66
                     <img
61 67
                         className = { this._getAvatarClassName() }
68
+                        data-testid = { this.props.testId }
62 69
                         id = { this.props.id }
63 70
                         onError = { this.props.onAvatarLoadError }
64 71
                         src = { url }
@@ -71,6 +78,7 @@ export default class StatelessAvatar extends AbstractStatelessAvatar<Props> {
71 78
             return (
72 79
                 <div
73 80
                     className = { `${this._getAvatarClassName()} ${this._getBadgeClassName()}` }
81
+                    data-testid = { this.props.testId }
74 82
                     id = { this.props.id }
75 83
                     style = { this._getAvatarStyle(this.props.color) }>
76 84
                     <svg
@@ -97,6 +105,7 @@ export default class StatelessAvatar extends AbstractStatelessAvatar<Props> {
97 105
             <div className = { this._getBadgeClassName() }>
98 106
                 <img
99 107
                     className = { this._getAvatarClassName('defaultAvatar') }
108
+                    data-testid = { this.props.testId }
100 109
                     id = { this.props.id }
101 110
                     src = { this.props.defaultAvatar || 'images/avatar.png' }
102 111
                     style = { this._getAvatarStyle() } />

+ 7
- 0
react/features/base/premeeting/components/web/ActionButton.js View File

@@ -26,6 +26,11 @@ type Props = {
26 26
      */
27 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 35
      * The type of th button: primary, secondary, text.
31 36
      */
@@ -52,6 +57,7 @@ function ActionButton({
52 57
     className = '',
53 58
     disabled,
54 59
     hasOptions,
60
+    testId,
55 61
     type = 'primary',
56 62
     onClick,
57 63
     onOptionsClick
@@ -59,6 +65,7 @@ function ActionButton({
59 65
     return (
60 66
         <div
61 67
             className = { `action-btn ${className} ${type} ${disabled ? 'disabled' : ''}` }
68
+            data-testid = { testId ? testId : undefined }
62 69
             onClick = { disabled ? undefined : onClick }>
63 70
             {children}
64 71
             {hasOptions && <div

+ 6
- 0
react/features/base/premeeting/components/web/InputField.js View File

@@ -11,6 +11,11 @@ type Props = {
11 11
      */
12 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 20
      * Callback for the onChange event of the field.
16 21
      */
@@ -105,6 +110,7 @@ export default class InputField extends PureComponent<Props, State> {
105 110
         return (
106 111
             <input
107 112
                 className = { `field ${this.state.focused ? 'focused' : ''} ${this.props.className || ''}` }
113
+                data-testid = { this.props.testId ? this.props.testId : undefined }
108 114
                 onBlur = { this._onBlur }
109 115
                 onChange = { this._onChange }
110 116
                 onFocus = { this._onFocus }

+ 5
- 2
react/features/lobby/components/web/KnockingParticipantList.js View File

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

+ 6
- 0
react/features/lobby/components/web/LobbyScreen.js View File

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

+ 2
- 1
react/features/notifications/components/web/Notification.js View File

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

+ 1
- 0
react/features/prejoin/components/Prejoin.js View File

@@ -313,6 +313,7 @@ class Prejoin extends Component<Props, State> {
313 313
                                         hasOptions = { true }
314 314
                                         onClick = { joinConference }
315 315
                                         onOptionsClick = { _onOptionsClick }
316
+                                        testId = 'prejoin.joinMeeting'
316 317
                                         type = 'primary'>
317 318
                                         { t('prejoin.joinMeeting') }
318 319
                                     </ActionButton>

Loading…
Cancel
Save