-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DATAUP-266 staging refresh #1886
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4e58f9d
fix auto-refresh on completed upload
briehl 6c4f0c4
add staging data tab tests
briehl 3a89179
var -> const
briehl f41024d
restore karma.conf to run all frontend tests...
briehl 3f860d0
Merge branch 'truss' into DATAUP-266-staging-refresh
briehl 318407c
move inline styles to class
briehl f0490ff
rename to BEM style
briehl 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
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 |
---|---|---|
@@ -1,7 +1,5 @@ | ||
/*global define*/ | ||
/*global describe, it, expect*/ | ||
/*global jasmine*/ | ||
/*global beforeEach, afterEach*/ | ||
/*global jasmine, describe, it, expect, beforeEach, afterEach, spyOn*/ | ||
/*jslint white: true*/ | ||
define([ | ||
'jquery', | ||
|
@@ -14,12 +12,10 @@ define([ | |
) { | ||
'use strict'; | ||
describe('Test the kbaseNarrativeStagingDataTab widget', () => { | ||
let $dummyNode = $('<div>'), | ||
stagingWidget, | ||
fakeUser = 'notAUser'; | ||
const fakeUser = 'notAUser'; | ||
beforeEach(() => { | ||
jasmine.Ajax.install(); | ||
jasmine.Ajax.stubRequest("https://ci.kbase.us/services/auth/api/V2/me").andReturn({ | ||
jasmine.Ajax.stubRequest(/\/auth\/api\/V2\/me$/).andReturn({ | ||
status: 200, | ||
statusText: 'success', | ||
contentType: 'application/json', | ||
|
@@ -42,14 +38,14 @@ define([ | |
responseHeaders: '', | ||
responseText: JSON.stringify([ | ||
{ | ||
name: "test_folder", | ||
path: fakeUser + "/test_folder", | ||
name: 'test_folder', | ||
path: fakeUser + '/test_folder', | ||
mtime: 1532738637499, | ||
size: 34, | ||
isFolder: true | ||
}, { | ||
name: "file_list.txt", | ||
path: fakeUser + "/test_folder/file_list.txt", | ||
name: 'file_list.txt', | ||
path: fakeUser + '/test_folder/file_list.txt', | ||
mtime: 1532738637555, | ||
size: 49233, | ||
source: 'KBase upload' | ||
|
@@ -60,30 +56,109 @@ define([ | |
userId: fakeUser, | ||
getAuthToken: () => { return 'fakeToken'; } | ||
}; | ||
stagingWidget = new StagingDataTab($dummyNode); | ||
}); | ||
|
||
afterEach(() => { | ||
jasmine.Ajax.uninstall(); | ||
$dummyNode.remove(); | ||
}); | ||
|
||
it('can load properly', (done) => { | ||
stagingWidget.render() | ||
.then(() => { | ||
expect(stagingWidget).not.toBeNull(); | ||
done(); | ||
}); | ||
it('can load properly', async () => { | ||
const $dummyNode = $('<div>'), | ||
stagingWidget = new StagingDataTab($dummyNode); | ||
await stagingWidget.render(); | ||
expect(stagingWidget).not.toBeNull(); | ||
}); | ||
|
||
it('can update its path properly', (done) => { | ||
stagingWidget.render() | ||
.then(() => { | ||
var newPath = 'a_new_path'; | ||
stagingWidget.updatePath(newPath); | ||
expect(stagingWidget.path).toEqual(newPath); | ||
done(); | ||
}); | ||
it('properly catches failed user profile lookups by returning a default unlinked profile', async () => { | ||
jasmine.Ajax.stubRequest(/\/auth\/api\/V2\/me$/).andReturn({ | ||
status: 500, | ||
statusText: 'error', | ||
contentType: 'text/html', | ||
responseHeaders: '', | ||
responseText: 'error! no profile for you!' | ||
}); | ||
const $dummyNode = $('<div>'), | ||
stagingWidget = new StagingDataTab($dummyNode); | ||
const userInfo = await stagingWidget.getUserInfo(); | ||
expect(userInfo).toEqual({user: fakeUser, globusLinked: false}); | ||
}); | ||
|
||
it('gets user info and parsed into whether or not the user is linked to globus', async () => { | ||
const $dummyNode = $('<div>'), | ||
stagingWidget = new StagingDataTab($dummyNode); | ||
const userInfo = await stagingWidget.getUserInfo(); | ||
expect(userInfo).toEqual({user: fakeUser, globusLinked: true}); | ||
}); | ||
Comment on lines
+86
to
+91
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. extra tests! 🎉 |
||
|
||
it('can update its path properly', async () => { | ||
const $dummyNode = $('<div>'), | ||
stagingWidget = new StagingDataTab($dummyNode); | ||
await stagingWidget.render(); | ||
const newPath = 'a_new_path'; | ||
stagingWidget.updatePath(newPath); | ||
expect(stagingWidget.path).toEqual(newPath); | ||
}); | ||
|
||
it('can activate its staging area viewer', async () => { | ||
const $dummyNode = $('<div>'), | ||
stagingWidget = new StagingDataTab($dummyNode); | ||
await stagingWidget.render(); | ||
spyOn(stagingWidget.stagingAreaViewer, 'activate'); | ||
stagingWidget.activate(); | ||
expect(stagingWidget.stagingAreaViewer.activate).toHaveBeenCalled(); | ||
}); | ||
|
||
it('can deactivate its staging area viewer', async () => { | ||
const $dummyNode = $('<div>'), | ||
stagingWidget = new StagingDataTab($dummyNode); | ||
await stagingWidget.render(); | ||
spyOn(stagingWidget.stagingAreaViewer, 'deactivate'); | ||
stagingWidget.activate(); | ||
stagingWidget.deactivate(); | ||
expect(stagingWidget.stagingAreaViewer.deactivate).toHaveBeenCalled(); | ||
}); | ||
|
||
it('can be told to update its view', async () => { | ||
jasmine.clock().install(); | ||
|
||
const $dummyNode = $('<div>'), | ||
stagingWidget = new StagingDataTab($dummyNode); | ||
await stagingWidget.render(); | ||
// kinda cheating - but to test that things are run, we know that this will call | ||
// stagingAreaViewer.render | ||
spyOn(stagingWidget.stagingAreaViewer, 'render'); | ||
stagingWidget.updateView(); | ||
jasmine.clock().tick(stagingWidget.minRefreshTime + 100); | ||
expect(stagingWidget.stagingAreaViewer.render).toHaveBeenCalled(); | ||
|
||
jasmine.clock().uninstall(); | ||
}); | ||
|
||
it('can be triggered to update its view after a completed upload', async () => { | ||
const $dummyNode = $('<div>'), | ||
stagingWidget = new StagingDataTab($dummyNode); | ||
await stagingWidget.render(); | ||
spyOn(stagingWidget, 'updateView'); | ||
// a little more cheating with implementation, this triggers the "upload complete" event | ||
stagingWidget.uploadWidget.dropzone.emit('complete', {name: 'foo', size: 12345}); | ||
expect(stagingWidget.updateView).toHaveBeenCalled(); | ||
}); | ||
|
||
it('only updates its view once per interval on completed uploads', async () => { | ||
jasmine.clock().install(); | ||
|
||
const $dummyNode = $('<div>'), | ||
stagingWidget = new StagingDataTab($dummyNode); | ||
await stagingWidget.render(); | ||
// run a bunch of triggers, should only call render on the staging area once | ||
spyOn(stagingWidget.stagingAreaViewer, 'render'); | ||
for (let i = 0; i < 100; i++) { | ||
stagingWidget.uploadWidget.dropzone.emit('complete', {name: 'foo', size: 12345}); | ||
} | ||
jasmine.clock().tick(stagingWidget.minRefreshTime + 100); | ||
expect(stagingWidget.stagingAreaViewer.render.calls.count()).toEqual(1); | ||
|
||
jasmine.clock().uninstall(); | ||
}); | ||
}); | ||
}); |
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.
👍