-
Notifications
You must be signed in to change notification settings - Fork 3.2k
fix: Error in archived task Set up categories #61393
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
Changes from 2 commits
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 |
---|---|---|
@@ -1,10 +1,11 @@ | ||
import {renderHook} from '@testing-library/react-native'; | ||
import Onyx from 'react-native-onyx'; | ||
import useReportIsArchived from '@hooks/useReportIsArchived'; | ||
import {canModifyTask, completeTestDriveTask} from '@libs/actions/Task'; | ||
import {canModifyTask, completeTestDriveTask, getFinishOnboardingTaskOnyxData} from '@libs/actions/Task'; | ||
// eslint-disable-next-line no-restricted-syntax -- this is required to allow mocking | ||
import * as API from '@libs/API'; | ||
import {WRITE_COMMANDS} from '@libs/API/types'; | ||
import DateUtils from '@libs/DateUtils'; | ||
import Parser from '@libs/Parser'; | ||
// eslint-disable-next-line no-restricted-syntax -- this is required to allow mocking | ||
import * as ReportUtils from '@libs/ReportUtils'; | ||
|
@@ -141,4 +142,33 @@ describe('actions/Task', () => { | |
expect(writeSpy).toHaveBeenCalledWith(WRITE_COMMANDS.COMPLETE_TASK, expect.anything(), expect.anything()); | ||
}); | ||
}); | ||
|
||
describe('getFinishOnboardingTaskOnyxData', () => { | ||
const parentReport: Report = LHNTestUtils.getFakeReport(); | ||
const taskReport: Report = {...LHNTestUtils.getFakeReport(), type: CONST.REPORT.TYPE.TASK, ownerAccountID: 1, managerID: 2, parentReportID: parentReport.reportID}; | ||
const reportCollectionDataSet: ReportCollectionDataSet = { | ||
[`${ONYXKEYS.COLLECTION.REPORT}${taskReport.reportID}`]: taskReport, | ||
[`${ONYXKEYS.COLLECTION.REPORT}${parentReport.reportID}`]: parentReport, | ||
}; | ||
beforeEach(async () => { | ||
await Onyx.clear(); | ||
await Onyx.multiSet({ | ||
...reportCollectionDataSet, | ||
}); | ||
await Onyx.set(ONYXKEYS.SESSION, {email: '[email protected]', accountID: 2}); | ||
await Onyx.set(`${ONYXKEYS.NVP_INTRO_SELECTED}`, {choice: CONST.ONBOARDING_CHOICES.MANAGE_TEAM, setupCategories: taskReport.reportID}); | ||
await waitForBatchedUpdates(); | ||
}); | ||
it('Return not empty object', () => { | ||
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. Hi, just dropping in here, but can you please be more descriptive with the test names or comments? From looking at this test (and the one below), I have no context to understand why an empty or a non-empty object would be expected. 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. @tgolen Should I create a follow-up PR to add a more descriptive explanation for the test? |
||
expect(Object.values(getFinishOnboardingTaskOnyxData('setupCategories')).length).toBeGreaterThan(0); | ||
}); | ||
it('Return empty object', async () => { | ||
const reportNameValuePairs = { | ||
private_isArchived: DateUtils.getDBTime(), | ||
}; | ||
await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${parentReport.reportID}`, reportNameValuePairs); | ||
await waitForBatchedUpdates(); | ||
expect(Object.values(getFinishOnboardingTaskOnyxData('setupCategories')).length).toBe(0); | ||
}); | ||
}); | ||
}); |
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.
This task is failing on local for me, can you take a look 👀 ?
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.
@hungvu193 Could you help run the test again?

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.
Tests passed!