-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
feat(cdk/testing): add method to wait for async tasks outside angular to complete #17408
feat(cdk/testing): add method to wait for async tasks outside angular to complete #17408
Conversation
4d959b0
to
22f5294
Compare
b53d8d3
to
ee7c989
Compare
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 looks good to me, just a naming suggestion. We should see what others think for the name too
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.
LGTM aside from the naming discussion
df5c2dc
to
d5409f3
Compare
@devversion Inside google3 it appears that the actual typings from the angular/angular repo ( @jelbourn If not, how do you think we should handle this? just copybara out the import of the |
@mmalerba I had logic to access the zone.js types, but it actually caused the whole |
Omitting those type from the sync seems pretty trivial @devversion for the naming, I think that |
@jelbourn We said in the meeting that the case that someone uses I'm not in particular saying we should mention zone in the name, nor do I say that my initial proposal is the best. I totally see why you want it to be named |
@devversion I think one thing that kind of mitigates your concern is the fact that waiting for the |
@mmalerba But not necessarily. In more advanced harnesses where the provided default platform-agnostic As said, I see your reasoning. It will be helpful for most cases, but I personally prefer method names to not be based on their effect when called in specific scenarios, but rather based on what is done regardless of the callee context. Not trying to argue on the name, just trying to explain my standpoint. |
I don't think people should ever be accessing the platform directly in harness code. The harnesses are meant to be platform-independent. I'm sure you're right that someone will try to do that, but its not really a use case I think we need to be concerned about supporting |
Fair point. My thinking was that harnesses can be also built just for one platform though (i.e. with the goal of just making breaking changes less painful in tests / or just making test authoring easier). |
export type ZoneDelegate = Object; | ||
export type HasTaskState = {microTask: boolean, macroTask: boolean}; | ||
|
||
export interface ProxyZoneStatic { |
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.
@devversion It looks like ProxyZoneStatic
and ProxyZone
are not part of the real zone.js d.ts
file. Can you move these to a separate file (either task-state-zone-interceptor.ts
or some new file like proxy-zone-types.d.ts
). I need to be able to easily strip away just the ones that are part of the real zone.js d.ts
file for google3.
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.
Makes sense. I've split the ProxyZone types into a separate file.
… to complete Adds a new method to the `ComponentHarness` base class that can be used to wait for async tasks to complete. This is useful for harness authors as sometimes the component schedules tasks outside of the Angular zone which therefore won't be captured by `whenStable`. These tasks can be relevant for the harness logic though, so there should be an option for harness authors to await _all_ async tasks (not only the ones captured in the ng zone). e.g. the slider re-adjusts when the directionality changes. This re-rendering happens in the next tick. To make sure that `setValue` works when the directionality changed, we need to wait for the async tasks to complete, so that the slider completed re-rendering and the value can be changed through a mouse click.
d5409f3
to
48daa8f
Compare
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Adds a new method to the
ComponentHarness
base class that can beused to wait for async tasks to complete. This is useful for harness
authors as sometimes the component schedules tasks outside of the
Angular zone which therefore won't be captured by
whenStable
.These tasks can be relevant for the harness logic though, so there
should be an option for harness authors to await all async tasks
(not only the ones captured in the ng zone).
e.g. the slider re-adjusts when the directionality changes. This
re-rendering happens in the next tick. To make sure that
setValue
works when the directionality changed, we need to wait for the async
tasks to complete, so that the slider completed re-rendering and the
value can be changed through a mouse click.