-
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
fix: Inbox showing GBR when there’s a report with RBR #51643
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
87f6644
fix: Inbox showing GBR when there’s a report with RBR
truph01 850f5ab
merge main
truph01 6d00a65
fix: optimize code
truph01 bba3e08
merge main
truph01 bbbe5aa
fix: refactor code
truph01 462c52f
fix: lint
truph01 c45ade8
merge main
truph01 f20b84f
fix: add test
truph01 a708691
fix: lint
truph01 85d684f
fix: unit test
truph01 0f9e3df
fix: lint
truph01 976c78f
fix: lint
truph01 e156dca
fix: add comment to test and create json file
truph01 e82e777
fix: prettier
truph01 8d0da00
fix: remove unused data in json
truph01 d42e264
fix: add 2nd test case
truph01 ef77bb9
fix: lint
truph01 bd9c7ac
fix: update comment
truph01 16b9d4e
fix: add detailed comments in test
truph01 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
{ | ||
"session": { | ||
"accountID": 18634488 | ||
}, | ||
"reports": { | ||
"report_4286515777714555": { | ||
"type": "chat", | ||
"isOwnPolicyExpenseChat": false, | ||
"ownerAccountID": 0, | ||
"parentReportActionID": "8722650843049927838", | ||
"parentReportID": "6955627196303088", | ||
"policyID": "57D0F454E0BCE54B", | ||
"reportID": "4286515777714555", | ||
"stateNum": 0, | ||
"statusNum": 0 | ||
}, | ||
"report_6955627196303088": { | ||
"reportID": "6955627196303088", | ||
"chatReportID": "1699789757771388", | ||
"policyID": "57D0F454E0BCE54B", | ||
"type": "expense", | ||
"ownerAccountID": 18634488, | ||
"stateNum": 1, | ||
"statusNum": 1, | ||
"parentReportID": "1699789757771388", | ||
"parentReportActionID": "7978085421707288417" | ||
} | ||
}, | ||
"transactionViolations": { | ||
"transactionViolations_3106135972713435169": [ | ||
{ | ||
"name": "missingCategory", | ||
"type": "violation" | ||
} | ||
], | ||
"transactionViolations_3690687111940510713": [ | ||
{ | ||
"name": "missingCategory", | ||
"type": "violation" | ||
} | ||
] | ||
}, | ||
"reportActions": { | ||
"reportActions_6955627196303088": { | ||
"8722650843049927838": { | ||
"actionName": "IOU", | ||
"actorAccountID": 18634488, | ||
"automatic": false, | ||
"avatar": "https: //d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_1.png", | ||
"isAttachmentOnly": false, | ||
"originalMessage": { | ||
"amount": 12300, | ||
"comment": "", | ||
"currency": "VND", | ||
"IOUTransactionID": "3106135972713435169", | ||
"IOUReportID": "6955627196303088" | ||
}, | ||
"message": [ | ||
{ | ||
"deleted": "", | ||
"html": "₫123 expense", | ||
"isDeletedParentAction": false, | ||
"isEdited": false, | ||
"text": "₫123 expense", | ||
"type": "COMMENT", | ||
"whisperedTo": [] | ||
} | ||
], | ||
"person": [ | ||
{ | ||
"style": "strong", | ||
"text": "adasdasd", | ||
"type": "TEXT" | ||
} | ||
], | ||
"reportActionID": "8722650843049927838", | ||
"shouldShow": true, | ||
"created": "2024-11-05 11: 19: 18.706", | ||
"childReportID": "4286515777714555", | ||
"lastModified": "2024-11-05 11: 19: 18.706", | ||
"childReportNotificationPreference": "hidden", | ||
"childType": "chat" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import type {OnyxCollection} from 'react-native-onyx'; | ||
import Onyx from 'react-native-onyx'; | ||
import {getBrickRoadForPolicy} from '@libs/WorkspacesSettingsUtils'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
import type {Report, ReportActions, TransactionViolations} from '@src/types/onyx'; | ||
import type {ReportCollectionDataSet} from '@src/types/onyx/Report'; | ||
import * as TestHelper from '../utils/TestHelper'; | ||
import waitForBatchedUpdates from '../utils/waitForBatchedUpdates'; | ||
import mockData from './WorkspaceSettingsUtilsTest.json'; | ||
|
||
describe('WorkspacesSettingsUtils', () => { | ||
beforeAll(() => { | ||
Onyx.init({ | ||
keys: ONYXKEYS, | ||
}); | ||
}); | ||
|
||
beforeEach(() => { | ||
global.fetch = TestHelper.getGlobalFetchMock(); | ||
return Onyx.clear().then(waitForBatchedUpdates); | ||
}); | ||
describe('getBrickRoadForPolicy', () => { | ||
it('Should return "error"', async () => { | ||
// Given mock data for reports, transaction violations, sessions, and report actions. | ||
const report = Object.values(mockData.reports)?.at(0); | ||
const transactionViolations = mockData.transactionViolations; | ||
const reports = mockData.reports; | ||
const session = mockData.session; | ||
const reportActions = mockData.reportActions; | ||
|
||
await Onyx.multiSet({ | ||
...(reports as ReportCollectionDataSet), | ||
...(reportActions as OnyxCollection<ReportActions>), | ||
...(transactionViolations as OnyxCollection<TransactionViolations>), | ||
truph01 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
session, | ||
}); | ||
|
||
await waitForBatchedUpdates(); | ||
|
||
// When calling getBrickRoadForPolicy with a report and report actions | ||
const result = getBrickRoadForPolicy(report as Report, reportActions as OnyxCollection<ReportActions>); | ||
|
||
// The result should be 'error' because there is at least one IOU action associated with a transaction that has a violation. | ||
expect(result).toBe('error'); | ||
}); | ||
|
||
it('Should return "undefined"', async () => { | ||
// Given mock data for reports, sessions, and report actions. Note: Transaction data is intentionally excluded. | ||
const report = Object.values(mockData.reports)?.at(0); | ||
const reports = mockData.reports; | ||
const session = mockData.session; | ||
const reportActions = mockData.reportActions; | ||
|
||
await Onyx.multiSet({ | ||
...(reports as ReportCollectionDataSet), | ||
...(reportActions as OnyxCollection<ReportActions>), | ||
session, | ||
}); | ||
|
||
await waitForBatchedUpdates(); | ||
|
||
// When calling getBrickRoadForPolicy with a report and report actions | ||
const result = getBrickRoadForPolicy(report as Report, reportActions as OnyxCollection<ReportActions>); | ||
|
||
// Then the result should be 'undefined' since no IOU action is linked to a transaction with a violation. | ||
expect(result).toBe(undefined); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
add line break