Only draw chart on crates page once Google Charts has been loaded. #1740
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 acceptance tests are failing for me when running them locally. Some tests error out with an error like this
while other tests time out (with a ridiculously long timeout of like three minutes per test). I get similar errors in the JavaScript console when loading the live version of crates.io in Chrome 74, though the page renders just fine.
Looking at the code, the errors are expected. The
didRender()
hook is triggered by the initial rendering of the corresponding element, regardless of whether the Google Charts library has already been completely loaded. I seem to be on a slower internet connection than most other people running these tests, so for me the Google Charts library is usually not loaded at that point. However, the current code goes ahead with calls to the library even if it isn't loaded. This trivial fix simply exits early if the lib isn't loaded yet, because in that case there is no point in doing any further work. This fixed the acceptance tests for me, and also gets rid of the logged error in the Chrome JS console when loading the page.