diff --git a/apps/electron-backend-e2e/src/performance/zoneless-migration.spec.ts b/apps/electron-backend-e2e/src/performance/zoneless-migration.spec.ts index c326c4a92..f9a67c9d7 100644 --- a/apps/electron-backend-e2e/src/performance/zoneless-migration.spec.ts +++ b/apps/electron-backend-e2e/src/performance/zoneless-migration.spec.ts @@ -12,9 +12,16 @@ import { fileURLToPath } from 'node:url'; const workspaceRoot = fileURLToPath(new URL('../../../../', import.meta.url)); const checklistPath = 'docs/architecture/zoneless-migration.md'; const sourceRoots = ['apps', 'libs']; -const skippedDirectories = new Set(['node_modules', 'dist', 'coverage']); -const testOnlyFile = - /(\.spec|\.spec-stubs|\.spec-data|\.test-helpers|test-setup)\.ts$/; +const skippedDirectories = new Set([ + 'node_modules', + 'dist', + 'coverage', + 'test-stubs', +]); +// Test-only files follow the repository's `.spec` / `.test` naming, with an +// optional suffix of one or more segments (`.spec-stubs.ts`, +// `.test-helpers.ts`, `.test-data-stubs.ts`). +const testOnlyFile = /(\.(spec|test)(-\w+)*|^test-setup)\.ts$/; function listProductionSources(directory: string): string[] { const files: string[] = []; @@ -78,6 +85,27 @@ test('the zoneless checklist lists exactly the components that are still Eager', ); }); +test('the guard skips test-only file names and keeps production ones', () => { + for (const name of [ + 'player.component.spec.ts', + 'serial-details.test-stubs.ts', + 'dashboard.spec-stubs.ts', + 'rail.test-data-stubs.ts', + 'test-setup.ts', + ]) { + assert.ok(testOnlyFile.test(name), `${name} is test-only`); + } + for (const name of [ + 'player.component.ts', + 'spec-utils.ts', + 'contest.ts', + 'latest-setup.ts', + 'testing.service.ts', + ]) { + assert.ok(!testOnlyFile.test(name), `${name} ships`); + } +}); + test('ticked checklist entries name files that exist', () => { for (const file of readEagerChecklist().done) { assert.ok(sources.has(file), `${file} is ticked but does not exist`); diff --git a/docs/architecture/zoneless-migration.md b/docs/architecture/zoneless-migration.md index 630d51ff2..84fdb1ede 100644 --- a/docs/architecture/zoneless-migration.md +++ b/docs/architecture/zoneless-migration.md @@ -153,8 +153,11 @@ files that still contain `ChangeDetectionStrategy.Eager`. - [ ] `libs/portal/xtream/feature/src/lib/global-search-results/global-search-results.component.ts` - [ ] `libs/portal/xtream/feature/src/lib/serial-details/serial-details.component.ts` -Test stubs that set Eager (`*.spec.ts`, `*.spec-stubs.ts`, `*.spec-data.ts`, -`*.test-helpers.ts`) are not listed; they do not ship. +Test-only files that set Eager are not listed; they do not ship. The guard +skips every `*.spec.ts` / `*.test.ts` file with or without a suffix of one +or more segments (`*.spec-stubs.ts`, `*.test-helpers.ts`, +`*.test-data-stubs.ts`, …), +`test-setup.ts` and `test-stubs/` directories. ## Zone-dependent sites