test(cli): make AstronStudio path assertions portable

Signed-off-by: dongmucat <1127093059@qq.com>
This commit is contained in:
dongmucat 2026-09-09 11:29:38 +08:00
parent 0827094cac
commit 2ac57ff270
2 changed files with 11 additions and 9 deletions

View file

@ -53,21 +53,22 @@ describe('agent profiles', () => {
test('AstronStudio is detected only when the user .acode skills directory exists', async () => {
const home = await mkdtemp(join(tmpdir(), 'skillhub-astron-studio-home-'))
const profile = profileMap.get('astron-studio')!
const rootDir = join(home, '.acode', 'skills')
const nativeRootDir = join(home, '.acode', 'skills')
const profileRootDir = nativeRootDir.replace(/\\/g, '/')
try {
expect(await profile.detectInstalled('/repo', home)).toEqual([])
await mkdir(join(home, '.acode'), { recursive: true })
await writeFile(rootDir, 'not a directory')
await writeFile(nativeRootDir, 'not a directory')
expect(await profile.detectInstalled('/repo', home)).toEqual([])
await rm(rootDir)
await mkdir(rootDir, { recursive: true })
await rm(nativeRootDir)
await mkdir(nativeRootDir, { recursive: true })
expect(await profile.detectInstalled('/repo', home)).toEqual([{
agent: 'astron-studio',
rootDir,
rootDir: profileRootDir,
scope: 'user',
source: 'detected'
}])

View file

@ -37,10 +37,11 @@ const { resolveInstallTargets } = await import('../../../src/agents/resolver')
describe('resolveInstallTargets interactive prompt', () => {
test('renders AstronStudio by display name when its directory was detected', async () => {
const home = await mkdtemp(join(tmpdir(), 'skillhub-astron-studio-resolver-'))
const rootDir = join(home, '.acode', 'skills')
const nativeRootDir = join(home, '.acode', 'skills')
const profileRootDir = nativeRootDir.replace(/\\/g, '/')
try {
await mkdir(rootDir, { recursive: true })
await mkdir(nativeRootDir, { recursive: true })
await resolveInstallTargets({
cwd: '/repo',
home,
@ -50,7 +51,7 @@ describe('resolveInstallTargets interactive prompt', () => {
interactive: true
})
expect(renderedChoices[0]?.title).toBe(`AstronStudio (${rootDir})`)
expect(renderedChoices[0]?.title).toBe(`AstronStudio (${profileRootDir})`)
} finally {
await rm(home, { recursive: true, force: true })
}
@ -75,7 +76,7 @@ describe('resolveInstallTargets interactive prompt', () => {
expect(renderedChoices.some(choice => choice.value.agent === 'astron-studio')).toBe(false)
expect(targets).toEqual([{
agent: 'generic',
rootDir: join(home, '.agents', 'skills'),
rootDir: `${home}/.agents/skills`,
scope: 'user',
source: 'fallback'
}])