Skip to content

Commit

Permalink
complete RBR report ui test
Browse files Browse the repository at this point in the history
  • Loading branch information
mkzie2 committed Dec 2, 2024
1 parent ffc90fd commit 25bee06
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions tests/ui/LHNItemsPresence.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,33 +196,31 @@ describe('SidebarLinksData', () => {
LHNTestUtils.getDefaultRenderedSidebarLinks();

// And the report is initialized in Onyx.
const report: Report = {
...createReport(true, undefined, undefined, CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT, TEST_POLICY_ID),
const expenseReport: Report = {
...createReport(false, undefined, undefined, undefined, TEST_POLICY_ID),
ownerAccountID: TEST_USER_ACCOUNT_ID,
type: CONST.REPORT.TYPE.EXPENSE,
};

await initializeState({
[`${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`]: report,
[`${ONYXKEYS.COLLECTION.REPORT}${expenseReport.reportID}`]: expenseReport,
});

// The report should appear in the sidebar because it’s pinned.
expect(getOptionRows()).toHaveLength(1);
// The report should not appear in the sidebar because it's hidden
expect(getOptionRows()).toHaveLength(0);
await waitForBatchedUpdatesWithAct();

const expenseReport: Report = {
...createReport(true, undefined, undefined, undefined, TEST_POLICY_ID),
ownerAccountID: TEST_USER_ACCOUNT_ID,
type: CONST.REPORT.TYPE.EXPENSE,
};

const transaction = LHNTestUtils.getFakeTransaction(expenseReport.reportID);
const transactionViolation = createFakeTransactionViolation();

await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${expenseReport.reportID}`, expenseReport);
// When the report has outstanding violations
await Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`, transaction);
await Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transaction.transactionID}`, [transactionViolation]);

// And the draft icon should be shown, indicating there is unsent content.
// The report should appear in the sidebar because it has violations
expect(getOptionRows()).toHaveLength(0);

// And the RBR icon should be shown
expect(screen.getByTestId('RBR Icon')).toBeOnTheScreen();
});
});
Expand Down

0 comments on commit 25bee06

Please sign in to comment.