mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
Fix attach file widget shows Local source when only link is enabled (#5775)
This commit is contained in:
@@ -105,7 +105,8 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements
|
||||
isAllFileSourceSelected(): boolean {
|
||||
return this.field.params &&
|
||||
this.field.params.fileSource &&
|
||||
this.field.params.fileSource.serviceId === 'all-file-sources';
|
||||
this.field.params.fileSource.serviceId === 'all-file-sources' &&
|
||||
!this.field.params.link;
|
||||
}
|
||||
|
||||
isOnlyLocalSourceSelected(): boolean {
|
||||
|
@@ -63,6 +63,13 @@ const allSourceParams = {
|
||||
}
|
||||
};
|
||||
|
||||
const allSourceParamsWithLinkEnabled = {
|
||||
fileSource: {
|
||||
serviceId: 'all-file-sources'
|
||||
},
|
||||
link: true
|
||||
};
|
||||
|
||||
const definedSourceParams = {
|
||||
fileSource: {
|
||||
serviceId: 'goku-sources',
|
||||
@@ -163,7 +170,7 @@ describe('AttachFileWidgetComponent', () => {
|
||||
});
|
||||
}));
|
||||
|
||||
it('should show up all the repository option on menu list', async(() => {
|
||||
it('should show up all the repository option on menu list', async() => {
|
||||
widget.field = new FormFieldModel(new FormModel(), {
|
||||
type: FormFieldTypes.UPLOAD,
|
||||
value: []
|
||||
@@ -178,15 +185,51 @@ describe('AttachFileWidgetComponent', () => {
|
||||
attachButton.click();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(fixture.debugElement.queryAll(By.css('#attach-local-file'))).not.toBeNull();
|
||||
expect(fixture.debugElement.queryAll(By.css('#attach-local-file'))).not.toBeUndefined();
|
||||
expect(fixture.debugElement.queryAll(By.css('#attach-SHAREME'))).not.toBeNull();
|
||||
expect(fixture.debugElement.queryAll(By.css('#attach-SHAREME'))).not.toBeUndefined();
|
||||
expect(fixture.debugElement.queryAll(By.css('#attach-GOKUSHARE'))).not.toBeNull();
|
||||
expect(fixture.debugElement.queryAll(By.css('#attach-GOKUSHARE'))).not.toBeUndefined();
|
||||
const localFileOption = fixture.debugElement.queryAll(By.css('#attach-local-file'));
|
||||
const fakeRepoOption1 = fixture.debugElement.queryAll(By.css('#attach-SHAREME'));
|
||||
const fakeRepoOption2 = fixture.debugElement.queryAll(By.css('#attach-GOKUSHARE'));
|
||||
|
||||
expect(localFileOption.length).toEqual(1);
|
||||
expect(localFileOption[0]).not.toBeNull();
|
||||
|
||||
expect(fakeRepoOption1.length).toEqual(1);
|
||||
expect(fakeRepoOption1[0]).not.toBeNull();
|
||||
|
||||
expect(fakeRepoOption2.length).toEqual(1);
|
||||
expect(fakeRepoOption2[0]).not.toBeNull();
|
||||
});
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
it ('should show only remote repos when just link to files is true', async () => {
|
||||
widget.field = new FormFieldModel(new FormModel(), {
|
||||
type: FormFieldTypes.UPLOAD,
|
||||
value: []
|
||||
});
|
||||
widget.field.id = 'attach-file-attach';
|
||||
widget.field.params = <FormFieldMetadata> allSourceParamsWithLinkEnabled;
|
||||
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
|
||||
fixture.detectChanges();
|
||||
fixture.whenRenderingDone().then(() => {
|
||||
const attachButton: HTMLButtonElement = element.querySelector('#attach-file-attach');
|
||||
expect(attachButton).not.toBeNull();
|
||||
attachButton.click();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const localFileOption = fixture.debugElement.queryAll(By.css('#attach-local-file'));
|
||||
const fakeRepoOption1 = fixture.debugElement.queryAll(By.css('#attach-SHAREME'));
|
||||
const fakeRepoOption2 = fixture.debugElement.queryAll(By.css('#attach-GOKUSHARE'));
|
||||
|
||||
expect(localFileOption.length).toEqual(0);
|
||||
|
||||
expect(fakeRepoOption1.length).toEqual(1);
|
||||
expect(fakeRepoOption1[0]).not.toBeNull();
|
||||
|
||||
expect(fakeRepoOption2.length).toEqual(1);
|
||||
expect(fakeRepoOption2[0]).not.toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to upload files coming from content node selector', async(() => {
|
||||
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
|
||||
|
Reference in New Issue
Block a user