angular / angular/components

bug(MatInputTestHarness): setValue does not trigger "change" event

Aperta
#30,160 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
area: cdk/testing P3
Lingua principale
TypeScript
Stelle
25k
Fork
6.8k
Merge medio
1g 8h
PR unite (30g)
91

Descrizione

### Is this a regression?

- [ ] Yes, this behavior used to work in the previous version

### The previous version in which this bug was not present was

_No response_

### Description

According to the documentation, the MatInput component emits a "change" event when the value changes. However, the test harness does not emit this event after "setValue()". See the stackblitz.

I have tried using focus() to focus the component before setting the value, then blur() to remove focus, which is what triggers "change" in the application, and there is still no "change" event.

### Reproduction

StackBlitz link: https://stackblitz.com/edit/phfedq5f?file=src%2Fexample%2Finput-harness-example.html
Steps to reproduce:
1. modified example test from https://material.angular.io/components/input/examples should run automatically
2. two tests fail because the event spy is not called

### Expected Behavior

You should be able to trigger the expected event with the test harness.

### Actual Behavior

Expected code associated with (change) to run.

### Environment

- Angular: 19
- CDK/Material: 19
- Browser(s): chrome
- Operating System (e.g. Windows, macOS, Ubuntu): Windows, macOs

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia con il comportamento di MatInputTestHarness descritto nell’issue ed esegui la riproduzione collegata di StackBlitz, basata sull’esempio di input Material modificato. Verifica gli spy degli eventi che falliscono attorno a setValue(), inclusi i tentativi di focus e blur. Il lavoro è completato quando viene eseguito il change handler previsto ed entrambi i test di riproduzione passano.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
angular, typescript
Ambito
frontend, testing
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.