refactor(platform-server): split zone/zoneless tests.

The Zone tests are a subset of tests that we still using the Zone CD provider.
This commit is contained in:
Matthieu Riegler
2026-02-13 09:41:10 -08:00
committed by Matthew Beck (Berry)
parent 63d8005703
commit 08ea105aa3
5 changed files with 729 additions and 705 deletions
+12 -5
View File
@@ -29,12 +29,21 @@ import {performanceMarkFeature} from '../util/performance';
import {NgZone} from '../zone';
import {withEventReplay} from './event_replay';
import {
ChangeDetectionScheduler,
NotificationSource,
} from '../change_detection/scheduling/zoneless_scheduling';
import {DEHYDRATED_BLOCK_REGISTRY, DehydratedBlockRegistry} from '../defer/registry';
import {processAndInitTriggers} from '../defer/triggering';
import {DOCUMENT} from '../document';
import {DOC_PAGE_BASE_URL} from '../error_details_base_url';
import {cleanupDehydratedViews} from './cleanup';
import {
enableClaimDehydratedIcuCaseImpl,
enablePrepareI18nBlockForHydrationImpl,
setIsI18nHydrationSupportEnabled,
} from './i18n';
import {gatherDeferBlocksCommentNodes} from './node_lookup_utils';
import {
IS_HYDRATION_DOM_REUSE_ENABLED,
IS_I18N_HYDRATION_ENABLED,
@@ -52,11 +61,6 @@ import {
verifySsrContentsIntegrity,
} from './utils';
import {enableFindMatchingDehydratedViewImpl} from './views';
import {DEHYDRATED_BLOCK_REGISTRY, DehydratedBlockRegistry} from '../defer/registry';
import {gatherDeferBlocksCommentNodes} from './node_lookup_utils';
import {processAndInitTriggers} from '../defer/triggering';
import {DOCUMENT} from '../document';
import {DOC_PAGE_BASE_URL} from '../error_details_base_url';
/**
* Indicates whether the hydration-related code was added,
@@ -277,6 +281,7 @@ export function withDomHydration(): EnvironmentProviders {
{
provide: APP_BOOTSTRAP_LISTENER,
useFactory: () => {
const scheduler = inject(ChangeDetectionScheduler);
if (inject(IS_HYDRATION_DOM_REUSE_ENABLED)) {
const appRef = inject(ApplicationRef);
@@ -304,6 +309,8 @@ export function withDomHydration(): EnvironmentProviders {
countBlocksSkippedByHydration(appRef.injector);
printHydrationStats(appRef.injector);
}
// We need to schedule the execution of the render hooks because the hydration cleanup alters the DOM.
scheduler.notify(NotificationSource.RenderHook);
});
};
}
+3 -2
View File
@@ -1,4 +1,4 @@
load("//tools:defaults.bzl", "angular_jasmine_test", "ts_project")
load("//tools:defaults.bzl", "angular_jasmine_test", "ts_project", "zoneless_jasmine_test")
ts_project(
name = "dom_utils",
@@ -65,6 +65,7 @@ ts_project(
],
)
# This target is meant to run with Zone.js as some test cases are shared between Zone & Zoneless.
angular_jasmine_test(
name = "test",
data = [
@@ -73,7 +74,7 @@ angular_jasmine_test(
],
)
angular_jasmine_test(
zoneless_jasmine_test(
name = "event_replay_test",
data = [
":event_replay_test_lib",
File diff suppressed because it is too large Load Diff
@@ -10,25 +10,38 @@ import {
APP_ID,
ApplicationRef,
Component,
ɵDEHYDRATED_BLOCK_REGISTRY as DEHYDRATED_BLOCK_REGISTRY,
destroyPlatform,
ɵgetDocument as getDocument,
inject,
Input,
NgZone,
ɵJSACTION_BLOCK_ELEMENT_MAP as JSACTION_BLOCK_ELEMENT_MAP,
ɵJSACTION_EVENT_CONTRACT as JSACTION_EVENT_CONTRACT,
PendingTasks,
PLATFORM_ID,
Provider,
QueryList,
ɵresetIncrementalHydrationEnabledWarnedForTests as resetIncrementalHydrationEnabledWarnedForTests,
signal,
ɵTimerScheduler as TimerScheduler,
ViewChildren,
ɵDEFER_BLOCK_DEPENDENCY_INTERCEPTOR,
ɵDEHYDRATED_BLOCK_REGISTRY as DEHYDRATED_BLOCK_REGISTRY,
ɵJSACTION_BLOCK_ELEMENT_MAP as JSACTION_BLOCK_ELEMENT_MAP,
ɵJSACTION_EVENT_CONTRACT as JSACTION_EVENT_CONTRACT,
ɵgetDocument as getDocument,
ɵresetIncrementalHydrationEnabledWarnedForTests as resetIncrementalHydrationEnabledWarnedForTests,
ɵTimerScheduler as TimerScheduler,
provideZoneChangeDetection,
} from '@angular/core';
import {
isPlatformServer,
Location,
ɵPLATFORM_BROWSER_ID as PLATFORM_BROWSER_ID,
PlatformLocation,
} from '@angular/common';
import {MockPlatformLocation} from '@angular/common/testing';
import {TestBed} from '@angular/core/testing';
import {
provideClientHydration,
withEventReplay,
withIncrementalHydration,
} from '@angular/platform-browser';
import {provideRouter, RouterLink, RouterOutlet, Routes} from '@angular/router';
import {getAppContents, prepareEnvironmentAndHydrate, resetTViewsFor} from './dom_utils';
import {
clearConsole,
@@ -41,20 +54,6 @@ import {
verifyNodeWasNotHydrated,
withDebugConsole,
} from './hydration_utils';
import {
isPlatformServer,
Location,
PlatformLocation,
ɵPLATFORM_BROWSER_ID as PLATFORM_BROWSER_ID,
} from '@angular/common';
import {
provideClientHydration,
withEventReplay,
withIncrementalHydration,
} from '@angular/platform-browser';
import {TestBed} from '@angular/core/testing';
import {provideRouter, RouterLink, RouterOutlet, Routes} from '@angular/router';
import {MockPlatformLocation} from '@angular/common/testing';
/**
* Emulates a dynamic import promise.
@@ -1410,7 +1409,6 @@ describe('platform-server partial hydration integration', () => {
): number => {
onIdleCallbackQueue.set(id, callback);
expect(idleCallbacksRequested).toBe(0);
expect(NgZone.isInAngularZone()).toBe(true);
idleCallbacksRequested++;
return id++;
};
@@ -1469,10 +1467,7 @@ describe('platform-server partial hydration integration', () => {
}
const appId = 'custom-app-id';
const providers = [
{provide: APP_ID, useValue: appId},
provideZoneChangeDetection() as any,
];
const providers = [{provide: APP_ID, useValue: appId}];
const hydrationFeatures = () => [withIncrementalHydration()];
const html = await ssr(SimpleComponent, {envProviders: providers, hydrationFeatures});
@@ -2062,10 +2057,18 @@ describe('platform-server partial hydration integration', () => {
this.value.set('end');
}
registry = inject(DEHYDRATED_BLOCK_REGISTRY);
constructor() {
// TODO: Understand why this is needed to get the full rendering of the HTML
// Without it, bindings aren't properly rendered in SSR and the test fails.
// There was no issue with the zone based scheduler.
const remove = inject(PendingTasks).add();
setTimeout(() => remove(), 10);
}
}
const appId = 'custom-app-id';
const providers = [{provide: APP_ID, useValue: appId}, provideZoneChangeDetection() as any];
const providers = [{provide: APP_ID, useValue: appId}];
const hydrationFeatures = () => [withIncrementalHydration()];
const html = await ssr(SimpleComponent, {envProviders: providers, hydrationFeatures});
File diff suppressed because it is too large Load Diff