This repository has been archived by the owner on Jun 4, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 281
Fix intermittent failures in updateGrid test #172
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,40 +6,46 @@ import { | |
PlotlyAPIRequest, | ||
updateGrid | ||
} from '../../backend/persistent/PlotlyAPI.js'; | ||
import {names, createGrid, username, apiKey} from './utils.js'; | ||
import {wait, names, createGrid, username, apiKey} from './utils.js'; | ||
import {saveSetting} from '../../backend/settings.js'; | ||
|
||
describe('Grid API Functions', function () { | ||
beforeEach(() => { | ||
before(() => { | ||
saveSetting('USERS', [{username, apiKey}]); | ||
saveSetting('PLOTLY_API_DOMAIN', 'api.plot.ly'); | ||
saveSetting('PLOTLY_API_SSL_ENABLED', true); | ||
}); | ||
|
||
xit('updateGrid overwrites a grid with new data', function (done) { | ||
it('updateGrid overwrites a grid with new data', function () { | ||
this.timeout(15 * 1000); | ||
// First, create a new grid. | ||
// Note that the app never actually does this, | ||
// it works off of the assumption that a grid exists | ||
|
||
let fid; | ||
createGrid('Test updateGrid').then(res => res.json().then(json => { | ||
return createGrid('Test updateGrid').then(res => res.json().then(json => { | ||
// Update the grid's data | ||
fid = json.file.fid; | ||
const uids = json.file.cols.map(col => col.uid); | ||
|
||
return updateGrid( | ||
[ | ||
['x', 10, 40, 70, 100, 130], | ||
['y', 20, 50, 80, 110, 140], | ||
['z', 30, 60, 90, 120, 150] | ||
], | ||
fid, | ||
uids, | ||
username | ||
); | ||
return wait(1000).then(() => { | ||
return updateGrid( | ||
[ | ||
['x', 10, 40, 70, 100, 130], | ||
['y', 20, 50, 80, 110, 140], | ||
['z', 30, 60, 90, 120, 150] | ||
], | ||
fid, | ||
uids, | ||
username | ||
); | ||
}); | ||
})).then(() => { | ||
const url = `grids/${fid}/content`; | ||
// 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 commentThe reason will be displayed to describe this comment to others. Learn more. I wonder why this |
||
const url = `grids/${fid}/content`; | ||
return PlotlyAPIRequest(url, {username, apiKey, method: 'GET'}); | ||
}); | ||
}).then(res => res.json().then(json => { | ||
// Test that the update worked | ||
assert.deepEqual( | ||
|
@@ -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 commentThe 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 |
||
})); | ||
|
||
}); | ||
}); |
This file contains 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
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.
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