mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
@@ -121,7 +121,7 @@ describe('Test ng2-alfresco-upload UploadButton', () => {
|
||||
expect(compiled.querySelector('#uploadFolder')).toBeDefined();
|
||||
});
|
||||
|
||||
it('should call uploadFile with the default folder', () => {
|
||||
it('should call uploadFile with the default root folder', () => {
|
||||
component.currentFolderPath = '/root-fake-/sites-fake/folder-fake';
|
||||
component.onSuccess = null;
|
||||
component._uploaderService.uploadFilesInTheQueue = jasmine.createSpy('uploadFilesInTheQueue');
|
||||
@@ -129,7 +129,19 @@ describe('Test ng2-alfresco-upload UploadButton', () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
component.onFilesAdded(fakeEvent);
|
||||
expect(component._uploaderService.uploadFilesInTheQueue).toHaveBeenCalledWith('/root-fake-/sites-fake/folder-fake', null);
|
||||
expect(component._uploaderService.uploadFilesInTheQueue).toHaveBeenCalledWith('-root-', '/root-fake-/sites-fake/folder-fake', null);
|
||||
});
|
||||
|
||||
it('should call uploadFile with a custom root folder', () => {
|
||||
component.currentFolderPath = '/root-fake-/sites-fake/folder-fake';
|
||||
component.rootFolderId = '-my-';
|
||||
component.onSuccess = null;
|
||||
component._uploaderService.uploadFilesInTheQueue = jasmine.createSpy('uploadFilesInTheQueue');
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
component.onFilesAdded(fakeEvent);
|
||||
expect(component._uploaderService.uploadFilesInTheQueue).toHaveBeenCalledWith('-my-', '/root-fake-/sites-fake/folder-fake', null);
|
||||
});
|
||||
|
||||
it('should create a folder and emit an File uploaded event', (done) => {
|
||||
|
@@ -53,6 +53,8 @@ const ERROR_FOLDER_ALREADY_EXIST = 409;
|
||||
})
|
||||
export class UploadButtonComponent {
|
||||
|
||||
private static DEFAULT_ROOT_ID: string = '-root-';
|
||||
|
||||
@ViewChild('undoNotificationBar')
|
||||
undoNotificationBar: any;
|
||||
|
||||
@@ -72,7 +74,10 @@ export class UploadButtonComponent {
|
||||
acceptedFilesType: string = '*';
|
||||
|
||||
@Input()
|
||||
currentFolderPath: string = '/Sites/swsdp/documentLibrary';
|
||||
currentFolderPath: string = '/';
|
||||
|
||||
@Input()
|
||||
rootFolderId: string = UploadButtonComponent.DEFAULT_ROOT_ID;
|
||||
|
||||
@Output()
|
||||
onSuccess = new EventEmitter();
|
||||
@@ -151,7 +156,7 @@ export class UploadButtonComponent {
|
||||
private uploadFiles(path: string, files: any[]) {
|
||||
if (files.length) {
|
||||
let latestFilesAdded = this._uploaderService.addToQueue(files);
|
||||
this._uploaderService.uploadFilesInTheQueue(path, this.onSuccess);
|
||||
this._uploaderService.uploadFilesInTheQueue(this.rootFolderId, path, this.onSuccess);
|
||||
if (this.showUdoNotificationBar) {
|
||||
this._showUndoNotificationBar(latestFilesAdded);
|
||||
}
|
||||
|
@@ -99,7 +99,7 @@ describe('Test ng2-alfresco-upload UploadDragArea', () => {
|
||||
|
||||
component.onFilesDropped(filesList);
|
||||
expect(component._uploaderService.addToQueue).toHaveBeenCalledWith(filesList);
|
||||
expect(component._uploaderService.uploadFilesInTheQueue).toHaveBeenCalledWith('/root-fake-/sites-fake/folder-fake', null);
|
||||
expect(component._uploaderService.uploadFilesInTheQueue).toHaveBeenCalledWith('-root-', '/root-fake-/sites-fake/folder-fake', null);
|
||||
});
|
||||
|
||||
it('should show the loading messages in the notification bar when the files are dropped', () => {
|
||||
@@ -114,7 +114,7 @@ describe('Test ng2-alfresco-upload UploadDragArea', () => {
|
||||
let filesList = [fileFake];
|
||||
|
||||
component.onFilesDropped(filesList);
|
||||
expect(component._uploaderService.uploadFilesInTheQueue).toHaveBeenCalledWith('/root-fake-/sites-fake/folder-fake', null);
|
||||
expect(component._uploaderService.uploadFilesInTheQueue).toHaveBeenCalledWith('-root-', '/root-fake-/sites-fake/folder-fake', null);
|
||||
expect(component._showUndoNotificationBar).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -138,7 +138,31 @@ describe('Test ng2-alfresco-upload UploadDragArea', () => {
|
||||
|
||||
component.onFilesEntityDropped(itemEntity);
|
||||
expect(component._uploaderService.uploadFilesInTheQueue)
|
||||
.toHaveBeenCalledWith('/root-fake-/sites-fake/document-library-fake/folder-fake/', null);
|
||||
.toHaveBeenCalledWith('-root-', '/root-fake-/sites-fake/document-library-fake/folder-fake/', null);
|
||||
});
|
||||
|
||||
it('should upload a file with a custom root folder ID when dropped', () => {
|
||||
component.currentFolderPath = '/root-fake-/sites-fake/document-library-fake';
|
||||
component.rootFolderId = '-my-';
|
||||
component.onSuccess = null;
|
||||
|
||||
fixture.detectChanges();
|
||||
spyOn(component._uploaderService, 'uploadFilesInTheQueue');
|
||||
|
||||
let itemEntity = {
|
||||
fullPath: '/folder-fake/file-fake.png',
|
||||
isDirectory: false,
|
||||
isFile: true,
|
||||
name: 'file-fake.png',
|
||||
file: (callbackFile) => {
|
||||
let fileFake = new File(['fakefake'], 'file-fake.png', {type: 'image/png'});
|
||||
callbackFile(fileFake);
|
||||
}
|
||||
};
|
||||
|
||||
component.onFilesEntityDropped(itemEntity);
|
||||
expect(component._uploaderService.uploadFilesInTheQueue)
|
||||
.toHaveBeenCalledWith('-my-', '/root-fake-/sites-fake/document-library-fake/folder-fake/', null);
|
||||
});
|
||||
|
||||
it('should throws an exception and show it in the notification bar when the folder already exist', done => {
|
||||
|
@@ -41,6 +41,8 @@ const ERROR_FOLDER_ALREADY_EXIST = 409;
|
||||
})
|
||||
export class UploadDragAreaComponent {
|
||||
|
||||
private static DEFAULT_ROOT_ID: string = '-root-';
|
||||
|
||||
@ViewChild('undoNotificationBar')
|
||||
undoNotificationBar: any;
|
||||
|
||||
@@ -51,7 +53,10 @@ export class UploadDragAreaComponent {
|
||||
versioning: boolean = false;
|
||||
|
||||
@Input()
|
||||
currentFolderPath: string = '/Sites/swsdp/documentLibrary';
|
||||
currentFolderPath: string = '/';
|
||||
|
||||
@Input()
|
||||
rootFolderId: string = UploadDragAreaComponent.DEFAULT_ROOT_ID;
|
||||
|
||||
@Output()
|
||||
onSuccess = new EventEmitter();
|
||||
@@ -77,7 +82,7 @@ export class UploadDragAreaComponent {
|
||||
if (files.length) {
|
||||
if (this.checkValidity(files)) {
|
||||
this._uploaderService.addToQueue(files);
|
||||
this._uploaderService.uploadFilesInTheQueue(this.currentFolderPath, this.onSuccess);
|
||||
this._uploaderService.uploadFilesInTheQueue(this.rootFolderId, this.currentFolderPath, this.onSuccess);
|
||||
let latestFilesAdded = this._uploaderService.getQueue();
|
||||
if (this.showUdoNotificationBar) {
|
||||
this._showUndoNotificationBar(latestFilesAdded);
|
||||
@@ -115,7 +120,7 @@ export class UploadDragAreaComponent {
|
||||
this._uploaderService.addToQueue([file]);
|
||||
let path = item.fullPath.replace(item.name, '');
|
||||
let filePath = this.currentFolderPath + path;
|
||||
this._uploaderService.uploadFilesInTheQueue(filePath, this.onSuccess);
|
||||
this._uploaderService.uploadFilesInTheQueue(this.rootFolderId, filePath, this.onSuccess);
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user