6
6
import { act , render , screen , waitFor } from '@testing-library/react-native' ;
7
7
import React from 'react' ;
8
8
import Onyx from 'react-native-onyx' ;
9
- import * as Localize from '@libs/Localize' ;
10
- import * as AppActions from '@userActions/App' ;
11
- import * as User from '@userActions/User' ;
9
+ import { translateLocal } from '@libs/Localize' ;
10
+ import { setSidebarLoaded } from '@userActions/App' ;
11
+ import { subscribeToUserEvents } from '@userActions/User' ;
12
12
import App from '@src/App' ;
13
13
import CONST from '@src/CONST' ;
14
14
import ONYXKEYS from '@src/ONYXKEYS' ;
@@ -82,7 +82,7 @@ function signInAndGetApp(reportName = '', participantAccountIDs?: number[]): Pro
82
82
return waitForBatchedUpdatesWithAct ( )
83
83
. then ( async ( ) => {
84
84
await waitForBatchedUpdatesWithAct ( ) ;
85
- const hintText = Localize . translateLocal ( 'loginForm.loginForm' ) ;
85
+ const hintText = translateLocal ( 'loginForm.loginForm' ) ;
86
86
const loginForm = screen . queryAllByLabelText ( hintText ) ;
87
87
expect ( loginForm ) . toHaveLength ( 1 ) ;
88
88
@@ -92,7 +92,7 @@ function signInAndGetApp(reportName = '', participantAccountIDs?: number[]): Pro
92
92
return waitForBatchedUpdatesWithAct ( ) ;
93
93
} )
94
94
. then ( ( ) => {
95
- User . subscribeToUserEvents ( ) ;
95
+ subscribeToUserEvents ( ) ;
96
96
return waitForBatchedUpdates ( ) ;
97
97
} )
98
98
. then ( async ( ) => {
@@ -119,7 +119,7 @@ function signInAndGetApp(reportName = '', participantAccountIDs?: number[]): Pro
119
119
} ) ;
120
120
121
121
// We manually setting the sidebar as loaded since the onLayout event does not fire in tests
122
- AppActions . setSidebarLoaded ( ) ;
122
+ setSidebarLoaded ( ) ;
123
123
return waitForBatchedUpdatesWithAct ( ) ;
124
124
} ) ;
125
125
}
@@ -143,16 +143,16 @@ describe('Tests for group chat name', () => {
143
143
it ( 'Should show correctly in LHN' , ( ) =>
144
144
signInAndGetApp ( 'A, B, C, D' , participantAccountIDs4 ) . then ( ( ) => {
145
145
// Verify the sidebar links are rendered
146
- const sidebarLinksHintText = Localize . translateLocal ( 'sidebarScreen.listOfChats' ) ;
146
+ const sidebarLinksHintText = translateLocal ( 'sidebarScreen.listOfChats' ) ;
147
147
const sidebarLinks = screen . queryAllByLabelText ( sidebarLinksHintText ) ;
148
148
expect ( sidebarLinks ) . toHaveLength ( 1 ) ;
149
149
150
150
// Verify there is only one option in the sidebar
151
- const optionRowsHintText = Localize . translateLocal ( 'accessibilityHints.navigatesToChat' ) ;
151
+ const optionRowsHintText = translateLocal ( 'accessibilityHints.navigatesToChat' ) ;
152
152
const optionRows = screen . queryAllByAccessibilityHint ( optionRowsHintText ) ;
153
153
expect ( optionRows ) . toHaveLength ( 1 ) ;
154
154
155
- const displayNameHintText = Localize . translateLocal ( 'accessibilityHints.chatUserDisplayNames' ) ;
155
+ const displayNameHintText = translateLocal ( 'accessibilityHints.chatUserDisplayNames' ) ;
156
156
const displayNameText = screen . queryByLabelText ( displayNameHintText ) ;
157
157
158
158
return waitFor ( ( ) => expect ( displayNameText ?. props ?. children ?. [ 0 ] ) . toBe ( 'A, B, C, D' ) ) ;
@@ -161,16 +161,16 @@ describe('Tests for group chat name', () => {
161
161
it ( 'Should show correctly in LHN when report name is not present' , ( ) =>
162
162
signInAndGetApp ( '' , participantAccountIDs4 ) . then ( ( ) => {
163
163
// Verify the sidebar links are rendered
164
- const sidebarLinksHintText = Localize . translateLocal ( 'sidebarScreen.listOfChats' ) ;
164
+ const sidebarLinksHintText = translateLocal ( 'sidebarScreen.listOfChats' ) ;
165
165
const sidebarLinks = screen . queryAllByLabelText ( sidebarLinksHintText ) ;
166
166
expect ( sidebarLinks ) . toHaveLength ( 1 ) ;
167
167
168
168
// Verify there is only one option in the sidebar
169
- const optionRowsHintText = Localize . translateLocal ( 'accessibilityHints.navigatesToChat' ) ;
169
+ const optionRowsHintText = translateLocal ( 'accessibilityHints.navigatesToChat' ) ;
170
170
const optionRows = screen . queryAllByAccessibilityHint ( optionRowsHintText ) ;
171
171
expect ( optionRows ) . toHaveLength ( 1 ) ;
172
172
173
- const displayNameHintText = Localize . translateLocal ( 'accessibilityHints.chatUserDisplayNames' ) ;
173
+ const displayNameHintText = translateLocal ( 'accessibilityHints.chatUserDisplayNames' ) ;
174
174
const displayNameText = screen . queryByLabelText ( displayNameHintText ) ;
175
175
176
176
return waitFor ( ( ) => expect ( displayNameText ?. props ?. children ?. [ 0 ] ) . toBe ( 'A, B, C, D' ) ) ;
@@ -179,16 +179,16 @@ describe('Tests for group chat name', () => {
179
179
it ( 'Should show limited names in LHN when 8 participants are present' , ( ) =>
180
180
signInAndGetApp ( '' , participantAccountIDs8 ) . then ( ( ) => {
181
181
// Verify the sidebar links are rendered
182
- const sidebarLinksHintText = Localize . translateLocal ( 'sidebarScreen.listOfChats' ) ;
182
+ const sidebarLinksHintText = translateLocal ( 'sidebarScreen.listOfChats' ) ;
183
183
const sidebarLinks = screen . queryAllByLabelText ( sidebarLinksHintText ) ;
184
184
expect ( sidebarLinks ) . toHaveLength ( 1 ) ;
185
185
186
186
// Verify there is only one option in the sidebar
187
- const optionRowsHintText = Localize . translateLocal ( 'accessibilityHints.navigatesToChat' ) ;
187
+ const optionRowsHintText = translateLocal ( 'accessibilityHints.navigatesToChat' ) ;
188
188
const optionRows = screen . queryAllByAccessibilityHint ( optionRowsHintText ) ;
189
189
expect ( optionRows ) . toHaveLength ( 1 ) ;
190
190
191
- const displayNameHintText = Localize . translateLocal ( 'accessibilityHints.chatUserDisplayNames' ) ;
191
+ const displayNameHintText = translateLocal ( 'accessibilityHints.chatUserDisplayNames' ) ;
192
192
const displayNameText = screen . queryByLabelText ( displayNameHintText ) ;
193
193
194
194
return waitFor ( ( ) => expect ( displayNameText ?. props ?. children ?. [ 0 ] ) . toBe ( 'A, B, C, D, E' ) ) ;
@@ -198,16 +198,16 @@ describe('Tests for group chat name', () => {
198
198
signInAndGetApp ( '' , participantAccountIDs4 )
199
199
. then ( ( ) => {
200
200
// Verify the sidebar links are rendered
201
- const sidebarLinksHintText = Localize . translateLocal ( 'sidebarScreen.listOfChats' ) ;
201
+ const sidebarLinksHintText = translateLocal ( 'sidebarScreen.listOfChats' ) ;
202
202
const sidebarLinks = screen . queryAllByLabelText ( sidebarLinksHintText ) ;
203
203
expect ( sidebarLinks ) . toHaveLength ( 1 ) ;
204
204
205
205
// Verify there is only one option in the sidebar
206
- const optionRowsHintText = Localize . translateLocal ( 'accessibilityHints.navigatesToChat' ) ;
206
+ const optionRowsHintText = translateLocal ( 'accessibilityHints.navigatesToChat' ) ;
207
207
const optionRows = screen . queryAllByAccessibilityHint ( optionRowsHintText ) ;
208
208
expect ( optionRows ) . toHaveLength ( 1 ) ;
209
209
210
- const displayNameHintText = Localize . translateLocal ( 'accessibilityHints.chatUserDisplayNames' ) ;
210
+ const displayNameHintText = translateLocal ( 'accessibilityHints.chatUserDisplayNames' ) ;
211
211
const displayNameText = screen . queryByLabelText ( displayNameHintText ) ;
212
212
213
213
expect ( displayNameText ?. props ?. children ?. [ 0 ] ) . toBe ( 'A, B, C, D' ) ;
@@ -226,16 +226,16 @@ describe('Tests for group chat name', () => {
226
226
signInAndGetApp ( '' , participantAccountIDs8 )
227
227
. then ( ( ) => {
228
228
// Verify the sidebar links are rendered
229
- const sidebarLinksHintText = Localize . translateLocal ( 'sidebarScreen.listOfChats' ) ;
229
+ const sidebarLinksHintText = translateLocal ( 'sidebarScreen.listOfChats' ) ;
230
230
const sidebarLinks = screen . queryAllByLabelText ( sidebarLinksHintText ) ;
231
231
expect ( sidebarLinks ) . toHaveLength ( 1 ) ;
232
232
233
233
// Verify there is only one option in the sidebar
234
- const optionRowsHintText = Localize . translateLocal ( 'accessibilityHints.navigatesToChat' ) ;
234
+ const optionRowsHintText = translateLocal ( 'accessibilityHints.navigatesToChat' ) ;
235
235
const optionRows = screen . queryAllByAccessibilityHint ( optionRowsHintText ) ;
236
236
expect ( optionRows ) . toHaveLength ( 1 ) ;
237
237
238
- const displayNameHintText = Localize . translateLocal ( 'accessibilityHints.chatUserDisplayNames' ) ;
238
+ const displayNameHintText = translateLocal ( 'accessibilityHints.chatUserDisplayNames' ) ;
239
239
const displayNameText = screen . queryByLabelText ( displayNameHintText ) ;
240
240
241
241
expect ( displayNameText ?. props ?. children ?. [ 0 ] ) . toBe ( 'A, B, C, D, E' ) ;
@@ -254,16 +254,16 @@ describe('Tests for group chat name', () => {
254
254
signInAndGetApp ( 'Test chat' , participantAccountIDs4 )
255
255
. then ( ( ) => {
256
256
// Verify the sidebar links are rendered
257
- const sidebarLinksHintText = Localize . translateLocal ( 'sidebarScreen.listOfChats' ) ;
257
+ const sidebarLinksHintText = translateLocal ( 'sidebarScreen.listOfChats' ) ;
258
258
const sidebarLinks = screen . queryAllByLabelText ( sidebarLinksHintText ) ;
259
259
expect ( sidebarLinks ) . toHaveLength ( 1 ) ;
260
260
261
261
// Verify there is only one option in the sidebar
262
- const optionRowsHintText = Localize . translateLocal ( 'accessibilityHints.navigatesToChat' ) ;
262
+ const optionRowsHintText = translateLocal ( 'accessibilityHints.navigatesToChat' ) ;
263
263
const optionRows = screen . queryAllByAccessibilityHint ( optionRowsHintText ) ;
264
264
expect ( optionRows ) . toHaveLength ( 1 ) ;
265
265
266
- const displayNameHintText = Localize . translateLocal ( 'accessibilityHints.chatUserDisplayNames' ) ;
266
+ const displayNameHintText = translateLocal ( 'accessibilityHints.chatUserDisplayNames' ) ;
267
267
const displayNameText = screen . queryByLabelText ( displayNameHintText ) ;
268
268
269
269
expect ( displayNameText ?. props ?. children ?. [ 0 ] ) . toBe ( 'Test chat' ) ;
@@ -282,16 +282,16 @@ describe('Tests for group chat name', () => {
282
282
signInAndGetApp ( "Let's talk" , participantAccountIDs8 )
283
283
. then ( ( ) => {
284
284
// Verify the sidebar links are rendered
285
- const sidebarLinksHintText = Localize . translateLocal ( 'sidebarScreen.listOfChats' ) ;
285
+ const sidebarLinksHintText = translateLocal ( 'sidebarScreen.listOfChats' ) ;
286
286
const sidebarLinks = screen . queryAllByLabelText ( sidebarLinksHintText ) ;
287
287
expect ( sidebarLinks ) . toHaveLength ( 1 ) ;
288
288
289
289
// Verify there is only one option in the sidebar
290
- const optionRowsHintText = Localize . translateLocal ( 'accessibilityHints.navigatesToChat' ) ;
290
+ const optionRowsHintText = translateLocal ( 'accessibilityHints.navigatesToChat' ) ;
291
291
const optionRows = screen . queryAllByAccessibilityHint ( optionRowsHintText ) ;
292
292
expect ( optionRows ) . toHaveLength ( 1 ) ;
293
293
294
- const displayNameHintText = Localize . translateLocal ( 'accessibilityHints.chatUserDisplayNames' ) ;
294
+ const displayNameHintText = translateLocal ( 'accessibilityHints.chatUserDisplayNames' ) ;
295
295
const displayNameText = screen . queryByLabelText ( displayNameHintText ) ;
296
296
297
297
expect ( displayNameText ?. props ?. children ?. [ 0 ] ) . toBe ( "Let's talk" ) ;
@@ -306,37 +306,37 @@ describe('Tests for group chat name', () => {
306
306
return waitFor ( ( ) => expect ( displayNameTexts ) . toHaveLength ( 1 ) ) ;
307
307
} ) ) ;
308
308
309
- it . skip ( 'Should show last message preview in LHN' , ( ) =>
309
+ it ( 'Should show last message preview in LHN' , ( ) =>
310
310
signInAndGetApp ( 'A, B, C, D' , participantAccountIDs4 ) . then ( ( ) => {
311
311
// Verify the sidebar links are rendered
312
- const sidebarLinksHintText = Localize . translateLocal ( 'sidebarScreen.listOfChats' ) ;
312
+ const sidebarLinksHintText = translateLocal ( 'sidebarScreen.listOfChats' ) ;
313
313
const sidebarLinks = screen . queryAllByLabelText ( sidebarLinksHintText ) ;
314
314
expect ( sidebarLinks ) . toHaveLength ( 1 ) ;
315
315
316
316
// Verify there is only one option in the sidebar
317
- const optionRowsHintText = Localize . translateLocal ( 'accessibilityHints.navigatesToChat' ) ;
317
+ const optionRowsHintText = translateLocal ( 'accessibilityHints.navigatesToChat' ) ;
318
318
const optionRows = screen . queryAllByAccessibilityHint ( optionRowsHintText ) ;
319
319
expect ( optionRows ) . toHaveLength ( 1 ) ;
320
320
321
- const lastChatHintText = Localize . translateLocal ( 'accessibilityHints.lastChatMessagePreview' ) ;
321
+ const lastChatHintText = translateLocal ( 'accessibilityHints.lastChatMessagePreview' ) ;
322
322
const lastChatText = screen . queryByLabelText ( lastChatHintText ) ;
323
323
324
324
return waitFor ( ( ) => expect ( lastChatText ?. props ?. children ) . toBe ( 'B: Test' ) ) ;
325
325
} ) ) ;
326
326
327
- it . skip ( 'Should sort the names before displaying' , ( ) =>
327
+ it ( 'Should sort the names before displaying' , ( ) =>
328
328
signInAndGetApp ( '' , [ USER_E_ACCOUNT_ID , ...participantAccountIDs4 ] ) . then ( ( ) => {
329
329
// Verify the sidebar links are rendered
330
- const sidebarLinksHintText = Localize . translateLocal ( 'sidebarScreen.listOfChats' ) ;
330
+ const sidebarLinksHintText = translateLocal ( 'sidebarScreen.listOfChats' ) ;
331
331
const sidebarLinks = screen . queryAllByLabelText ( sidebarLinksHintText ) ;
332
332
expect ( sidebarLinks ) . toHaveLength ( 1 ) ;
333
333
334
334
// Verify there is only one option in the sidebar
335
- const optionRowsHintText = Localize . translateLocal ( 'accessibilityHints.navigatesToChat' ) ;
335
+ const optionRowsHintText = translateLocal ( 'accessibilityHints.navigatesToChat' ) ;
336
336
const optionRows = screen . queryAllByAccessibilityHint ( optionRowsHintText ) ;
337
337
expect ( optionRows ) . toHaveLength ( 1 ) ;
338
338
339
- const displayNameHintText = Localize . translateLocal ( 'accessibilityHints.chatUserDisplayNames' ) ;
339
+ const displayNameHintText = translateLocal ( 'accessibilityHints.chatUserDisplayNames' ) ;
340
340
const displayNameText = screen . queryByLabelText ( displayNameHintText ) ;
341
341
342
342
return waitFor ( ( ) => expect ( displayNameText ?. props ?. children ?. [ 0 ] ) . toBe ( 'A, B, C, D, E' ) ) ;
0 commit comments