Skip to content

Commit b7f75ef

Browse files
committed
fix: update lint for test
Signed-off-by: dominictb <tb-dominic@outlook.com>
1 parent fbad958 commit b7f75ef

File tree

2 files changed

+46
-53
lines changed

2 files changed

+46
-53
lines changed

src/pages/home/ReportScreen.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ function ReportScreen({
704704
<View
705705
style={[styles.flex1, styles.justifyContentEnd, styles.overflowHidden]}
706706
onLayout={onListLayout}
707-
testID={'reportActionsViewWrapper'}
707+
testID="report-actions-view-wrapper"
708708
>
709709
{shouldShowReportActionList && (
710710
<ReportActionsView

tests/ui/UnreadIndicatorsTest.tsx

+45-52
Original file line numberDiff line numberDiff line change
@@ -197,15 +197,12 @@ const USER_C_EMAIL = 'user_c@test.com';
197197
let reportAction3CreatedDate: string;
198198
let reportAction9CreatedDate: string;
199199

200-
// store render result, used to trigger onLayout event
201-
let renderResult: ReturnType<typeof render> | null = null;
202-
203200
/**
204201
* Sets up a test with a logged in user that has one unread chat from another user. Returns the <App/> test instance.
205202
*/
206203
function signInAndGetAppWithUnreadChat(): Promise<void> {
207204
// Render the App and sign in as a test user.
208-
renderResult = render(<App />);
205+
render(<App />);
209206
return waitForBatchedUpdatesWithAct()
210207
.then(async () => {
211208
await waitForBatchedUpdatesWithAct();
@@ -465,57 +462,53 @@ describe('Unread Indicators', () => {
465462
expect(screen.getAllByText('C User')[0]).toBeOnTheScreen();
466463
expect(displayNameTexts[1]?.props?.style?.fontWeight).toBe(FontUtils.fontWeight.bold);
467464
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();
468481
})
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(() => {
490506
const unreadIndicator = getUnreadIndicator();
491-
expect(unreadIndicator).toHaveLength(1);
492507
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+
});
519512

520513
xit('Manually marking a chat message as unread shows the new line indicator and updates the LHN', () =>
521514
signInAndGetAppWithUnreadChat()

0 commit comments

Comments
 (0)