From 74aa8a3888dcc95817138ef2b1906216605f48fd Mon Sep 17 00:00:00 2001 From: Andrew Scott Date: Thu, 1 Feb 2024 13:26:57 -0800 Subject: [PATCH] test(core): ExpressionChanged... error does not happen with signals (#54206) This test ensures that the `ExpressionChanged...` error does not happen when signals are updated in a view that is attached to `ApplicationRef` but was already checked. This was fixed in 432afd1ef41e0bfd905e71e8b15ec7c9ab337352 which actually consequently fixes it for regular `markForCheck` as well. PR Close #54206 --- .../change_detection_signals_in_zones_spec.ts | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/packages/core/test/acceptance/change_detection_signals_in_zones_spec.ts b/packages/core/test/acceptance/change_detection_signals_in_zones_spec.ts index c3ac5bef4a5af..f738dac35cf59 100644 --- a/packages/core/test/acceptance/change_detection_signals_in_zones_spec.ts +++ b/packages/core/test/acceptance/change_detection_signals_in_zones_spec.ts @@ -171,6 +171,29 @@ describe('CheckAlways components', () => { incrementAfterCheckedUntil = Number.MAX_SAFE_INTEGER; expect(() => fixture.detectChanges()).toThrowError(/Infinite/); }); + + it('refreshes all views attached to ApplicationRef until no longer dirty', () => { + const val = signal(0); + @Component({ + template: '{{val()}}', + standalone: true, + }) + class App { + val = val; + ngOnInit() { + this.val.update(v => v+1); + } + } + const fixture = TestBed.createComponent(App); + const fixture2 = TestBed.createComponent(App); + const appRef = TestBed.inject(ApplicationRef); + appRef.attachView(fixture.componentRef.hostView); + appRef.attachView(fixture2.componentRef.hostView); + + appRef.tick(); + expect(fixture.nativeElement.innerText).toEqual('2'); + expect(fixture2.nativeElement.innerText).toEqual('2'); + }); });