[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:
MichalKinas
2024-09-04 14:51:17 +02:00
committed by GitHub
parent 4821c19760
commit a238442d93
2 changed files with 15 additions and 14 deletions

View File

@@ -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));

View File

@@ -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);