[ADF-5443] remove cannot read properties of null on inputdebugelement

This commit is contained in:
michu-dunat 2021-09-30 08:18:21 -04:00
parent 84b3c79602
commit 3cbb3a1317

View File

@ -64,7 +64,7 @@ import { of } from 'rxjs';
import { FormCloudModule } from '../../../form-cloud.module'; import { FormCloudModule } from '../../../form-cloud.module';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
fdescribe('AttachFileCloudWidgetComponent', () => { describe('AttachFileCloudWidgetComponent', () => {
let widget: AttachFileCloudWidgetComponent; let widget: AttachFileCloudWidgetComponent;
let fixture: ComponentFixture<AttachFileCloudWidgetComponent>; let fixture: ComponentFixture<AttachFileCloudWidgetComponent>;
let element: HTMLInputElement; let element: HTMLInputElement;
@ -449,12 +449,7 @@ fdescribe('AttachFileCloudWidgetComponent', () => {
apiServiceSpy = spyOn(widget['nodesApi'], 'getNode').and.returnValue(new Promise(resolve => resolve({entry: fakeNodeWithProperties}))); apiServiceSpy = spyOn(widget['nodesApi'], 'getNode').and.returnValue(new Promise(resolve => resolve({entry: fakeNodeWithProperties})));
spyOn(contentCloudNodeSelectorService, 'getNodeIdFromPath').and.returnValue(new Promise(resolve => resolve('fake-properties'))); spyOn(contentCloudNodeSelectorService, 'getNodeIdFromPath').and.returnValue(new Promise(resolve => resolve('fake-properties')));
openUploadFileDialogSpy.and.returnValue(of([fakeNodeWithProperties])); openUploadFileDialogSpy.and.returnValue(of([fakeNodeWithProperties]));
widget.field = new FormFieldModel(new FormModel(), { createUploadWidgetField(new FormModel(), 'attach-file-alfresco', [], <FormFieldMetadata>menuTestSourceParam, false, null, false);
type: FormFieldTypes.UPLOAD,
value: []
});
widget.field.id = 'attach-file-alfresco';
widget.field.params = <FormFieldMetadata> menuTestSourceParam;
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@ -568,38 +563,40 @@ fdescribe('AttachFileCloudWidgetComponent', () => {
}); });
it('should display the default menu options if no options are provided', () => { it('should display the default menu options if no options are provided', () => {
widget.hasFile = false;
widget.field.params = <FormFieldMetadata> onlyLocalParams; widget.field.params = <FormFieldMetadata> onlyLocalParams;
fixture.detectChanges(); fixture.detectChanges();
fixture.whenStable().then(() => { fixture.whenStable().then(() => {
const inputDebugElement = fixture.debugElement.query( const inputDebugElement = fixture.debugElement.query(
By.css('#adf-attach-widget-readonly-list') By.css('#attach-file-alfresco')
); );
inputDebugElement.triggerEventHandler('change', { inputDebugElement.triggerEventHandler('change', {
target: { files: [fakeLocalPngAnswer] } target: { files: [fakeLocalPngAnswer] }
}); });
widget.hasFile = true;
fixture.detectChanges(); fixture.detectChanges();
const menuButton: HTMLButtonElement = <HTMLButtonElement> ( const menuButton: HTMLButtonElement = <HTMLButtonElement> (
fixture.debugElement.query( fixture.debugElement.query(
By.css('#file-fake-option-menu') By.css('#file-1155-option-menu')
).nativeElement ).nativeElement
); );
menuButton.click(); menuButton.click();
fixture.detectChanges(); fixture.detectChanges();
const showOption: HTMLButtonElement = <HTMLButtonElement> ( const showOption: HTMLButtonElement = <HTMLButtonElement> (
fixture.debugElement.query( fixture.debugElement.query(
By.css('#file-fake-show-file') By.css('#file-1155-show-file')
).nativeElement ).nativeElement
); );
const downloadOption: HTMLButtonElement = <HTMLButtonElement> ( const downloadOption: HTMLButtonElement = <HTMLButtonElement> (
fixture.debugElement.query(By.css('#file-fake-download-file')) fixture.debugElement.query(By.css('#file-1155-download-file'))
.nativeElement .nativeElement
); );
const retrieveMetadataOption: HTMLButtonElement = <HTMLButtonElement> ( const retrieveMetadataOption: HTMLButtonElement = <HTMLButtonElement> (
fixture.debugElement.query(By.css('#file-fake-retrieve-file-metadata')) fixture.debugElement.query(By.css('#file-1155-retrieve-file-metadata'))
.nativeElement .nativeElement
); );
const removeOption: HTMLButtonElement = <HTMLButtonElement> ( const removeOption: HTMLButtonElement = <HTMLButtonElement> (
fixture.debugElement.query(By.css('#file-fake-remove')) fixture.debugElement.query(By.css('#file-1155-remove'))
.nativeElement .nativeElement
); );