This is not actually a question. This is a solution. I have had the issue and found this topic : "https://forum.primefaces.org/viewtopic.php?t=50318" but I do not want to register to submit the solution.
So here it is ! The value of the autocomplete component is only set after a keypressdown event. So here is the solution :
const autoComplete = fixture.debugElement.query(By.css('p-autocomplete')).query(By.css('input'));
autoComplete.nativeElement.value = 'MyValue';
autoComplete.nativeElement.dispatchEvent(new Event("keydown"));
fixture.detectChanges();
tick(400); <== //Because the component triggers observables with 300 delay
autoComplete.nativeElement.dispatchEvent(new Event('input'));
fixture.detectChanges();
tick(400);
Hope this can help someone someday.
Aucun commentaire:
Enregistrer un commentaire