From b8cf7167e8d8796ebe62c63cf476772a5d6e899b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=91=98=E9=98=BF=E6=B1=9F=28Relakkes?= =?UTF-8?q?=29?= Date: Mon, 10 Aug 2026 18:35:24 +0800 Subject: [PATCH] test(adapters): isolate project boundary fixture --- .../common/__tests__/adapter-client.test.ts | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/adapters/common/__tests__/adapter-client.test.ts b/adapters/common/__tests__/adapter-client.test.ts index 0e5f164b..ea2eef5d 100644 --- a/adapters/common/__tests__/adapter-client.test.ts +++ b/adapters/common/__tests__/adapter-client.test.ts @@ -52,16 +52,22 @@ async function listedProjects( describe('createAdapterClient', () => { // The regression that started #1191, now pinned behaviourally rather than by // grepping the entrypoints. - it('keeps every project under home reachable when a default project is set', async () => { - const base = fs.mkdtempSync(path.join(HOME, '.cc-haha-test-')) - const outside = fs.mkdtempSync(path.join(os.tmpdir(), 'cc-haha-outside-')) + it('keeps every project under the allowed root reachable when a default project is set', async () => { + const sandbox = fs.mkdtempSync(path.join(os.tmpdir(), 'adapter-client-roots-')) + const allowedRoot = path.join(sandbox, 'allowed') + const outside = path.join(sandbox, 'outside') try { - const myApp = path.join(base, 'work', 'my-app') - const sibling = path.join(base, 'side', 'blog') - for (const dir of [myApp, sibling]) fs.mkdirSync(dir, { recursive: true }) + const myApp = path.join(allowedRoot, 'work', 'my-app') + const sibling = path.join(allowedRoot, 'side', 'blog') + for (const dir of [myApp, sibling, outside]) { + fs.mkdirSync(dir, { recursive: true }) + } for (const platform of PLATFORMS) { - const config = bootConfig({ defaultProjectDir: myApp }) + const config = bootConfig({ + defaultProjectDir: myApp, + allowedProjectRoots: [allowedRoot], + }) const { httpClient, defaultWorkDir } = createAdapterClient(config, config[platform]) expect(defaultWorkDir).toBe(fs.realpathSync(myApp)) @@ -73,8 +79,7 @@ describe('createAdapterClient', () => { expect(names).toEqual(['my-app', 'blog']) } } finally { - fs.rmSync(base, { recursive: true, force: true }) - fs.rmSync(outside, { recursive: true, force: true }) + fs.rmSync(sandbox, { recursive: true, force: true }) } })