Skip to content

Commit

Permalink
[AAE-3410] NodeSelector - Use user alias (-my-) name as default for u…
Browse files Browse the repository at this point in the history
…pload of type Alfresco Content only (#6160)

* Use as default folder root in case is only ACS

* Fix and improve unit test

* Use user alias -my- for Content Service only
  • Loading branch information
mauriziovitale committed Sep 27, 2020
1 parent 71ec41f commit c40614f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,29 @@ describe('AttachFileCloudWidgetComponent', () => {
expect(openUploadFileDialogSpy).toHaveBeenCalledWith('-root-', 'single', true);
});

it('Should be able to set default alias as rootNodeId if destinationFolderPath contains wrong alias', async () => {
it('Should set default user alias (-my-) as rootNodeId if destinationFolderPath contains wrong alias and single upload for Alfresco Content + Locale', async () => {
widget.field = new FormFieldModel(new FormModel(), {
type: FormFieldTypes.UPLOAD,
value: []
});
widget.field.id = 'attach-file-alfresco';
widget.field.params = <FormFieldMetadata> allSourceWithWrongAliasParams;
widget.field.params.multiple = false;
fixture.detectChanges();
await fixture.whenStable();
const attachButton: HTMLButtonElement = element.querySelector('#attach-file-alfresco');

expect(attachButton).not.toBeNull();

attachButton.click();
await fixture.whenStable();
fixture.detectChanges();

expect(widget.rootNodeId).toEqual('-my-');
expect(openUploadFileDialogSpy).toHaveBeenCalledWith('-my-', 'single', true);
});

it('Should set default user alias (-my-) as rootNodeId if destinationFolderPath contains wrong alias and multiple upload for Alfresco Content + Locale', async () => {
widget.field = new FormFieldModel(new FormModel(), {
type: FormFieldTypes.UPLOAD,
value: []
Expand All @@ -401,7 +423,7 @@ describe('AttachFileCloudWidgetComponent', () => {
expect(openUploadFileDialogSpy).toHaveBeenCalledWith('-my-', 'multiple', true);
});

it('Should be able to set default alias as rootNodeId if destinationFolderPath does not have alias', async () => {
it('Should set default user alias (-my-) as rootNodeId if destinationFolderPath does not have alias for Alfresco Content + Locale', async () => {
widget.field = new FormFieldModel(new FormModel(), {
type: FormFieldTypes.UPLOAD,
value: []
Expand Down Expand Up @@ -439,8 +461,7 @@ describe('AttachFileCloudWidgetComponent', () => {
});

describe('FilesSource', () => {

it('should be able to set myFiles folderId as rootNodeId if fileSource set only to content', async () => {
it('Should set default user alias (-my-) as rootNodeId if fileSource set only to Alfresco Content', async () => {
widget.field = new FormFieldModel(new FormModel(), {
type: FormFieldTypes.UPLOAD,
value: []
Expand All @@ -461,28 +482,6 @@ describe('AttachFileCloudWidgetComponent', () => {
expect(openUploadFileDialogSpy).toHaveBeenCalledWith('-my-', 'single', false);
});

it('should be able to set root folderId as rootNodeId if fileSource set to content and local', async () => {
widget.field = new FormFieldModel(new FormModel(), {
type: FormFieldTypes.UPLOAD,
value: []
});
widget.field.id = 'attach-file-alfresco';
widget.field.params = <FormFieldMetadata> allSourceWithWrongAliasParams;
widget.field.params.multiple = false;
fixture.detectChanges();
await fixture.whenStable();
const attachButton: HTMLButtonElement = element.querySelector('#attach-file-alfresco');

expect(attachButton).not.toBeNull();

attachButton.click();
await fixture.whenStable();
fixture.detectChanges();

expect(widget.rootNodeId).toEqual('-my-');
expect(openUploadFileDialogSpy).toHaveBeenCalledWith('-my-', 'single', true);
});

it('should display tooltip when tooltip is set', async(() => {
widget.field = new FormFieldModel(new FormModel(), {
id: 'attach-file-attach',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,13 @@ import { DestinationFolderPathModel } from '../../../models/form-cloud-represent
})
export class AttachFileCloudWidgetComponent extends UploadCloudWidgetComponent implements OnInit {

static ALIAS_ROOT_FOLDER = '-root-';
static ALIAS_USER_FOLDER = '-my-';
static APP_NAME = '-appname-';
static VALID_ALIAS = ['-root-', AttachFileCloudWidgetComponent.ALIAS_USER_FOLDER, '-shared-'];
static VALID_ALIAS = [
AttachFileCloudWidgetComponent.ALIAS_ROOT_FOLDER,
AttachFileCloudWidgetComponent.ALIAS_USER_FOLDER, '-shared-'
];
static RETRIEVE_METADATA_OPTION = 'retrieveMetadata';

typeId = 'AttachFileCloudWidgetComponent';
Expand Down

0 comments on commit c40614f

Please sign in to comment.