@@ -107,7 +107,7 @@ describe("Manage password", () => {
107
107
} ) ;
108
108
109
109
test ( "Cancel alert" , async ( ) => {
110
- const { queryByTestId, getByTestId, unmount } = render (
110
+ const { queryByTestId, getByTestId, queryByText } = render (
111
111
< Provider store = { storeMocked } >
112
112
< ManagePassword />
113
113
</ Provider >
@@ -126,6 +126,15 @@ describe("Manage password", () => {
126
126
fireEvent . click ( getByTestId ( "settings-item-toggle-password" ) ) ;
127
127
} ) ;
128
128
129
+ await waitFor ( ( ) => {
130
+ expect (
131
+ queryByText (
132
+ TRANSLATIONS . tabs . menu . tab . settings . sections . security . managepassword
133
+ . page . alert . enablemessage
134
+ )
135
+ ) . toBeVisible ( ) ;
136
+ } ) ;
137
+
129
138
await waitFor ( ( ) => {
130
139
expect (
131
140
getByTestId ( "alert-cancel-enable-password" ) . getAttribute ( "is-open" )
@@ -141,6 +150,15 @@ describe("Manage password", () => {
141
150
) ;
142
151
} ) ;
143
152
153
+ await waitFor ( ( ) => {
154
+ expect (
155
+ queryByText (
156
+ TRANSLATIONS . tabs . menu . tab . settings . sections . security . managepassword
157
+ . page . alert . enablemessage
158
+ )
159
+ ) . toBeNull ( ) ;
160
+ } ) ;
161
+
144
162
await waitFor ( ( ) => {
145
163
expect (
146
164
getByTestId ( "alert-cancel-enable-password" ) . getAttribute ( "is-open" )
@@ -149,17 +167,11 @@ describe("Manage password", () => {
149
167
expect ( queryByTestId ( "create-password-modal" ) ) . toBe ( null ) ;
150
168
} ) ;
151
169
152
- unmount ( ) ;
170
+ document . getElementsByTagName ( "html" ) [ 0 ] . innerHTML = "" ;
153
171
} ) ;
154
172
155
173
test ( "Password not set" , async ( ) => {
156
- const {
157
- queryByTestId,
158
- getByTestId,
159
- getByText,
160
- findByText,
161
- getAllByTestId,
162
- } = render (
174
+ const { queryByTestId, getByTestId, getByText, queryByText } = render (
163
175
< Provider store = { storeMocked } >
164
176
< ManagePassword />
165
177
</ Provider >
@@ -174,23 +186,30 @@ describe("Manage password", () => {
174
186
fireEvent . click ( getByTestId ( "settings-item-toggle-password" ) ) ;
175
187
} ) ;
176
188
177
- const text = await waitFor ( async ( ) => {
178
- return await findByText (
179
- TRANSLATIONS . tabs . menu . tab . settings . sections . security . managepassword
180
- . page . alert . enablemessage
181
- ) ;
182
- } ) ;
183
-
184
189
await waitFor ( ( ) => {
185
- expect ( text ) . toBeVisible ( ) ;
190
+ expect (
191
+ getByText (
192
+ TRANSLATIONS . tabs . menu . tab . settings . sections . security . managepassword
193
+ . page . alert . enablemessage
194
+ )
195
+ ) . toBeVisible ( ) ;
186
196
} ) ;
187
197
188
198
act ( ( ) => {
189
199
fireEvent . click (
190
- getAllByTestId ( "alert-cancel-enable-password-confirm-button" ) [ 0 ]
200
+ getByTestId ( "alert-cancel-enable-password-confirm-button" )
191
201
) ;
192
202
} ) ;
193
203
204
+ await waitFor ( ( ) => {
205
+ expect (
206
+ queryByText (
207
+ TRANSLATIONS . tabs . menu . tab . settings . sections . security . managepassword
208
+ . page . alert . enablemessage
209
+ )
210
+ ) . toBeNull ( ) ;
211
+ } ) ;
212
+
194
213
await waitFor ( ( ) => {
195
214
expect ( getByText ( "1" ) ) . toBeVisible ( ) ;
196
215
} ) ;
@@ -200,6 +219,8 @@ describe("Manage password", () => {
200
219
await waitFor ( ( ) => {
201
220
expect ( getByTestId ( "create-password-modal" ) ) . toBeVisible ( ) ;
202
221
} ) ;
222
+
223
+ document . getElementsByTagName ( "html" ) [ 0 ] . innerHTML = "" ;
203
224
} ) ;
204
225
205
226
test ( "Disable password option" , async ( ) => {
@@ -233,7 +254,7 @@ describe("Manage password", () => {
233
254
dispatch : dispatchMock ,
234
255
} ;
235
256
236
- const { queryByTestId, getByTestId, findByText } = render (
257
+ const { queryByTestId, getByTestId, queryByText , getByText } = render (
237
258
< Provider store = { storeMocked } >
238
259
< ManagePassword />
239
260
</ Provider >
@@ -248,19 +269,28 @@ describe("Manage password", () => {
248
269
fireEvent . click ( getByTestId ( "settings-item-toggle-password" ) ) ;
249
270
} ) ;
250
271
251
- const text = await findByText (
252
- TRANSLATIONS . tabs . menu . tab . settings . sections . security . managepassword . page
253
- . alert . disablemessage
254
- ) ;
255
-
256
272
await waitFor ( ( ) => {
257
- expect ( text ) . toBeVisible ( ) ;
273
+ expect (
274
+ getByText (
275
+ TRANSLATIONS . tabs . menu . tab . settings . sections . security . managepassword
276
+ . page . alert . disablemessage
277
+ )
278
+ ) . toBeVisible ( ) ;
258
279
} ) ;
259
280
260
281
act ( ( ) => {
261
282
fireEvent . click ( getByTestId ( "alert-cancel-confirm-button" ) ) ;
262
283
} ) ;
263
284
285
+ await waitFor ( ( ) => {
286
+ expect (
287
+ queryByText (
288
+ TRANSLATIONS . tabs . menu . tab . settings . sections . security . managepassword
289
+ . page . alert . disablemessage
290
+ )
291
+ ) . toBeNull ( ) ;
292
+ } ) ;
293
+
264
294
await waitFor ( ( ) => {
265
295
expect ( getByTestId ( "verify-password-value" ) ) . toBeVisible ( ) ;
266
296
expect ( getByTestId ( "forgot-hint-btn" ) ) . toBeVisible ( ) ;
0 commit comments