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
@@ -79,7 +79,7 @@ describe('Upload component', async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('[C272792] Should be possible to cancel upload of a big file using row cancel icon', async () => {
|
it('[C272792] Should be possible to cancel upload of a big file using row cancel icon', async () => {
|
||||||
await browser.executeScript('setTimeout(() => {document.querySelector("div[data-automation-id=\'cancel-upload-progress\']").click();}, 3000)');
|
await browser.executeScript('setTimeout(() => {document.querySelector("div[data-automation-id=\'cancel-upload-progress\']").click();}, 1000)');
|
||||||
|
|
||||||
await contentServicesPage.uploadFile(largeFile.location);
|
await contentServicesPage.uploadFile(largeFile.location);
|
||||||
|
|
||||||
@@ -90,7 +90,7 @@ describe('Upload component', async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('[C287790] Should be possible to cancel upload of a big file through the cancel uploads button', async () => {
|
it('[C287790] Should be possible to cancel upload of a big file through the cancel uploads button', async () => {
|
||||||
await browser.executeScript(' setInterval(() => {document.querySelector("#adf-upload-dialog-cancel-all").click();' +
|
await browser.executeScript(' setTimeout(() => {document.querySelector("#adf-upload-dialog-cancel-all").click();' +
|
||||||
'document.querySelector("#adf-upload-dialog-cancel").click(); }, 500)');
|
'document.querySelector("#adf-upload-dialog-cancel").click(); }, 500)');
|
||||||
|
|
||||||
await contentServicesPage.uploadFile(largeFile.location);
|
await contentServicesPage.uploadFile(largeFile.location);
|
||||||
@@ -102,7 +102,7 @@ describe('Upload component', async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('[C272793] Should be able to cancel multiple files upload', async () => {
|
it('[C272793] Should be able to cancel multiple files upload', async () => {
|
||||||
await browser.executeScript(' setInterval(() => {document.querySelector("#adf-upload-dialog-cancel-all").click();' +
|
await browser.executeScript(' setTimeout(() => {document.querySelector("#adf-upload-dialog-cancel-all").click();' +
|
||||||
'document.querySelector("#adf-upload-dialog-cancel").click(); }, 500)');
|
'document.querySelector("#adf-upload-dialog-cancel").click(); }, 500)');
|
||||||
|
|
||||||
await uploadToggles.enableMultipleFileUpload();
|
await uploadToggles.enableMultipleFileUpload();
|
||||||
@@ -115,4 +115,13 @@ describe('Upload component', async () => {
|
|||||||
await uploadToggles.disableMultipleFileUpload();
|
await uploadToggles.disableMultipleFileUpload();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('[C315257] Should be able to cancel file in upload queue', async () => {
|
||||||
|
await uploadToggles.enableMultipleFileUpload();
|
||||||
|
await browser.executeScript('setTimeout(() => {document.querySelector("button[data-automation-id=\'cancel-upload-queue\']").click();}, 500)');
|
||||||
|
await contentServicesPage.uploadMultipleFile([largeFile.location, pngFileModel.location]);
|
||||||
|
await uploadDialog.fileIsCancelled(pngFileModel.name);
|
||||||
|
await uploadDialog.clickOnCloseButton();
|
||||||
|
await uploadDialog.dialogIsNotDisplayed();
|
||||||
|
await uploadToggles.disableMultipleFileUpload();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -82,6 +82,7 @@
|
|||||||
mat-icon-button
|
mat-icon-button
|
||||||
*ngIf="file.status === FileUploadStatus.Pending"
|
*ngIf="file.status === FileUploadStatus.Pending"
|
||||||
(click)="onCancel(file)"
|
(click)="onCancel(file)"
|
||||||
|
data-automation-id="cancel-upload-queue"
|
||||||
class="adf-file-uploading-row__group"
|
class="adf-file-uploading-row__group"
|
||||||
title="{{ 'ADF_FILE_UPLOAD.BUTTON.CANCEL_FILE' | translate }}"
|
title="{{ 'ADF_FILE_UPLOAD.BUTTON.CANCEL_FILE' | translate }}"
|
||||||
[attr.aria-label]="'ADF_FILE_UPLOAD.ARIA-LABEL.CANCEL_FILE' | translate: { file: file.name }">
|
[attr.aria-label]="'ADF_FILE_UPLOAD.ARIA-LABEL.CANCEL_FILE' | translate: { file: file.name }">
|
||||||
|
@@ -62,11 +62,25 @@ describe('FileUploadingListComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('cancelFile()', () => {
|
describe('cancelFile()', () => {
|
||||||
it('should call uploadService api when cancelling a file', () => {
|
it('should call cancelUpload service when cancelling a file', () => {
|
||||||
component.cancelFile(file);
|
component.cancelFile(file);
|
||||||
|
|
||||||
expect(uploadService.cancelUpload).toHaveBeenCalledWith(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()', () => {
|
describe('removeFile()', () => {
|
||||||
@@ -106,6 +120,40 @@ describe('FileUploadingListComponent', () => {
|
|||||||
expect(uploadService.cancelUpload).toHaveBeenCalled();
|
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', () => {
|
describe('Events', () => {
|
||||||
|
|
||||||
it('should throw an error event if delete file goes wrong', (done) => {
|
it('should throw an error event if delete file goes wrong', (done) => {
|
||||||
|
@@ -65,8 +65,12 @@ export class FileUploadingListComponent {
|
|||||||
* @memberOf FileUploadingListComponent
|
* @memberOf FileUploadingListComponent
|
||||||
*/
|
*/
|
||||||
cancelFile(file: FileModel): void {
|
cancelFile(file: FileModel): void {
|
||||||
|
if (file.status === FileUploadStatus.Pending) {
|
||||||
|
file.status = FileUploadStatus.Cancelled;
|
||||||
|
} else {
|
||||||
this.uploadService.cancelUpload(file);
|
this.uploadService.cancelUpload(file);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove uploaded file
|
* Remove uploaded file
|
||||||
@@ -161,8 +165,9 @@ export class FileUploadingListComponent {
|
|||||||
this.files
|
this.files
|
||||||
.filter(
|
.filter(
|
||||||
(item) =>
|
(item) =>
|
||||||
item.data.entry.id === file.data.entry.id &&
|
item.options.newVersion &&
|
||||||
item.options.newVersion
|
item.data.entry.id === file.data.entry.id
|
||||||
|
|
||||||
)
|
)
|
||||||
.map((item) => {
|
.map((item) => {
|
||||||
item.status = FileUploadStatus.Deleted;
|
item.status = FileUploadStatus.Deleted;
|
||||||
|
Reference in New Issue
Block a user