From 5db2df8aad4f5af73ff1edc5cb8a294b99a25bf9 Mon Sep 17 00:00:00 2001 From: Jessica Janiuk Date: Thu, 6 Mar 2025 15:04:47 -0500 Subject: [PATCH] ci: fix flakey timer tests (#60254) This adjusts the tests to have a longer await time and removes the click portion of the test. These tests should only pass if the timer has triggered hydration. PR Close #60254 --- .../test/incremental_hydration_spec.ts | 45 +++++-------------- 1 file changed, 10 insertions(+), 35 deletions(-) diff --git a/packages/platform-server/test/incremental_hydration_spec.ts b/packages/platform-server/test/incremental_hydration_spec.ts index 55507b8d652..e183184a4a0 100644 --- a/packages/platform-server/test/incremental_hydration_spec.ts +++ b/packages/platform-server/test/incremental_hydration_spec.ts @@ -1400,21 +1400,12 @@ describe('platform-server partial hydration integration', () => { expect(appHostNode.outerHTML).toContain('
'); - await timeout(150); // wait for timer - appRef.tick(); - + await timeout(500); // wait for timer + await appRef.whenStable(); await allPendingDynamicImports(); appRef.tick(); expect(appHostNode.outerHTML).toContain('start'); - - const testElement = doc.getElementById('test')!; - const clickEvent2 = new CustomEvent('click'); - testElement.dispatchEvent(clickEvent2); - - appRef.tick(); - - expect(appHostNode.outerHTML).toContain('end'); }, TEST_TIMEOUT, ); @@ -1432,7 +1423,7 @@ describe('platform-server partial hydration integration', () => { @defer (on viewport; hydrate on timer(150)) {

Nested defer block

- {{value()}} + {{value()}}
} @placeholder { Inner block placeholder @@ -1447,8 +1438,10 @@ describe('platform-server partial hydration integration', () => { class SimpleComponent { value = signal('start'); fnA() {} - fnB() { - this.value.set('end'); + constructor() { + if (!isPlatformServer(inject(PLATFORM_ID))) { + this.value.set('end'); + } } } @@ -1472,11 +1465,7 @@ describe('platform-server partial hydration integration', () => { //////////////////////////////// const doc = getDocument(); const appRef = await prepareEnvironmentAndHydrate(doc, html, SimpleComponent, { - envProviders: [ - ...providers, - {provide: PLATFORM_ID, useValue: 'browser'}, - withDebugConsole(), - ], + envProviders: [...providers, {provide: PLATFORM_ID, useValue: 'browser'}], hydrationFeatures, }); const compRef = getComponentRef(appRef); @@ -1487,25 +1476,11 @@ describe('platform-server partial hydration integration', () => { expect(appHostNode.outerHTML).toContain('
'); - verifyHasLog( - appRef, - 'Angular hydrated 1 component(s) and 21 node(s), 0 component(s) were skipped. 2 defer block(s) were configured to use incremental hydration.', - ); - - await timeout(150); // wait for timer - appRef.tick(); - + await timeout(500); // wait for timer + await appRef.whenStable(); await allPendingDynamicImports(); appRef.tick(); - expect(appHostNode.outerHTML).toContain('start'); - - const testElement = doc.getElementById('test')!; - const clickEvent2 = new CustomEvent('click'); - testElement.dispatchEvent(clickEvent2); - - appRef.tick(); - expect(appHostNode.outerHTML).toContain('end'); }, TEST_TIMEOUT,