Skip to content

Commit

Permalink
[ACA-3847] - fixed download for external source file (#7254)
Browse files Browse the repository at this point in the history
* [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
  • Loading branch information
VitoAlbano committed Oct 29, 2021
1 parent 7481001 commit 622383a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
Expand Up @@ -77,14 +77,20 @@ export class AttachFileWidgetDialogService {

downloadURL(repository: AlfrescoEndpointRepresentation, sourceId: string): Observable<string> {
const { accountIdentifier } = this.constructPayload(repository);
const contentApi = new ContentApi(this.externalApis[accountIdentifier].getInstance());

if (this.externalApis[accountIdentifier]?.getInstance()?.isLoggedIn()) {
return of(contentApi.getContentUrl(sourceId));
if (this.externalApis[accountIdentifier]?.getInstance()) {
const contentApi = new ContentApi(this.externalApis[accountIdentifier].getInstance());

if (this.externalApis[accountIdentifier].getInstance().isLoggedIn()) {
return of(contentApi.getContentUrl(sourceId));
}
}

return this.showExternalHostLoginDialog(repository).pipe(
switchMap(() => of(contentApi.getContentUrl(sourceId)))
switchMap(() => {
const contentApi = new ContentApi(this.externalApis[accountIdentifier].getInstance());
return of(contentApi.getContentUrl(sourceId));
})
);
}

Expand Down
Expand Up @@ -600,4 +600,29 @@ describe('AttachFileWidgetComponent', () => {

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');
});
});

0 comments on commit 622383a

Please sign in to comment.