diff --git a/src/libs/NextStepUtils.ts b/src/libs/NextStepUtils.ts index 4016e2418a50..48181db8b168 100644 --- a/src/libs/NextStepUtils.ts +++ b/src/libs/NextStepUtils.ts @@ -37,7 +37,6 @@ Onyx.connect({ function parseMessage(messages: Message[] | undefined) { let nextStepHTML = ''; - messages?.forEach((part, index) => { const isEmail = Str.isValidEmail(part.text); let tagType = part.type ?? 'span'; @@ -94,6 +93,7 @@ function buildNextStep(report: OnyxEntry, predictedNextStatus: ValueOf, predictedNextStatus: ValueOf { test('self review', () => { optimisticNextStep.icon = CONST.NEXT_STEP.ICONS.HOURGLASS; + // Waiting for an admin to set up a bank account + optimisticNextStep.message = [ + { + text: 'Waiting for ', + }, + { + text: `an admin`, + }, + { + text: ' to ', + }, + { + text: 'finish setting up', + }, + { + text: ' a business bank account.', + }, + ]; + + const result = NextStepUtils.buildNextStep(report, CONST.REPORT.STATUS_NUM.APPROVED); + + expect(result).toMatchObject(optimisticNextStep); + }); + + test('self review with bank account setup', () => { + optimisticNextStep.icon = CONST.NEXT_STEP.ICONS.HOURGLASS; + // Waiting for an admin to pay expense(s) optimisticNextStep.message = [ { @@ -421,9 +448,20 @@ describe('libs/NextStepUtils', () => { }, ]; - const result = NextStepUtils.buildNextStep(report, CONST.REPORT.STATUS_NUM.APPROVED); + return Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, { + achAccount: { + accountNumber: '123456789', + }, + }).then(() => { + const result = NextStepUtils.buildNextStep(report, CONST.REPORT.STATUS_NUM.APPROVED); - expect(result).toMatchObject(optimisticNextStep); + expect(result).toMatchObject(optimisticNextStep); + + // restore to previous state + Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, { + achAccount: null, + }); + }); }); test('another reviewer', () => { @@ -536,7 +574,7 @@ describe('libs/NextStepUtils', () => { test('payer', () => { optimisticNextStep.icon = CONST.NEXT_STEP.ICONS.HOURGLASS; - // Waiting for an admin to pay expense(s). + // Waiting for an admin to set up a bank account optimisticNextStep.message = [ { text: 'Waiting for ', @@ -548,10 +586,10 @@ describe('libs/NextStepUtils', () => { text: ' to ', }, { - text: 'pay', + text: 'finish setting up', }, { - text: ' %expenses.', + text: ' a business bank account.', }, ]; // mock the report as approved @@ -567,20 +605,53 @@ describe('libs/NextStepUtils', () => { report.stateNum = originalState.stateNum; report.statusNum = originalState.statusNum; }); - }); - describe('it generates an optimistic nextStep once a report has been paid', () => { - test('paid with wallet / outside of Expensify', () => { - optimisticNextStep.icon = CONST.NEXT_STEP.ICONS.CHECKMARK; + test('payer with bank account setup', () => { + optimisticNextStep.icon = CONST.NEXT_STEP.ICONS.HOURGLASS; + + // Waiting for an admin to pay expense(s) optimisticNextStep.message = [ { - text: 'No further action required!', + text: 'Waiting for ', + }, + { + text: 'an admin', + }, + { + text: ' to ', + }, + { + text: 'pay', + }, + { + text: ' %expenses.', }, ]; - const result = NextStepUtils.buildNextStep(report, CONST.REPORT.STATUS_NUM.REIMBURSED); + return Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, { + achAccount: { + accountNumber: '123456789', + }, + }).then(() => { + const result = NextStepUtils.buildNextStep(report, CONST.REPORT.STATUS_NUM.APPROVED); - expect(result).toMatchObject(optimisticNextStep); + expect(result).toMatchObject(optimisticNextStep); + }); + }); + + describe('it generates an optimistic nextStep once a report has been paid', () => { + test('paid with wallet / outside of Expensify', () => { + optimisticNextStep.icon = CONST.NEXT_STEP.ICONS.CHECKMARK; + optimisticNextStep.message = [ + { + text: 'No further action required!', + }, + ]; + + const result = NextStepUtils.buildNextStep(report, CONST.REPORT.STATUS_NUM.REIMBURSED); + + expect(result).toMatchObject(optimisticNextStep); + }); }); }); });