From 3cbb3a13170eb1716a9533ef6b51c8b913ba7e61 Mon Sep 17 00:00:00 2001 From: michu-dunat Date: Thu, 30 Sep 2021 08:18:21 -0400 Subject: [PATCH] [ADF-5443] remove cannot read properties of null on inputdebugelement --- ...attach-file-cloud-widget.component.spec.ts | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 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 917c4c479b..daf691b4fa 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 @@ -64,7 +64,7 @@ import { of } from 'rxjs'; import { FormCloudModule } from '../../../form-cloud.module'; import { TranslateModule } from '@ngx-translate/core'; -fdescribe('AttachFileCloudWidgetComponent', () => { +describe('AttachFileCloudWidgetComponent', () => { let widget: AttachFileCloudWidgetComponent; let fixture: ComponentFixture; let element: HTMLInputElement; @@ -449,12 +449,7 @@ fdescribe('AttachFileCloudWidgetComponent', () => { apiServiceSpy = spyOn(widget['nodesApi'], 'getNode').and.returnValue(new Promise(resolve => resolve({entry: fakeNodeWithProperties}))); spyOn(contentCloudNodeSelectorService, 'getNodeIdFromPath').and.returnValue(new Promise(resolve => resolve('fake-properties'))); openUploadFileDialogSpy.and.returnValue(of([fakeNodeWithProperties])); - widget.field = new FormFieldModel(new FormModel(), { - type: FormFieldTypes.UPLOAD, - value: [] - }); - widget.field.id = 'attach-file-alfresco'; - widget.field.params = menuTestSourceParam; + createUploadWidgetField(new FormModel(), 'attach-file-alfresco', [], menuTestSourceParam, false, null, false); fixture.detectChanges(); await fixture.whenStable(); @@ -568,38 +563,40 @@ fdescribe('AttachFileCloudWidgetComponent', () => { }); it('should display the default menu options if no options are provided', () => { + widget.hasFile = false; widget.field.params = onlyLocalParams; fixture.detectChanges(); fixture.whenStable().then(() => { const inputDebugElement = fixture.debugElement.query( - By.css('#adf-attach-widget-readonly-list') + By.css('#attach-file-alfresco') ); inputDebugElement.triggerEventHandler('change', { target: { files: [fakeLocalPngAnswer] } }); + widget.hasFile = true; fixture.detectChanges(); const menuButton: HTMLButtonElement = ( fixture.debugElement.query( - By.css('#file-fake-option-menu') + By.css('#file-1155-option-menu') ).nativeElement ); menuButton.click(); fixture.detectChanges(); const showOption: HTMLButtonElement = ( fixture.debugElement.query( - By.css('#file-fake-show-file') + By.css('#file-1155-show-file') ).nativeElement ); const downloadOption: HTMLButtonElement = ( - fixture.debugElement.query(By.css('#file-fake-download-file')) + fixture.debugElement.query(By.css('#file-1155-download-file')) .nativeElement ); const retrieveMetadataOption: HTMLButtonElement = ( - fixture.debugElement.query(By.css('#file-fake-retrieve-file-metadata')) + fixture.debugElement.query(By.css('#file-1155-retrieve-file-metadata')) .nativeElement ); const removeOption: HTMLButtonElement = ( - fixture.debugElement.query(By.css('#file-fake-remove')) + fixture.debugElement.query(By.css('#file-1155-remove')) .nativeElement );