refactor: isolate enablePolicyTags from Onyx.connect data#72437
Conversation
91468d0 to
7f5acd2
Compare
Codecov Report❌ Patch coverage is
... and 72 files with indirect coverage changes 🚀 New features to boost your workflow:
|
| // And after API success, pending fields should be cleared | ||
| const successPolicy = await OnyxUtils.get(`${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`); | ||
| expect(successPolicy?.pendingFields?.areTagsEnabled).toBeFalsy(); |
There was a problem hiding this comment.
Personally, I would also add checking the data from the optimistic update also after success, because we have no guarantee that someone will not accidentally overwrite something in the success state.
| // And after API success, pending fields should be cleared | |
| const successPolicy = await OnyxUtils.get(`${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`); | |
| expect(successPolicy?.pendingFields?.areTagsEnabled).toBeFalsy(); | |
| // And after API success, pending fields should be cleared | |
| const successPolicy = await OnyxUtils.get(`${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`); | |
| expect(successPolicy?.pendingFields?.areTagsEnabled).toBeFalsy(); | |
| // And a default tag list should be created | |
| const optimisticPolicyTags = await OnyxUtils.get(`${ONYXKEYS.COLLECTION.POLICY_TAGS}${fakePolicy.id}`); | |
| expect(optimisticPolicyTags?.Tag?.name).toBe('Tag'); | |
| expect(optimisticPolicyTags?.Tag?.orderWeight).toBe(0); | |
| expect(optimisticPolicyTags?.Tag?.required).toBe(false); | |
| expect(optimisticPolicyTags?.Tag?.tags).toEqual({}); |
There was a problem hiding this comment.
I'm not sure if it's worth adding here. I don't see any other test with such a check
…nnect/enablePolicyTags-src-libs-actions-Policy-Tag.ts
|
@shubham1206agra Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Reviewer Checklist
Screenshots/VideosScreen.Recording.2025-10-20.at.12.01.04.AM.mov |
|
🚀 Deployed to staging by https://github.com/tgolen in version: 9.2.35-0 🚀
|
|
🚀 Deployed to production by https://github.com/blimpich in version: 9.2.35-4 🚀
|
Explanation of Change
This PR is part of a refactor to remove Onyx.connect from the
src/libs/actions/Policy/Tag.tsfile and replace it with useOnyx.It isolates the
enablePolicyTagsfunction from the Onyx.connect data.To ensure this refactor doesn't break anything, it adds automated tests to the
enablePolicyTagsfunction.Fixed Issues
$ #69022
PROPOSAL:
Tests
TagsfeatureTagsfeatureOffline tests
Same as Tests
QA Steps
Same as Tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
web.mov