-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: dominictb <[email protected]>
- Loading branch information
Showing
2 changed files
with
46 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -197,15 +197,12 @@ const USER_C_EMAIL = '[email protected]'; | |
let reportAction3CreatedDate: string; | ||
let reportAction9CreatedDate: string; | ||
|
||
// store render result, used to trigger onLayout event | ||
let renderResult: ReturnType<typeof render> | null = null; | ||
|
||
/** | ||
* Sets up a test with a logged in user that has one unread chat from another user. Returns the <App/> test instance. | ||
*/ | ||
function signInAndGetAppWithUnreadChat(): Promise<void> { | ||
// Render the App and sign in as a test user. | ||
renderResult = render(<App />); | ||
render(<App />); | ||
return waitForBatchedUpdatesWithAct() | ||
.then(async () => { | ||
await waitForBatchedUpdatesWithAct(); | ||
|
@@ -465,57 +462,53 @@ describe('Unread Indicators', () => { | |
expect(screen.getAllByText('C User')[0]).toBeOnTheScreen(); | ||
expect(displayNameTexts[1]?.props?.style?.fontWeight).toBe(FontUtils.fontWeight.bold); | ||
expect(screen.getByText('B User')).toBeOnTheScreen(); | ||
})); | ||
it('Delete a chat message and verify the unread indicator is moved', async () => { | ||
const getUnreadIndicator = () => { | ||
const newMessageLineIndicatorHintText = Localize.translateLocal('accessibilityHints.newMessageLineIndicator'); | ||
return screen.queryAllByLabelText(newMessageLineIndicatorHintText); | ||
}; | ||
|
||
return signInAndGetAppWithUnreadChat() | ||
.then(() => navigateToSidebarOption(0)) | ||
.then(async () => act(() => transitionEndCB?.())) | ||
.then(async () => { | ||
const reportActionsViewWrapper = await screen.findByTestId('report-actions-view-wrapper'); | ||
if (reportActionsViewWrapper) { | ||
fireEvent(reportActionsViewWrapper, 'onLayout', {nativeEvent: {layout: {x: 0, y: 0, width: 100, height: 100}}}); | ||
} | ||
return waitForBatchedUpdates(); | ||
}) | ||
); | ||
it('Delete a chat message and verify the unread indicator is moved', async () => { | ||
const getUnreadIndicator = () => { | ||
const newMessageLineIndicatorHintText = Localize.translateLocal('accessibilityHints.newMessageLineIndicator'); | ||
return screen.queryAllByLabelText(newMessageLineIndicatorHintText); | ||
} | ||
|
||
return signInAndGetAppWithUnreadChat() | ||
.then(() => navigateToSidebarOption(0)) | ||
.then(async () => await act(() => transitionEndCB?.())) | ||
.then(async () => { | ||
const reportActionsViewWrapper = await renderResult?.findByTestId('reportActionsViewWrapper'); | ||
if(reportActionsViewWrapper) { | ||
act(() => { | ||
fireEvent(reportActionsViewWrapper, 'onLayout', { nativeEvent: { layout: { x: 0, y: 0, width: 100, height: 100 } } }); | ||
}) | ||
} | ||
return waitForBatchedUpdates(); | ||
}) | ||
.then(() => { | ||
// Verify the new line indicator is present, and it's before the action with ID 4 | ||
.then(() => { | ||
// Verify the new line indicator is present, and it's before the action with ID 4 | ||
const unreadIndicator = getUnreadIndicator(); | ||
expect(unreadIndicator).toHaveLength(1); | ||
const reportActionID = unreadIndicator[0]?.props?.['data-action-id']; | ||
expect(reportActionID).toBe('4'); | ||
|
||
// simulate delete comment event from Pusher | ||
PusherHelper.emitOnyxUpdate([ | ||
{ | ||
onyxMethod: Onyx.METHOD.MERGE, | ||
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${REPORT_ID}`, | ||
value: { | ||
'4': { | ||
message: [], | ||
}, | ||
}, | ||
}, | ||
]); | ||
return waitForBatchedUpdates(); | ||
}) | ||
.then(() => | ||
// Verify the new line indicator is now before the action with ID 5 | ||
waitFor(() => { | ||
const unreadIndicator = getUnreadIndicator(); | ||
expect(unreadIndicator).toHaveLength(1); | ||
const reportActionID = unreadIndicator[0]?.props?.['data-action-id']; | ||
expect(reportActionID).toBe('4'); | ||
|
||
// simulate delete comment event from Pusher | ||
PusherHelper.emitOnyxUpdate([ | ||
{ | ||
onyxMethod: Onyx.METHOD.MERGE, | ||
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${REPORT_ID}`, | ||
value: { | ||
'4': { | ||
message: [] | ||
} | ||
} | ||
}, | ||
]); | ||
return waitForBatchedUpdates(); | ||
}) | ||
.then(() => { | ||
// Verify the new line indicator is now before the action with ID 5 | ||
return waitFor(() => { | ||
const unreadIndicator = getUnreadIndicator(); | ||
expect(unreadIndicator).toHaveLength(1); | ||
const reportActionID = unreadIndicator[0]?.props?.['data-action-id']; | ||
expect(reportActionID).toBe('5'); | ||
}) | ||
}) | ||
}) | ||
expect(reportActionID).toBe('5'); | ||
}), | ||
); | ||
}); | ||
|
||
xit('Manually marking a chat message as unread shows the new line indicator and updates the LHN', () => | ||
signInAndGetAppWithUnreadChat() | ||
|