mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACA-3447] Cancel upload of new version removes existing version (#5815)
* instead of deleting the whole node when we upload and then cancel a new version, we delete the version in case * reverting wrong auto indent * fix case name of the unit test * fix auto indent * fix auto indent
This commit is contained in:
@@ -216,6 +216,50 @@ describe('UploadService', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should delete node\'s version when cancelling the upload of the new file version', (done) => {
|
||||
const emitter = new EventEmitter();
|
||||
|
||||
const emitterDisposable = emitter.subscribe((event) => {
|
||||
expect(event.value).toEqual('File deleted');
|
||||
emitterDisposable.unsubscribe();
|
||||
|
||||
const deleteRequest = jasmine.Ajax.requests.mostRecent();
|
||||
expect(deleteRequest.url).toBe('http://localhost:9876/ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/myNodeId/versions/1.1');
|
||||
expect(deleteRequest.method).toBe('DELETE');
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
'status': 200,
|
||||
contentType: 'text/plain',
|
||||
responseText: 'File deleted'
|
||||
});
|
||||
done();
|
||||
});
|
||||
|
||||
const fileFake = new FileModel(<File> {name: 'fake-name', size: 10}, null, 'fakeId');
|
||||
service.addToQueue(fileFake);
|
||||
service.uploadFilesInTheQueue(emitter);
|
||||
|
||||
const file = service.getQueue();
|
||||
service.cancelUpload(...file);
|
||||
|
||||
const request = jasmine.Ajax.requests.mostRecent();
|
||||
expect(request.url).toBe('http://localhost:9876/ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/fakeId/content?include=allowableOperations');
|
||||
expect(request.method).toBe('PUT');
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
'status': 200,
|
||||
contentType: 'json',
|
||||
responseText: {
|
||||
entry: {
|
||||
id: 'myNodeId',
|
||||
properties: {
|
||||
'cm:versionLabel': '1.1'
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('If newVersion is set, name should be a param', () => {
|
||||
const uploadFileSpy = spyOn(alfrescoApiService.getInstance().upload, 'uploadFile').and.callThrough();
|
||||
|
||||
|
Reference in New Issue
Block a user