mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[AAE-4504] FE - [ADF] Fetch destination Folder Path from a static path (#6557)
* [AAE4504] FE - [ADF] Fetch destination Folder Path from a static path * * Added condition to check destination folder path * * Added typescript way to check * Fix attach file from local e2e * * Added unit tests to the recent changes * * Fixed comments Co-authored-by: Cristina Jalba <cristina.jalba@ness.com>
This commit is contained in:
@@ -19,10 +19,17 @@
|
||||
|
||||
import { FormFieldSelectedFolder } from './form-field-selected-folder';
|
||||
|
||||
export interface DestinationFolderPath {
|
||||
id?: string;
|
||||
name?: string;
|
||||
type: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface FormFieldFileSource {
|
||||
metadataAllowed: boolean;
|
||||
name: string;
|
||||
selectedFolder: FormFieldSelectedFolder;
|
||||
serviceId: string;
|
||||
destinationFolderPath: string;
|
||||
destinationFolderPath: DestinationFolderPath;
|
||||
}
|
||||
|
@@ -111,7 +111,11 @@ describe('AttachFileCloudWidgetComponent', () => {
|
||||
fileSource: {
|
||||
name: 'all file sources',
|
||||
serviceId: 'all-file-sources',
|
||||
destinationFolderPath: '-root-/myfiles'
|
||||
destinationFolderPath: {
|
||||
name: 'staticValue',
|
||||
value: '-root-/myfiles',
|
||||
type: 'value'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -119,7 +123,11 @@ describe('AttachFileCloudWidgetComponent', () => {
|
||||
fileSource: {
|
||||
name: 'all file sources',
|
||||
serviceId: 'all-file-sources',
|
||||
destinationFolderPath: '-root-'
|
||||
destinationFolderPath: {
|
||||
name: 'staticValue',
|
||||
value: '-root-',
|
||||
type: 'value'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -127,7 +135,11 @@ describe('AttachFileCloudWidgetComponent', () => {
|
||||
fileSource: {
|
||||
name: 'all file sources',
|
||||
serviceId: 'all-file-sources',
|
||||
destinationFolderPath: '-wrongAlias-'
|
||||
destinationFolderPath: {
|
||||
name: 'staticValue',
|
||||
value: '-wrongAlias-',
|
||||
type: 'value'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -135,7 +147,26 @@ describe('AttachFileCloudWidgetComponent', () => {
|
||||
fileSource: {
|
||||
name: 'all file sources',
|
||||
serviceId: 'all-file-sources',
|
||||
destinationFolderPath: '/noalias/createdFolder'
|
||||
destinationFolderPath: {
|
||||
name: 'staticValue',
|
||||
value: '/noalias/createdFolder',
|
||||
type: 'value'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const allSourceWithoutDestinationFolderPath = {
|
||||
fileSource: {
|
||||
name: 'all file sources',
|
||||
serviceId: 'all-file-sources'
|
||||
}
|
||||
};
|
||||
|
||||
const allSourceWithoutValueProperty = {
|
||||
fileSource: {
|
||||
name: 'all file sources',
|
||||
serviceId: 'all-file-sources',
|
||||
destinationFolderPath: '-mockAlias-'
|
||||
}
|
||||
};
|
||||
|
||||
@@ -363,7 +394,7 @@ describe('AttachFileCloudWidgetComponent', () => {
|
||||
const alias = '-root-';
|
||||
const opt = { relativePath: '/myfiles' };
|
||||
expect(fetchNodeIdFromRelativePathSpy).toHaveBeenCalledWith(alias, opt);
|
||||
expect(widget.field.params.fileSource.destinationFolderPath).toBe('-root-/myfiles');
|
||||
expect(widget.field.params.fileSource.destinationFolderPath.value).toBe('-root-/myfiles');
|
||||
expect(widget.rootNodeId).toEqual('mock-node-id');
|
||||
});
|
||||
|
||||
@@ -454,6 +485,46 @@ describe('AttachFileCloudWidgetComponent', () => {
|
||||
expect(openUploadFileDialogSpy).toHaveBeenCalledWith('-my-', 'multiple', true, true);
|
||||
});
|
||||
|
||||
it('Should set default user alias (-my-) as rootNodeId if destinationFolderPath is not defined', async () => {
|
||||
const getAliasAndPathSpy = spyOn(widget, 'getAliasAndRelativePathFromDestinationFolderPath').and.callThrough();
|
||||
widget.field = new FormFieldModel(new FormModel(), {
|
||||
type: FormFieldTypes.UPLOAD,
|
||||
value: [],
|
||||
id: 'attach-file-alfresco',
|
||||
params: <any> allSourceWithoutDestinationFolderPath
|
||||
});
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
const attachButton: HTMLButtonElement = element.querySelector('#attach-file-alfresco');
|
||||
|
||||
attachButton.click();
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(getAliasAndPathSpy).not.toHaveBeenCalled();
|
||||
expect(widget.rootNodeId).toEqual('-my-');
|
||||
});
|
||||
|
||||
it('Should set default user alias (-my-) as rootNodeId if value property missing from destinationFolderPath', async () => {
|
||||
const getAliasAndPathSpy = spyOn(widget, 'getAliasAndRelativePathFromDestinationFolderPath').and.callThrough();
|
||||
widget.field = new FormFieldModel(new FormModel(), {
|
||||
type: FormFieldTypes.UPLOAD,
|
||||
value: [],
|
||||
id: 'attach-file-alfresco',
|
||||
params: <any> allSourceWithoutValueProperty
|
||||
});
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
const attachButton: HTMLButtonElement = element.querySelector('#attach-file-alfresco');
|
||||
|
||||
attachButton.click();
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(getAliasAndPathSpy).not.toHaveBeenCalled();
|
||||
expect(widget.rootNodeId).toEqual('-my-');
|
||||
});
|
||||
|
||||
it('should return the application name in case -appname- placeholder is present', async() => {
|
||||
appConfigService.config = Object.assign(appConfigService.config, {
|
||||
'alfresco-deployed-apps': [
|
||||
|
@@ -125,8 +125,8 @@ export class AttachFileCloudWidgetComponent extends UploadCloudWidgetComponent i
|
||||
async openSelectDialog() {
|
||||
const selectedMode = this.field.params.multiple ? 'multiple' : 'single';
|
||||
let destinationFolderPath = <DestinationFolderPathModel> { alias: AttachFileCloudWidgetComponent.ALIAS_USER_FOLDER, path: '' };
|
||||
if (this.isAlfrescoAndLocal()) {
|
||||
destinationFolderPath = this.getAliasAndRelativePathFromDestinationFolderPath(this.field.params.fileSource.destinationFolderPath);
|
||||
if (this.isAlfrescoAndLocal() && this.hasDestinationFolder()) {
|
||||
destinationFolderPath = this.getAliasAndRelativePathFromDestinationFolderPath(this.field.params.fileSource.destinationFolderPath.value);
|
||||
destinationFolderPath.path = this.replaceAppNameAliasWithValue(destinationFolderPath.path);
|
||||
}
|
||||
const nodeId = await this.contentNodeSelectorService.fetchNodeIdFromRelativePath(destinationFolderPath.alias, { relativePath: destinationFolderPath.path });
|
||||
@@ -218,6 +218,10 @@ export class AttachFileCloudWidgetComponent extends UploadCloudWidgetComponent i
|
||||
return alias && AttachFileCloudWidgetComponent.VALID_ALIAS.includes(alias);
|
||||
}
|
||||
|
||||
private hasDestinationFolder(): boolean {
|
||||
return !!this.field?.params?.fileSource?.destinationFolderPath?.value;
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.contentNodeSelectorPanelService.customModels = [];
|
||||
}
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { by, element } from 'protractor';
|
||||
import { by, element, browser } from 'protractor';
|
||||
import { DocumentListPage } from '../pages/document-list.page';
|
||||
import { BrowserVisibility } from '../../core/utils/browser-visibility';
|
||||
import { BrowserActions } from '../../core/utils/browser-actions';
|
||||
@@ -149,6 +149,7 @@ export class ContentNodeSelectorDialogPage {
|
||||
|
||||
const uploadButton = element(by.css('adf-upload-button input'));
|
||||
await BrowserVisibility.waitUntilElementIsPresent(uploadButton);
|
||||
await browser.sleep(500);
|
||||
await uploadButton.sendKeys(fileLocation);
|
||||
|
||||
await this.tabPage.clickTabByLabel(this.repositoryTabName);
|
||||
|
Reference in New Issue
Block a user