Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

Fix intermittent failures in updateGrid test #172

Merged
merged 2 commits into from
Sep 5, 2017

Conversation

n-riesco
Copy link
Contributor

@n-riesco n-riesco commented Sep 4, 2017

This PR restores the updateGrid test (previously skipped in order to merge #163).

This PR is merged on to top of #171.

* 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);
Copy link
Member

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(() => {
Copy link
Member

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];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nice

@chriddyp
Copy link
Member

chriddyp commented Sep 5, 2017

💃 - looks good! Thanks for digging into this one :)

@chriddyp chriddyp merged commit 1366f8c into plotly:master Sep 5, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants