From 9845b1e2a03cf9bc858ec89921ea16d852fff567 Mon Sep 17 00:00:00 2001 From: Tomasz Gnyp <49343696+tomgny@users.noreply.github.com> Date: Mon, 5 Jun 2023 12:23:30 +0200 Subject: [PATCH] [AAE-14851] Convert manual tests to unit for C587091, C587092 (#8608) * [AAE-14851] Convert manual tests to unit for C587091, C587092 * remove useless unit test * implement suggestions --- ...attach-file-cloud-widget.component.spec.ts | 20 +++++-------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/attach-file-cloud-widget.component.spec.ts b/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/attach-file-cloud-widget.component.spec.ts index 52b713a74d..0ffb137697 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/attach-file-cloud-widget.component.spec.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/attach-file-cloud-widget.component.spec.ts @@ -378,6 +378,7 @@ describe('AttachFileCloudWidgetComponent', () => { it('Should set default user alias (-my-) as rootNodeId if destinationFolderPath contains wrong alias and single upload for Alfresco Content + Locale', async () => { spyOn(contentCloudNodeSelectorService, 'getNodeIdFromPath').and.returnValue(mockMyNodeId); + const getAliasSpy = spyOn(widget, 'getAliasAndRelativePathFromDestinationFolderPath').and.callThrough(); createUploadWidgetField(new FormModel(), 'attach-file-alfresco', [], allSourceWithWrongAliasParams, false); fixture.detectChanges(); await fixture.whenStable(); @@ -385,25 +386,14 @@ describe('AttachFileCloudWidgetComponent', () => { fixture.detectChanges(); await fixture.whenStable(); - expect(widget.rootNodeId).toEqual('-my-'); - expect(openUploadFileDialogSpy).toHaveBeenCalledWith('-my-', 'single', true, true); - }); + const wrongAlias = allSourceWithWrongAliasParams.fileSource.destinationFolderPath.value; - it('Should set default user alias (-my-) as rootNodeId if destinationFolderPath contains wrong alias and multiple upload for Alfresco Content + Locale', async () => { - spyOn(contentCloudNodeSelectorService, 'getNodeIdFromPath').and.returnValue(mockMyNodeId); - createUploadWidgetField(new FormModel(), 'attach-file-alfresco', [], allSourceWithWrongAliasParams, true); - fixture.detectChanges(); - await fixture.whenStable(); - clickOnAttachFileWidget('attach-file-alfresco'); - fixture.detectChanges(); - await fixture.whenStable(); - - expect(widget.rootNodeId).toEqual('-my-'); - expect(openUploadFileDialogSpy).toHaveBeenCalledWith('-my-', 'multiple', true, true); + expect(getAliasSpy).toHaveBeenCalledOnceWith(wrongAlias); + expect(widget.getAliasAndRelativePathFromDestinationFolderPath(wrongAlias)).toEqual({ alias: '-my-', path: undefined }); }); it('Should set default user alias (-my-) as rootNodeId if destinationFolderPath does not have alias for Alfresco Content + Locale', async () => { - spyOn(contentCloudNodeSelectorService, 'getNodeIdFromPath').and.returnValue(mockMyNodeId); + spyOn(contentCloudNodeSelectorService, 'getNodeIdFromPath').and.returnValue(undefined); createUploadWidgetField(new FormModel(), 'attach-file-alfresco', [], allSourceWithNoAliasParams, true); fixture.detectChanges(); await fixture.whenStable();