@@ -197,15 +197,12 @@ const USER_C_EMAIL = 'user_c@test.com';
197
197
let reportAction3CreatedDate : string ;
198
198
let reportAction9CreatedDate : string ;
199
199
200
- // store render result, used to trigger onLayout event
201
- let renderResult : ReturnType < typeof render > | null = null ;
202
-
203
200
/**
204
201
* Sets up a test with a logged in user that has one unread chat from another user. Returns the <App/> test instance.
205
202
*/
206
203
function signInAndGetAppWithUnreadChat ( ) : Promise < void > {
207
204
// Render the App and sign in as a test user.
208
- renderResult = render ( < App /> ) ;
205
+ render ( < App /> ) ;
209
206
return waitForBatchedUpdatesWithAct ( )
210
207
. then ( async ( ) => {
211
208
await waitForBatchedUpdatesWithAct ( ) ;
@@ -465,57 +462,53 @@ describe('Unread Indicators', () => {
465
462
expect ( screen . getAllByText ( 'C User' ) [ 0 ] ) . toBeOnTheScreen ( ) ;
466
463
expect ( displayNameTexts [ 1 ] ?. props ?. style ?. fontWeight ) . toBe ( FontUtils . fontWeight . bold ) ;
467
464
expect ( screen . getByText ( 'B User' ) ) . toBeOnTheScreen ( ) ;
465
+ } ) ) ;
466
+ it ( 'Delete a chat message and verify the unread indicator is moved' , async ( ) => {
467
+ const getUnreadIndicator = ( ) => {
468
+ const newMessageLineIndicatorHintText = Localize . translateLocal ( 'accessibilityHints.newMessageLineIndicator' ) ;
469
+ return screen . queryAllByLabelText ( newMessageLineIndicatorHintText ) ;
470
+ } ;
471
+
472
+ return signInAndGetAppWithUnreadChat ( )
473
+ . then ( ( ) => navigateToSidebarOption ( 0 ) )
474
+ . then ( async ( ) => act ( ( ) => transitionEndCB ?.( ) ) )
475
+ . then ( async ( ) => {
476
+ const reportActionsViewWrapper = await screen . findByTestId ( 'report-actions-view-wrapper' ) ;
477
+ if ( reportActionsViewWrapper ) {
478
+ fireEvent ( reportActionsViewWrapper , 'onLayout' , { nativeEvent : { layout : { x : 0 , y : 0 , width : 100 , height : 100 } } } ) ;
479
+ }
480
+ return waitForBatchedUpdates ( ) ;
468
481
} )
469
- ) ;
470
- it ( 'Delete a chat message and verify the unread indicator is moved' , async ( ) => {
471
- const getUnreadIndicator = ( ) => {
472
- const newMessageLineIndicatorHintText = Localize . translateLocal ( 'accessibilityHints.newMessageLineIndicator' ) ;
473
- return screen . queryAllByLabelText ( newMessageLineIndicatorHintText ) ;
474
- }
475
-
476
- return signInAndGetAppWithUnreadChat ( )
477
- . then ( ( ) => navigateToSidebarOption ( 0 ) )
478
- . then ( async ( ) => await act ( ( ) => transitionEndCB ?.( ) ) )
479
- . then ( async ( ) => {
480
- const reportActionsViewWrapper = await renderResult ?. findByTestId ( 'reportActionsViewWrapper' ) ;
481
- if ( reportActionsViewWrapper ) {
482
- act ( ( ) => {
483
- fireEvent ( reportActionsViewWrapper , 'onLayout' , { nativeEvent : { layout : { x : 0 , y : 0 , width : 100 , height : 100 } } } ) ;
484
- } )
485
- }
486
- return waitForBatchedUpdates ( ) ;
487
- } )
488
- . then ( ( ) => {
489
- // Verify the new line indicator is present, and it's before the action with ID 4
482
+ . then ( ( ) => {
483
+ // Verify the new line indicator is present, and it's before the action with ID 4
484
+ const unreadIndicator = getUnreadIndicator ( ) ;
485
+ expect ( unreadIndicator ) . toHaveLength ( 1 ) ;
486
+ const reportActionID = unreadIndicator [ 0 ] ?. props ?. [ 'data-action-id' ] ;
487
+ expect ( reportActionID ) . toBe ( '4' ) ;
488
+
489
+ // simulate delete comment event from Pusher
490
+ PusherHelper . emitOnyxUpdate ( [
491
+ {
492
+ onyxMethod : Onyx . METHOD . MERGE ,
493
+ key : `${ ONYXKEYS . COLLECTION . REPORT_ACTIONS } ${ REPORT_ID } ` ,
494
+ value : {
495
+ '4' : {
496
+ message : [ ] ,
497
+ } ,
498
+ } ,
499
+ } ,
500
+ ] ) ;
501
+ return waitForBatchedUpdates ( ) ;
502
+ } )
503
+ . then ( ( ) =>
504
+ // Verify the new line indicator is now before the action with ID 5
505
+ waitFor ( ( ) => {
490
506
const unreadIndicator = getUnreadIndicator ( ) ;
491
- expect ( unreadIndicator ) . toHaveLength ( 1 ) ;
492
507
const reportActionID = unreadIndicator [ 0 ] ?. props ?. [ 'data-action-id' ] ;
493
- expect ( reportActionID ) . toBe ( '4' ) ;
494
-
495
- // simulate delete comment event from Pusher
496
- PusherHelper . emitOnyxUpdate ( [
497
- {
498
- onyxMethod : Onyx . METHOD . MERGE ,
499
- key : `${ ONYXKEYS . COLLECTION . REPORT_ACTIONS } ${ REPORT_ID } ` ,
500
- value : {
501
- '4' : {
502
- message : [ ]
503
- }
504
- }
505
- } ,
506
- ] ) ;
507
- return waitForBatchedUpdates ( ) ;
508
- } )
509
- . then ( ( ) => {
510
- // Verify the new line indicator is now before the action with ID 5
511
- return waitFor ( ( ) => {
512
- const unreadIndicator = getUnreadIndicator ( ) ;
513
- expect ( unreadIndicator ) . toHaveLength ( 1 ) ;
514
- const reportActionID = unreadIndicator [ 0 ] ?. props ?. [ 'data-action-id' ] ;
515
- expect ( reportActionID ) . toBe ( '5' ) ;
516
- } )
517
- } )
518
- } )
508
+ expect ( reportActionID ) . toBe ( '5' ) ;
509
+ } ) ,
510
+ ) ;
511
+ } ) ;
519
512
520
513
xit ( 'Manually marking a chat message as unread shows the new line indicator and updates the LHN' , ( ) =>
521
514
signInAndGetAppWithUnreadChat ( )
0 commit comments