Add ability to await the discovery refresh promise#2453
Merged
robertbrignull merged 7 commits intomainfrom May 31, 2023
Merged
Conversation
shati-patel
reviewed
May 30, 2023
Contributor
shati-patel
left a comment
There was a problem hiding this comment.
Thanks! I've read through the commits and I think I understand the idea 😅 As far as I could tell (from local testing), the behaviour is still the same too 🎉
I'm not super confident on the actual code changes, so I wouldn't mind a second look from a more confident TypeScript-y person 👀 ❤️
koesie10
reviewed
May 30, 2023
7cb9831 to
a0e6317
Compare
Contributor
Author
|
I think all comments are addressed now, and the tests are passing again. Should be ready for a quick re-review. |
koesie10
approved these changes
May 31, 2023
Member
koesie10
left a comment
There was a problem hiding this comment.
LGTM, thanks for implementing the suggestions
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The intent of this PR is to give you access to a promise for the
Discoveryclass refresh. This allows us to make the tests more type safe and less prone to flakiness.One part of this PR is making
refreshitself return a promise. This means in the tests we can doawait discovery.refresh()instead of having to doawait (discovery as any).discover()and calling the privatediscovermethod. This means we're no longer circumventing the public interface of theDiscoverclass.Another part of this PR is adding a
getCurrentRefreshPromisemethod which means even if we weren't the ones to kick off the refresh directly we can still safely wait for it to be finished. This is useful when we are testing listeners to events that trigger a refresh, such as the listener for files changing on disk. We can now doawait discovery.getCurrentRefreshPromise()instead of having to doawait sleep(100)and hope for the best.The commits are split up into separate changes, if you prefer to review commit-by-commit.
Checklist
ready-for-doc-reviewlabel there.