Skip to content

Commit d19263f

Browse files
committed
fix tests
1 parent 0b495ad commit d19263f

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ function MoneyRequestReportPreviewContent({
595595
}, [carouselTransactions.length]);
596596

597597
return (
598-
<View onLayout={onWrapperLayout}>
598+
<View onLayout={onWrapperLayout} testID="MoneyRequestReportPreviewContent-wrapper">
599599
<OfflineWithFeedback
600600
pendingAction={iouReport?.pendingFields?.preview}
601601
shouldDisableOpacity={!!(action.pendingAction ?? action.isOptimisticAction)}

tests/ui/MoneyRequestReportPreview.test.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ const getTransactionDisplayAmountAndHeaderText = (transaction: Transaction) => {
100100
};
101101

102102
const setCurrentWidth = () => {
103+
fireEvent(screen.getByTestId('MoneyRequestReportPreviewContent-wrapper'), 'layout', {
104+
nativeEvent: {layout: {width: 600}},
105+
});
103106
fireEvent(screen.getByTestId('carouselWidthSetter'), 'layout', {
104107
nativeEvent: {layout: {width: 500}},
105108
});
@@ -147,6 +150,7 @@ describe('MoneyRequestReportPreview', () => {
147150
await waitForBatchedUpdatesWithAct();
148151
setCurrentWidth();
149152
await Onyx.mergeCollection(ONYXKEYS.COLLECTION.TRANSACTION, mockOnyxTransactions).then(waitForBatchedUpdates);
153+
await waitForBatchedUpdatesWithAct();
150154
const {reportName: moneyRequestReportPreviewName = ''} = mockChatReport;
151155
for (const transaction of arrayOfTransactions) {
152156
const {transactionDisplayAmount, transactionHeaderText} = getTransactionDisplayAmountAndHeaderText(transaction);
@@ -163,6 +167,7 @@ describe('MoneyRequestReportPreview', () => {
163167
await waitForBatchedUpdatesWithAct();
164168
setCurrentWidth();
165169
await Onyx.multiSet({...mockOnyxTransactions, ...mockOnyxViolations});
170+
await waitForBatchedUpdatesWithAct();
166171
expect(screen.getAllByText(translateLocal('violations.reviewRequired'))).toHaveLength(2);
167172
});
168173

@@ -175,6 +180,6 @@ describe('MoneyRequestReportPreview', () => {
175180
await Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION}${mockSecondTransactionID}`, {} as OnyxMergeInput<`transactions_${string}`>);
176181
await waitForBatchedUpdatesWithAct();
177182

178-
expect(screen.getAllByTestId(TransactionPreviewSkeletonView.displayName)).toHaveLength(2);
183+
expect(screen.getAllByTestId('TransactionPreviewSkeletonView')).toHaveLength(2);
179184
});
180185
});

0 commit comments

Comments
 (0)