From a5958c7bc3bc4ae976940aa420195843621432b9 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 26 Oct 2026 01:09:16 +0000 Subject: [PATCH] test(ui): give the whole-tree scratch-dir sweep bases it can read in three ui/ script tests The slow tier of `pnpm check:pm-dispatch-gates` runs only on push and schedule, and since the ui/ import it reads ui/ sources too. Two of its live-tree cases went red on three ui/ test files: - check-node-esm-load.test.ts binds `dir` to a temp directory in most tests and to `path.join(REPO_ROOT, 'packages/fields' | 'packages/auth')` in two. The sweep does not track scope and an in-tree reading wins, so every `mkdirSync(path.join(dir, ...))` read as a directory created in ui/packages/fields. The two package-reading tests now say `pkgDir`. - markdown-test-inputs.test.ts and select-affected-tests-wiring.test.ts declared `let scratch = ''` and assigned the real temp base in beforeAll. The empty literal read as a cwd-relative mkdtempSync base. They now declare `let scratch: string;`, so the one assignment is the only reading. No gate changes. Tests unchanged in behaviour (86/86). Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01HssnEmZ59WGARsErPSbRpf --- .../__tests__/check-node-esm-load.test.ts | 20 +++++++++---------- .../__tests__/markdown-test-inputs.test.ts | 2 +- .../select-affected-tests-wiring.test.ts | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ui/scripts/__tests__/check-node-esm-load.test.ts b/ui/scripts/__tests__/check-node-esm-load.test.ts index abd7789d44b..e8bb5f4306e 100644 --- a/ui/scripts/__tests__/check-node-esm-load.test.ts +++ b/ui/scripts/__tests__/check-node-esm-load.test.ts @@ -369,24 +369,24 @@ describe('the scope this gate ratchets, now that the emit question is answered', // sources — so nothing live left the leg with it. The sources keep a // STRICTER guard than this heuristic: that config pins `nodenext`, under // which a missing relative extension is TS2835 in the package's own build. - const dir = path.join(REPO_ROOT, 'packages/fields'); - const build = JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf8')).scripts.build; + const pkgDir = path.join(REPO_ROOT, 'packages/fields'); + const build = JSON.parse(fs.readFileSync(path.join(pkgDir, 'package.json'), 'utf8')).scripts.build; - expect(effectiveNoEmit(path.join(dir, 'tsconfig.json'))).toBe(true); - expect(buildPreservesSpecifiers(build, dir)).toBe(false); - expect(parseTsconfig(path.join(dir, 'tsconfig.json')).compilerOptions?.noEmit).toBeUndefined(); + expect(effectiveNoEmit(path.join(pkgDir, 'tsconfig.json'))).toBe(true); + expect(buildPreservesSpecifiers(build, pkgDir)).toBe(false); + expect(parseTsconfig(path.join(pkgDir, 'tsconfig.json')).compilerOptions?.noEmit).toBeUndefined(); }); it('keeps `@object-ui/auth` in the leg on its DECLARED noEmit, not on a catch', () => { // Its config throws under the old reader too, so it was in the leg by // accident. It declares `"noEmit": false` outright, so the verdict is // unchanged — what changes is that it is now a reading. - const dir = path.join(REPO_ROOT, 'packages/auth'); - const build = JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf8')).scripts.build; + const pkgDir = path.join(REPO_ROOT, 'packages/auth'); + const build = JSON.parse(fs.readFileSync(path.join(pkgDir, 'package.json'), 'utf8')).scripts.build; - expect(parseTsconfig(path.join(dir, 'tsconfig.json')).compilerOptions?.noEmit).toBe(false); - expect(effectiveNoEmit(path.join(dir, 'tsconfig.json'))).toBe(false); - expect(buildPreservesSpecifiers(build, dir)).toBe(true); + expect(parseTsconfig(path.join(pkgDir, 'tsconfig.json')).compilerOptions?.noEmit).toBe(false); + expect(effectiveNoEmit(path.join(pkgDir, 'tsconfig.json'))).toBe(false); + expect(buildPreservesSpecifiers(build, pkgDir)).toBe(true); }); }); diff --git a/ui/scripts/__tests__/markdown-test-inputs.test.ts b/ui/scripts/__tests__/markdown-test-inputs.test.ts index b1df81d761a..f351366b623 100644 --- a/ui/scripts/__tests__/markdown-test-inputs.test.ts +++ b/ui/scripts/__tests__/markdown-test-inputs.test.ts @@ -113,7 +113,7 @@ const [TYPE_CHECK_STEP, TEST_STEP, DIST_PINS_STEP, E2E_STEP] = STEPS; type Outcome = { shouldRun: string; log: string }; -let scratch = ''; +let scratch: string; function git(cwd: string, ...args: string[]): void { execFileSync('git', args, { cwd, stdio: 'pipe' }); diff --git a/ui/scripts/__tests__/select-affected-tests-wiring.test.ts b/ui/scripts/__tests__/select-affected-tests-wiring.test.ts index 6b7838c8e8c..e0c57e73e56 100644 --- a/ui/scripts/__tests__/select-affected-tests-wiring.test.ts +++ b/ui/scripts/__tests__/select-affected-tests-wiring.test.ts @@ -134,7 +134,7 @@ function parseOutputs(text: string): Record { return outputs; } -let scratch = ''; +let scratch: string; const nodeDir = path.dirname(process.execPath); /** Write an executable stand-in for `name` into a fresh bin directory. */