mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[AAE-10896] - Fix attach file widget destinationFolderPath is broken … (#7888)
* [AAE-10896] - Fix attach file widget destinationFolderPath is broken when using string variables * Fix unit tests * Add unit test * Fix linting problems
This commit is contained in:
@@ -330,8 +330,7 @@ describe('AttachFileCloudWidgetComponent', () => {
|
||||
it('should be able to use mapped string variable value if the destinationFolderPath set to string type variable', async () => {
|
||||
const getNodeIdFromPathSpy = spyOn(contentCloudNodeSelectorService, 'getNodeIdFromPath').and.returnValue(mockNodeIdBasedOnStringVariableValue);
|
||||
|
||||
const variables = formVariables;
|
||||
const form = new FormModel({ variables, formVariables, processVariables });
|
||||
const form = new FormModel({ formVariables, processVariables });
|
||||
createUploadWidgetField(form, 'attach-file-alfresco', [], mockAllFileSourceWithStringVariablePathType);
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
@@ -791,10 +790,9 @@ describe('AttachFileCloudWidgetComponent', () => {
|
||||
|
||||
describe('Upload widget with destination folder path params', () => {
|
||||
let form: FormModel;
|
||||
const variables = formVariables;
|
||||
|
||||
beforeEach(() => {
|
||||
form = new FormModel({
|
||||
variables,
|
||||
formVariables,
|
||||
processVariables
|
||||
});
|
||||
@@ -808,6 +806,24 @@ describe('AttachFileCloudWidgetComponent', () => {
|
||||
expect(widget.field.params.fileSource.destinationFolderPath.value).toBe('-root-/pathBasedOnStringvariablevalue');
|
||||
});
|
||||
|
||||
it('should be able to fetch the destinationFolderPath from the default value of a form variable', () => {
|
||||
form.processVariables = [];
|
||||
form.variables = formVariables;
|
||||
|
||||
createUploadWidgetField(form, 'attach-file-attach', [], mockAllFileSourceWithStringVariablePathType);
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(widget.field.params.fileSource.destinationFolderPath.value).toBe('mock destination folder path');
|
||||
});
|
||||
|
||||
it('it should get a destination folder path value from a folder variable', () => {
|
||||
createUploadWidgetField(form, 'attach-file-attach', [], mockAllFileSourceWithFolderVariablePathType);
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(widget.field.params.fileSource.destinationFolderPath.type).toBe('folder');
|
||||
expect(widget.field.params.fileSource.destinationFolderPath.value).toBe('mock-folder-id');
|
||||
});
|
||||
|
||||
it('it should get a destination folder path value from a folder variable', () => {
|
||||
createUploadWidgetField(form, 'attach-file-attach', [], mockAllFileSourceWithFolderVariablePathType);
|
||||
fixture.detectChanges();
|
||||
|
@@ -204,6 +204,6 @@ export class UploadCloudWidgetComponent extends WidgetComponent implements OnIni
|
||||
}
|
||||
|
||||
private getDestinationFolderPathValue(): any {
|
||||
return this.field.form.getFormVariableValue(this.field.params.fileSource?.destinationFolderPath?.name);
|
||||
return this.field.form.getProcessVariableValue(this.field.params.fileSource?.destinationFolderPath?.name);
|
||||
}
|
||||
}
|
||||
|
@@ -397,13 +397,12 @@ export const formVariables = [
|
||||
id: 'bfca9766-7bc1-45cc-8ecf-cdad551e36e2',
|
||||
name: 'name1',
|
||||
type: 'string',
|
||||
value: '-root-/pathBasedOnStringvariablevalue'
|
||||
value: 'mock destination folder path'
|
||||
},
|
||||
{
|
||||
id: '3ed9f28a-dbae-463f-b991-47ef06658bb6',
|
||||
name: 'name2',
|
||||
type: 'folder',
|
||||
value: [{ id: 'mock-folder-id'}]
|
||||
type: 'folder'
|
||||
},
|
||||
{
|
||||
id: 'booleanVar',
|
||||
|
Reference in New Issue
Block a user