Skip to content

Commit

Permalink
File upload failure (jupyterlab#5152)
Browse files Browse the repository at this point in the history
* uploadChanged signal registered upon file failure

* Package integrity updates

* reset to master

* Added test to check file upload progress as failure occurs and is rendered
  • Loading branch information
richagadgil authored and blink1073 committed Aug 18, 2018
1 parent 71ff85b commit b9fbad8
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/filebrowser/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,12 @@ export class FileBrowserModel implements IDisposable {
return file.name === uploadIndex.path;
});

this._uploadChanged.emit({
name: 'failure',
newValue: upload,
oldValue: null
});

throw err;
}

Expand Down
44 changes: 44 additions & 0 deletions tests/test-filebrowser/src/model.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,50 @@ describe('filebrowser/model', () => {
expect(toArray(model.uploads())).to.deep.equal([]);
});

it(`should produce progress as a large file fails`, async () => {
const fname = UUID.uuid4() + '.ipynb';
const file = new File([new ArrayBuffer(2 * CHUNK_SIZE)], fname);

const [start, first, second] = signalToPromises(
model.uploadChanged,
3
);

model.upload(file);
// expect(toArray(model.uploads())).to.deep.equal([]);
expect(await start).to.deep.equal([
model,
{
name: 'start',
oldValue: null,
newValue: { path: fname, progress: 0 }
}
]);
expect(toArray(model.uploads())).to.deep.equal([
{ path: fname, progress: 0 }
]);
expect(await first).to.deep.equal([
model,
{
name: 'update',
oldValue: { path: fname, progress: 0 },
newValue: { path: fname, progress: 0 }
}
]);
expect(toArray(model.uploads())).to.deep.equal([
{ path: fname, progress: 0 }
]);
expect(await second).to.deep.equal([
model,
{
name: 'failure',
oldValue: null,
newValue: { path: fname, progress: 0 }
}
]);
expect(toArray(model.uploads())).to.deep.equal([]);
});

after(() => {
PageConfig.setOption('notebookVersion', prevNotebookVersion);
});
Expand Down

0 comments on commit b9fbad8

Please sign in to comment.