mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACA-3218] Fix attach file widget - wrong payload when link is true (#5777)
* [ACA-3218] Fix attach file widget link is always false * Add unit tests
This commit is contained in:
@@ -102,7 +102,7 @@ export class ActivitiContentService {
|
|||||||
mimeType: node.content.mimeType,
|
mimeType: node.content.mimeType,
|
||||||
sourceId: node.id + ';' + node.properties['cm:versionLabel'] + '@' + currentSideId,
|
sourceId: node.id + ';' + node.properties['cm:versionLabel'] + '@' + currentSideId,
|
||||||
name: node.name,
|
name: node.name,
|
||||||
link: false
|
link: node.isLink
|
||||||
};
|
};
|
||||||
return from(apiService.activiti.contentApi.createTemporaryRelatedContent(params))
|
return from(apiService.activiti.contentApi.createTemporaryRelatedContent(params))
|
||||||
.pipe(
|
.pipe(
|
||||||
|
@@ -225,6 +225,11 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements
|
|||||||
|
|
||||||
private uploadFileFromCS(fileNodeList: any[], accountId: string, siteId?: string) {
|
private uploadFileFromCS(fileNodeList: any[], accountId: string, siteId?: string) {
|
||||||
const filesSaved = [];
|
const filesSaved = [];
|
||||||
|
|
||||||
|
fileNodeList.forEach(node => {
|
||||||
|
node.isLink = this.field.params.link;
|
||||||
|
});
|
||||||
|
|
||||||
from(fileNodeList).pipe(
|
from(fileNodeList).pipe(
|
||||||
mergeMap((node) =>
|
mergeMap((node) =>
|
||||||
zip(
|
zip(
|
||||||
|
@@ -41,7 +41,8 @@ const fakeRepositoryListAnswer = [
|
|||||||
'serviceId': 'alfresco-9999-SHAREME',
|
'serviceId': 'alfresco-9999-SHAREME',
|
||||||
'metaDataAllowed': true,
|
'metaDataAllowed': true,
|
||||||
'name': 'SHAREME',
|
'name': 'SHAREME',
|
||||||
'repositoryUrl': 'http://localhost:0000/SHAREME'
|
'repositoryUrl': 'http://localhost:0000/SHAREME',
|
||||||
|
'id': 1000
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'authorized': true,
|
'authorized': true,
|
||||||
@@ -60,7 +61,8 @@ const onlyLocalParams = {
|
|||||||
const allSourceParams = {
|
const allSourceParams = {
|
||||||
fileSource: {
|
fileSource: {
|
||||||
serviceId: 'all-file-sources'
|
serviceId: 'all-file-sources'
|
||||||
}
|
},
|
||||||
|
link: false
|
||||||
};
|
};
|
||||||
|
|
||||||
const allSourceParamsWithLinkEnabled = {
|
const allSourceParamsWithLinkEnabled = {
|
||||||
@@ -231,6 +233,58 @@ describe('AttachFileWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should isLink property of the selected node become true when the widget has link enabled', async (done) => {
|
||||||
|
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
|
||||||
|
const applyAlfrescoNodeSpy = spyOn(activitiContentService, 'applyAlfrescoNode');
|
||||||
|
spyOn(contentNodeDialogService, 'openFileBrowseDialogBySite').and.returnValue(of([fakeMinimalNode]));
|
||||||
|
widget.field = new FormFieldModel(new FormModel(), {
|
||||||
|
type: FormFieldTypes.UPLOAD,
|
||||||
|
value: []
|
||||||
|
});
|
||||||
|
widget.field.id = 'attach-file-attach';
|
||||||
|
widget.field.params = <FormFieldMetadata> allSourceParamsWithLinkEnabled;
|
||||||
|
|
||||||
|
fixture.detectChanges();
|
||||||
|
await fixture.whenRenderingDone();
|
||||||
|
|
||||||
|
const attachButton: HTMLButtonElement = element.querySelector('#attach-file-attach');
|
||||||
|
expect(attachButton).not.toBeNull();
|
||||||
|
attachButton.click();
|
||||||
|
|
||||||
|
fixture.detectChanges();
|
||||||
|
await fixture.whenStable();
|
||||||
|
|
||||||
|
fixture.debugElement.query(By.css('#attach-SHAREME')).nativeElement.click();
|
||||||
|
expect(applyAlfrescoNodeSpy).toHaveBeenCalledWith({ ...fakeMinimalNode, isLink: true }, undefined, 'alfresco-1000-SHAREME');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should isLink property of the selected node become false when the widget has link disabled', async (done) => {
|
||||||
|
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
|
||||||
|
const applyAlfrescoNodeSpy = spyOn(activitiContentService, 'applyAlfrescoNode');
|
||||||
|
spyOn(contentNodeDialogService, 'openFileBrowseDialogBySite').and.returnValue(of([fakeMinimalNode]));
|
||||||
|
widget.field = new FormFieldModel(new FormModel(), {
|
||||||
|
type: FormFieldTypes.UPLOAD,
|
||||||
|
value: []
|
||||||
|
});
|
||||||
|
widget.field.id = 'attach-file-attach';
|
||||||
|
widget.field.params = <FormFieldMetadata> allSourceParams;
|
||||||
|
|
||||||
|
fixture.detectChanges();
|
||||||
|
await fixture.whenRenderingDone();
|
||||||
|
|
||||||
|
const attachButton: HTMLButtonElement = element.querySelector('#attach-file-attach');
|
||||||
|
expect(attachButton).not.toBeNull();
|
||||||
|
attachButton.click();
|
||||||
|
|
||||||
|
fixture.detectChanges();
|
||||||
|
await fixture.whenStable();
|
||||||
|
|
||||||
|
fixture.debugElement.query(By.css('#attach-SHAREME')).nativeElement.click();
|
||||||
|
expect(applyAlfrescoNodeSpy).toHaveBeenCalledWith({ ...fakeMinimalNode, isLink: false }, undefined, 'alfresco-1000-SHAREME');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
it('should be able to upload files coming from content node selector', async(() => {
|
it('should be able to upload files coming from content node selector', async(() => {
|
||||||
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
|
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
|
||||||
spyOn(activitiContentService, 'applyAlfrescoNode').and.returnValue(of(fakePngAnswer));
|
spyOn(activitiContentService, 'applyAlfrescoNode').and.returnValue(of(fakePngAnswer));
|
||||||
|
Reference in New Issue
Block a user