From f0e6281175e45b16bb5c9c8796d942d58d35c93e Mon Sep 17 00:00:00 2001 From: 4gray Date: Mon, 5 Oct 2026 22:06:20 +0200 Subject: [PATCH] test(performance): accept multi-segment test-only suffixes in the zoneless guard Review follow-up (Greptile): `(-\w+)?` allowed one suffix segment, so a file such as `rail.test-data-stubs.ts` would be scanned as production. The suffix now repeats, and a classifier test pins which names are skipped and which ship. Co-Authored-By: Claude Opus 5.5 --- .../performance/zoneless-migration.spec.ts | 26 +++++++++++++++++-- docs/architecture/zoneless-migration.md | 5 ++-- 2 files changed, 27 insertions(+), 4 deletions(-) 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 dd6607fda..f9a67c9d7 100644 --- a/apps/electron-backend-e2e/src/performance/zoneless-migration.spec.ts +++ b/apps/electron-backend-e2e/src/performance/zoneless-migration.spec.ts @@ -19,8 +19,9 @@ const skippedDirectories = new Set([ 'test-stubs', ]); // Test-only files follow the repository's `.spec` / `.test` naming, with an -// optional suffix (`.spec-stubs.ts`, `.test-helpers.ts`, `.test-stubs.ts`). -const testOnlyFile = /(\.(spec|test)(-[\w]+)?|^test-setup)\.ts$/; +// 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[] = []; @@ -84,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 fdf973bcd..84fdb1ede 100644 --- a/docs/architecture/zoneless-migration.md +++ b/docs/architecture/zoneless-migration.md @@ -154,8 +154,9 @@ files that still contain `ChangeDetectionStrategy.Eager`. - [ ] `libs/portal/xtream/feature/src/lib/serial-details/serial-details.component.ts` 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 -(`*.spec-stubs.ts`, `*.test-helpers.ts`, `*.test-stubs.ts`, …), +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