mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACA-3847] - fixed download for external source file (#7254)
* [AAE-3847] - added test for check login on external upload * [ACA-3847] - fixed logout/login scenario for external linked file * [ACA-3847] - fixed lint problems
This commit is contained in:
@@ -77,14 +77,20 @@ export class AttachFileWidgetDialogService {
|
|||||||
|
|
||||||
downloadURL(repository: AlfrescoEndpointRepresentation, sourceId: string): Observable<string> {
|
downloadURL(repository: AlfrescoEndpointRepresentation, sourceId: string): Observable<string> {
|
||||||
const { accountIdentifier } = this.constructPayload(repository);
|
const { accountIdentifier } = this.constructPayload(repository);
|
||||||
const contentApi = new ContentApi(this.externalApis[accountIdentifier].getInstance());
|
|
||||||
|
|
||||||
if (this.externalApis[accountIdentifier]?.getInstance()?.isLoggedIn()) {
|
if (this.externalApis[accountIdentifier]?.getInstance()) {
|
||||||
return of(contentApi.getContentUrl(sourceId));
|
const contentApi = new ContentApi(this.externalApis[accountIdentifier].getInstance());
|
||||||
|
|
||||||
|
if (this.externalApis[accountIdentifier].getInstance().isLoggedIn()) {
|
||||||
|
return of(contentApi.getContentUrl(sourceId));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.showExternalHostLoginDialog(repository).pipe(
|
return this.showExternalHostLoginDialog(repository).pipe(
|
||||||
switchMap(() => of(contentApi.getContentUrl(sourceId)))
|
switchMap(() => {
|
||||||
|
const contentApi = new ContentApi(this.externalApis[accountIdentifier].getInstance());
|
||||||
|
return of(contentApi.getContentUrl(sourceId));
|
||||||
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -600,4 +600,29 @@ describe('AttachFileWidgetComponent', () => {
|
|||||||
|
|
||||||
expect(element.querySelector('#file-1155-icon')).not.toBeNull();
|
expect(element.querySelector('#file-1155-icon')).not.toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should pass a valid repository id to open the external login', async () => {
|
||||||
|
widget.field = new FormFieldModel(new FormModel(), { type: FormFieldTypes.UPLOAD, value: [] });
|
||||||
|
widget.field.id = 'attach-external-file-attach';
|
||||||
|
widget.field.params = <FormFieldMetadata> externalDefinedSourceParams;
|
||||||
|
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
|
||||||
|
spyOn(activitiContentService, 'applyAlfrescoNode').and.returnValue(of(fakePngAnswer));
|
||||||
|
const openLoginSpy = spyOn(attachFileWidgetDialogService, 'openLogin').and.returnValue(of([fakeMinimalNode]));
|
||||||
|
|
||||||
|
fixture.detectChanges();
|
||||||
|
await fixture.whenStable();
|
||||||
|
|
||||||
|
const attachButton = element.querySelector<HTMLButtonElement>('#attach-external-file-attach');
|
||||||
|
attachButton.click();
|
||||||
|
|
||||||
|
fixture.detectChanges();
|
||||||
|
await fixture.whenStable();
|
||||||
|
|
||||||
|
fixture.debugElement.query(By.css('#attach-external')).nativeElement.click();
|
||||||
|
|
||||||
|
fixture.detectChanges();
|
||||||
|
await fixture.whenStable();
|
||||||
|
|
||||||
|
expect(openLoginSpy).toHaveBeenCalledWith(fakeRepositoryListAnswer[2], undefined, 'alfresco-2000-external');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user