-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Adjust tests to the batching updates feature #27230
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
Adjust tests to the batching updates feature #27230
Conversation
…f/onyx-upgrade-react-batching
Co-authored-by: Marc Glasser <marc.aaron.glasser@gmail.com>
Co-authored-by: Marc Glasser <marc.aaron.glasser@gmail.com>
tests/actions/ReportTest.js
Outdated
| beforeEach(() => Onyx.clear().then(waitForPromisesToResolve)); | ||
| beforeEach(() => { | ||
| const promise = Onyx.clear().then(jest.useRealTimers); | ||
| waitForPromisesToResolve(); |
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.
Should that be .then(wairForPromisesToResolve)?
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.
Actually the purpose is to flush timers if we use fake timers.
I change it so it's hopefully more clear now
| * | ||
| * @returns {Promise} | ||
| */ | ||
| export default () => waitForPromisesToResolve().then(waitForPromisesToResolve); |
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.
Should we call this something like waitForOnyxPromise that is onyx specific as fastForwardTwoMicrotasksCycles sounds too implementation specific.
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.
No Idea to be honest. @tgolen WDYT?
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.
I really like the idea of having waitForNetworkPromise and waitForOnyxPromise. Would that work?
tests/unit/APITest.js
Outdated
| // We need to advance past the request throttle back off timer because the request won't be retried until then | ||
| jest.advanceTimersByTime(CONST.NETWORK.MAX_RANDOM_RETRY_WAIT_TIME_MS); | ||
| return waitForPromisesToResolve(); | ||
| return new Promise((resolve) => setTimeout(resolve, 1000)).then(waitForPromisesToResolve); |
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 isn't going to actually take 1s to resolve right?
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.
True! Fixed!
Just started my day @mountiny. I'll confirm @ospfranco's findings. |
|
🧪🧪 Use the links below to test this build in android and iOS. Happy testing! 🧪🧪 |
marcaaron
left a comment
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.
Changes LGTM - I think at this point we are just waiting to confirm whether any fix is needed for a regression.
| @@ -10,7 +10,7 @@ Onyx.connect({ | |||
| }); | |||
|
|
|||
| function 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.
I believe we are trying to avoid using that and prefer to wait for the Onyx method to finish because waitForPromisesToResolve is not compatible with the batched updates solution.
Co-authored-by: Marc Glasser <marc.aaron.glasser@gmail.com>
# Conflicts: # package-lock.json # package.json
|
Seems some of the issues where caused by errors on the main branch. E.g. 2FA setup was caused by a FocusTrap component that crashed with a null ref, it was reverted on main and I've now updated this branch to main. I'm testing again, and will take a look into remaining issues: Emoji - The previously tone appears for a few seconds when fast switching between skin tones Security - 2FA setup seems that it is not completed, finish button does not continue process Workspace - User is redirected to /not-found page after refreshing workspace chat page IOU - When you return to selecting RM amount and continue, the request will be reset IOU - Incorrect animation display when selecting Split bill members Task - Task reverts to previous state briefly when checking or unchecking checkbox Preferences - Priority mode reverts to #focus briefly when changing it to Most recent |
mountiny
left a comment
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.
Thanks for the patience on this one!
|
🚀 Deployed to staging by https://github.com/mountiny in version: 1.3.72-1 🚀
|
|
I suggest to retest all bugs what QA team found in this PR build. |
|
^ @Szymon20000 Are you able to investigate this? |
|
I'm busy in another project but @ospfranco has better context. |
|
Just tested #27230 (comment) and indeed it is not working, but it doesn't look like it is the same problem that we ignored because of the < FocusTrap/> component that got reverted. The screens mount but nothing is thrown or happening. |
|
Found the problem and a potential solution |
|
🚀 Deployed to production by https://github.com/thienlnam in version: 1.3.72-11 🚀
|
|
🚀 Deployed to staging by https://github.com/mountiny in version: 1.3.74-0 🚀
|
|
🚀 Deployed to production by https://github.com/chiragsalian in version: 1.3.74-3 🚀
|
The purpose of this pull-request is to prepare app tests for batching update feature link.
Before that feature all Onyx.set or Onyx.merge were notifying its subscribers about a change right away.
Once we apply batching solution the notifications can be delayed and at the end of the current micro task cycle.
Because of that we had to reimplement waitForPromisesToResolve and sometimes use it twice in a row.
Details
jest.runOnlyPendingTimers()after every onyx update so that setTimeout used by batching logic is executed. In order to reduce the number of places where we have to use it we use real timer by default and fake timers only when time precision is needed to make the test stable.Fixed Issues
$ #27470
PROPOSAL:
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)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
Mobile Web - Chrome
Mobile Web - Safari
Desktop
iOS
Android