mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
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
This commit is contained in:
parent
bb12b30d52
commit
5db2df8aad
1 changed files with 10 additions and 35 deletions
|
|
@ -1400,21 +1400,12 @@ describe('platform-server partial hydration integration', () => {
|
|||
|
||||
expect(appHostNode.outerHTML).toContain('<article>');
|
||||
|
||||
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('<span id="test">start</span>');
|
||||
|
||||
const testElement = doc.getElementById('test')!;
|
||||
const clickEvent2 = new CustomEvent('click');
|
||||
testElement.dispatchEvent(clickEvent2);
|
||||
|
||||
appRef.tick();
|
||||
|
||||
expect(appHostNode.outerHTML).toContain('<span id="test">end</span>');
|
||||
},
|
||||
TEST_TIMEOUT,
|
||||
);
|
||||
|
|
@ -1432,7 +1423,7 @@ describe('platform-server partial hydration integration', () => {
|
|||
@defer (on viewport; hydrate on timer(150)) {
|
||||
<article>
|
||||
<p id="nested">Nested defer block</p>
|
||||
<span id="test" (click)="fnB()">{{value()}}</span>
|
||||
<span id="test">{{value()}}</span>
|
||||
</article>
|
||||
} @placeholder {
|
||||
<span>Inner block placeholder</span>
|
||||
|
|
@ -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<SimpleComponent>(appRef);
|
||||
|
|
@ -1487,25 +1476,11 @@ describe('platform-server partial hydration integration', () => {
|
|||
|
||||
expect(appHostNode.outerHTML).toContain('<article>');
|
||||
|
||||
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('<span id="test">start</span>');
|
||||
|
||||
const testElement = doc.getElementById('test')!;
|
||||
const clickEvent2 = new CustomEvent('click');
|
||||
testElement.dispatchEvent(clickEvent2);
|
||||
|
||||
appRef.tick();
|
||||
|
||||
expect(appHostNode.outerHTML).toContain('<span id="test">end</span>');
|
||||
},
|
||||
TEST_TIMEOUT,
|
||||
|
|
|
|||
Loading…
Reference in a new issue