-
-
Notifications
You must be signed in to change notification settings - Fork 281
Fix intermittent failures in updateGrid test #172
Conversation
* Moved the code that can throw into a promise so that it can be handled. Fixes plotly#170
* Ensure API requests go to `https://api.plot.ly/`. Fixes failures caused by sending requests to `http://plotly.acme.com/`. * Introduce a 1 second pause between API requests. Fixes intermittent failures.
@@ -66,8 +72,7 @@ describe('Grid API Functions', function () { | |||
json.cols[names[5]].data, | |||
[130, 140, 150] | |||
); | |||
done(); | |||
})).catch(done); |
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.
Nice catch! Tthis pattern is everywhere in the tests, I'm not sure how I missed the fact that you can just return a promise. We're on an old-ish version of mocha
(^2.4.5) but it seems like this was supported since 1.18.0 (https://github.com/mochajs/mocha/blob/master/CHANGELOG.md#1180--2014-03-13, mochajs/mocha#329)
// Retrieve the contents from the grid | ||
return PlotlyAPIRequest(url, {username, apiKey, method: 'GET'}); | ||
return wait(1000).then(() => { |
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 wonder why this wait
is needed (is it a plotly API issue?), but I'm OK with this 👍
} | ||
).then((res) => { | ||
return new Promise(function(resolve) { | ||
const {username, accessToken} = getSetting('USERS')[0]; |
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.
very nice
💃 - looks good! Thanks for digging into this one :) |
This PR restores the updateGrid test (previously skipped in order to merge #163).
This PR is merged on to top of #171.