mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACS-8635] Properly handle each case of viewing files linked to process/task (#10169)
* [ACS-8635] Properly handle each case of viewing files linked to process/task * [ACS-8635] Unit test coverage
This commit is contained in:
@@ -172,6 +172,16 @@ describe('AttachFileWidgetComponent', () => {
|
||||
fixture.destroy();
|
||||
});
|
||||
|
||||
it('should add file to tempFilesList when form has value and file source is configured', () => {
|
||||
spyOn(widget, 'isFileSourceConfigured').and.returnValue(true);
|
||||
widget.field = new FormFieldModel(new FormModel(), {
|
||||
type: FormFieldTypes.UPLOAD,
|
||||
value: [fakePngAnswer]
|
||||
});
|
||||
fixture.detectChanges();
|
||||
expect(widget.isTemporaryFile(fakePngAnswer)).toBeTrue();
|
||||
});
|
||||
|
||||
it('should show up as simple upload when is configured for only local files', async () => {
|
||||
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(null));
|
||||
widget.field = new FormFieldModel(new FormModel(), {
|
||||
@@ -517,19 +527,6 @@ describe('AttachFileWidgetComponent', () => {
|
||||
await fixture.whenStable();
|
||||
});
|
||||
|
||||
it('should raise formContentClicked event when file has sourceId', async () => {
|
||||
const testFile = {
|
||||
sourceId: '12345',
|
||||
id: '12345',
|
||||
contentAvailable: true
|
||||
};
|
||||
formService.formContentClicked.subscribe((file) => {
|
||||
expect(file).not.toBeNull();
|
||||
expect(file).toBe(testFile);
|
||||
});
|
||||
fixture.componentInstance.onAttachFileClicked(testFile);
|
||||
});
|
||||
|
||||
it('should not display the show button file when is an external file', async () => {
|
||||
fakePngAnswer.isExternal = true;
|
||||
spyOn(processContentService, 'getFileRawContent').and.returnValue(of(fakePngAnswer));
|
||||
|
@@ -85,6 +85,10 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements
|
||||
ngOnInit() {
|
||||
super.ngOnInit();
|
||||
|
||||
if (Array.isArray(this.field.value) && this.isFileSourceConfigured()) {
|
||||
this.tempFilesList.push(...this.field.value);
|
||||
}
|
||||
|
||||
this.activitiContentService.getAlfrescoRepositories().subscribe((repoList) => {
|
||||
this.repositoryList = repoList;
|
||||
});
|
||||
@@ -170,7 +174,7 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements
|
||||
if (file.isExternal || !file.contentAvailable) {
|
||||
return;
|
||||
}
|
||||
if (this.isTemporaryFile(file) || file.sourceId) {
|
||||
if (this.isTemporaryFile(file)) {
|
||||
this.formService.formContentClicked.next(file);
|
||||
} else {
|
||||
this.fileClicked(file);
|
||||
|
Reference in New Issue
Block a user