-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[HOLD #51296] [Unit & UI Tests]: add unit test for automatically approved expense #51330
base: main
Are you sure you want to change the base?
Changes from 5 commits
02316f3
358b107
7270293
7d7df77
f333ee5
242427d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -294,6 +294,94 @@ describe('ReportUtils', () => { | |
}); | ||
}); | ||
|
||
describe('Automatically approved report message via automatic (not by a human) action is', () => { | ||
test('Automatically Approved Report message when report is forwarded (Control feature)', () => { | ||
Comment on lines
+297
to
+298
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can clean up these names a bit - I believe ideally it reads almost like a sentence, starting with the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cool cool, I'll update in the next commit |
||
const threadOfSubmittedReportAction = { | ||
...LHNTestUtils.getFakeReport(), | ||
type: CONST.REPORT.TYPE.EXPENSE, | ||
stateNum: CONST.REPORT.STATE_NUM.APPROVED, | ||
statusNum: CONST.REPORT.STATUS_NUM.APPROVED, | ||
parentReportID: '101', | ||
policyID: policy.id, | ||
}; | ||
const submittedParentReportAction = { | ||
actionName: CONST.REPORT.ACTIONS.TYPE.FORWARDED, | ||
originalMessage: { | ||
amount: 169, | ||
currency: 'USD', | ||
automaticAction: true, | ||
}, | ||
} as ReportAction; | ||
|
||
expect(ReportUtils.getReportName(threadOfSubmittedReportAction, policy, submittedParentReportAction)).toBe('automatically approved $1.69 via workspace rules'); | ||
}); | ||
|
||
test('Automatically Approved Report message when report is approved', () => { | ||
const threadOfSubmittedReportAction = { | ||
...LHNTestUtils.getFakeReport(), | ||
type: CONST.REPORT.TYPE.EXPENSE, | ||
stateNum: CONST.REPORT.STATE_NUM.APPROVED, | ||
statusNum: CONST.REPORT.STATUS_NUM.APPROVED, | ||
parentReportID: '101', | ||
policyID: policy.id, | ||
}; | ||
const submittedParentReportAction = { | ||
actionName: CONST.REPORT.ACTIONS.TYPE.APPROVED, | ||
originalMessage: { | ||
amount: 169, | ||
currency: 'USD', | ||
automaticAction: true, | ||
}, | ||
} as ReportAction; | ||
|
||
expect(ReportUtils.getReportName(threadOfSubmittedReportAction, policy, submittedParentReportAction)).toBe('automatically approved $1.69 via workspace rules'); | ||
}); | ||
}); | ||
|
||
describe('Automatically approved report message via harvesting (delayed submit) is', () => { | ||
test('Automatically Approved Report message for report type submitted and status is submitted', () => { | ||
const threadOfSubmittedReportAction = { | ||
...LHNTestUtils.getFakeReport(), | ||
type: CONST.REPORT.TYPE.EXPENSE, | ||
stateNum: CONST.REPORT.STATE_NUM.SUBMITTED, | ||
statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED, | ||
parentReportID: '101', | ||
policyID: policy.id, | ||
}; | ||
const submittedParentReportAction = { | ||
actionName: CONST.REPORT.ACTIONS.TYPE.SUBMITTED, | ||
originalMessage: { | ||
amount: 169, | ||
currency: 'USD', | ||
harvesting: true, | ||
}, | ||
} as ReportAction; | ||
|
||
expect(ReportUtils.getReportName(threadOfSubmittedReportAction, policy, submittedParentReportAction)).toBe('automatically submitted $1.69 via delayed submission'); | ||
}); | ||
|
||
test('Automatically Approved Report message for report type submitted and status is closed', () => { | ||
const threadOfSubmittedReportAction = { | ||
...LHNTestUtils.getFakeReport(), | ||
type: CONST.REPORT.TYPE.EXPENSE, | ||
stateNum: CONST.REPORT.STATE_NUM.SUBMITTED, | ||
statusNum: CONST.REPORT.STATUS_NUM.CLOSED, | ||
parentReportID: '101', | ||
policyID: policy.id, | ||
}; | ||
const submittedParentReportAction = { | ||
actionName: CONST.REPORT.ACTIONS.TYPE.SUBMITTED_AND_CLOSED, | ||
originalMessage: { | ||
amount: 169, | ||
currency: 'USD', | ||
harvesting: true, | ||
}, | ||
} as ReportAction; | ||
|
||
expect(ReportUtils.getReportName(threadOfSubmittedReportAction, policy, submittedParentReportAction)).toBe('automatically submitted $1.69 via delayed submission'); | ||
}); | ||
}); | ||
|
||
describe('requiresAttentionFromCurrentUser', () => { | ||
afterEach(async () => { | ||
await Onyx.clear(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Beamanator please ignore this, i have used this temporarily just to not use up all the memory testing all files 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha yeah that's useful, you'll remove before we merge, eh? :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol, for sure !