mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ADF-4838] Upload Dialog - canceling a pending file cancels the file in progress (#5063)
* add automation id * call cancel upload api only if file is not pending * tests * e2e
This commit is contained in:
committed by
Eugenio Romano
parent
4de00fd6ca
commit
5b9f37d01f
@@ -62,11 +62,25 @@ describe('FileUploadingListComponent', () => {
|
||||
});
|
||||
|
||||
describe('cancelFile()', () => {
|
||||
it('should call uploadService api when cancelling a file', () => {
|
||||
it('should call cancelUpload service when cancelling a file', () => {
|
||||
component.cancelFile(file);
|
||||
|
||||
expect(uploadService.cancelUpload).toHaveBeenCalledWith(file);
|
||||
});
|
||||
|
||||
it('should not call cancelUpload service when file has `Pending` status', () => {
|
||||
file.status = FileUploadStatus.Pending;
|
||||
component.cancelFile(file);
|
||||
|
||||
expect(uploadService.cancelUpload).not.toHaveBeenCalledWith(file);
|
||||
});
|
||||
|
||||
it('should set `Cancelled` status on `Pending` file', () => {
|
||||
file.status = FileUploadStatus.Pending;
|
||||
component.cancelFile(file);
|
||||
|
||||
expect(file.status).toBe(FileUploadStatus.Cancelled);
|
||||
});
|
||||
});
|
||||
|
||||
describe('removeFile()', () => {
|
||||
@@ -106,6 +120,40 @@ describe('FileUploadingListComponent', () => {
|
||||
expect(uploadService.cancelUpload).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should set `Deleted` status on file version instances when original is removed', () => {
|
||||
component.files = <any> [
|
||||
{
|
||||
data: {
|
||||
entry: { id: 'nodeId' }
|
||||
},
|
||||
name: 'file',
|
||||
status: FileUploadStatus.Complete,
|
||||
options: {
|
||||
newVersion: false
|
||||
}
|
||||
},
|
||||
{
|
||||
data: {
|
||||
entry: { id: 'nodeId' }
|
||||
},
|
||||
name: 'file_v1',
|
||||
status: FileUploadStatus.Complete,
|
||||
options: {
|
||||
newVersion: true
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
spyOn(nodesApiService, 'deleteNode').and.returnValue(of(component.files[0]));
|
||||
|
||||
component.removeFile(component.files[0]);
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(nodesApiService.deleteNode).toHaveBeenCalledTimes(1);
|
||||
expect(component.files[0].status).toBe(FileUploadStatus.Deleted);
|
||||
expect(component.files[1].status).toBe(FileUploadStatus.Deleted);
|
||||
});
|
||||
|
||||
describe('Events', () => {
|
||||
|
||||
it('should throw an error event if delete file goes wrong', (done) => {
|
||||
|
Reference in New Issue
Block a user