Skip to content

Commit

Permalink
fix: update lint for test
Browse files Browse the repository at this point in the history
Signed-off-by: dominictb <[email protected]>
  • Loading branch information
dominictb committed Jun 10, 2024
1 parent fbad958 commit b7f75ef
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 53 deletions.
2 changes: 1 addition & 1 deletion src/pages/home/ReportScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ function ReportScreen({
<View
style={[styles.flex1, styles.justifyContentEnd, styles.overflowHidden]}
onLayout={onListLayout}
testID={'reportActionsViewWrapper'}
testID="report-actions-view-wrapper"
>
{shouldShowReportActionList && (
<ReportActionsView
Expand Down
97 changes: 45 additions & 52 deletions tests/ui/UnreadIndicatorsTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit b7f75ef

Please sign in to comment.