@@ -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 ( / n o t f o u n d | 4 0 4 | d o e s n o t e x i s t / i)
533+ expect ( output ) . not . toMatch ( / u n a u t h o r i z e d / 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