Skip to content

Commit 5d95c44

Browse files
author
Jarvis
committed
test: add e2e test for delete error handling
Verifies that deleting a non-existent skill returns a proper 'not found' error instead of a generic 'Unauthorized' message.
1 parent f1a5254 commit 5d95c44

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

e2e/clawdhub.e2e.test.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,4 +491,49 @@ describe('clawdhub e2e', () => {
491491
await rm(cfg.dir, { recursive: true, force: true })
492492
}
493493
}, 180_000)
494+
495+
it('delete returns proper error for non-existent skill', async () => {
496+
const registry = process.env.CLAWDHUB_REGISTRY?.trim() || 'https://clawdhub.com'
497+
const site = process.env.CLAWDHUB_SITE?.trim() || 'https://clawdhub.com'
498+
const token = mustGetToken() ?? (await readGlobalConfig())?.token ?? null
499+
if (!token) {
500+
throw new Error('Missing token. Set CLAWDHUB_E2E_TOKEN or run: bun clawdhub auth login')
501+
}
502+
503+
const cfg = await makeTempConfig(registry, token)
504+
const workdir = await mkdtemp(join(tmpdir(), 'clawdhub-e2e-delete-'))
505+
const nonExistentSlug = `non-existent-skill-${Date.now()}`
506+
507+
try {
508+
const del = spawnSync(
509+
'bun',
510+
[
511+
'clawdhub',
512+
'delete',
513+
nonExistentSlug,
514+
'--yes',
515+
'--site',
516+
site,
517+
'--registry',
518+
registry,
519+
'--workdir',
520+
workdir,
521+
],
522+
{
523+
cwd: process.cwd(),
524+
env: { ...process.env, CLAWDHUB_CONFIG_PATH: cfg.path, CLAWDHUB_DISABLE_TELEMETRY: '1' },
525+
encoding: 'utf8',
526+
},
527+
)
528+
// Should fail with non-zero exit code
529+
expect(del.status).not.toBe(0)
530+
// Error should mention "not found" - not generic "Unauthorized"
531+
const output = (del.stdout + del.stderr).toLowerCase()
532+
expect(output).toMatch(/not found|404|does not exist/i)
533+
expect(output).not.toMatch(/unauthorized/i)
534+
} finally {
535+
await rm(workdir, { recursive: true, force: true })
536+
await rm(cfg.dir, { recursive: true, force: true })
537+
}
538+
}, 30_000)
494539
})

0 commit comments

Comments
 (0)