@@ -350,4 +350,53 @@ describe('utils/fs/glob', () => {
350350 expect ( result ) . toEqual ( [ '**/node_modules' , '**/dist' ] )
351351 } )
352352 } )
353+
354+ describe ( 'getWorkspaceGlobs' , ( ) => {
355+ it ( 'reads pnpm-workspace.yaml packages list for PNPM agent (lines 49-56)' , async ( ) => {
356+ const { safeReadFile } = vi . mocked ( await import ( '@socketsecurity/lib/fs' ) )
357+ safeReadFile . mockResolvedValueOnce (
358+ 'packages:\n - "packages/*"\n - "apps/*"\n' ,
359+ )
360+ const { getWorkspaceGlobs } = await import (
361+ '../../../../src/utils/fs/glob.mts'
362+ )
363+ const result = await getWorkspaceGlobs ( 'pnpm' , '/repo' )
364+ // Workspace patterns are converted to glob form ("packages/*" → "packages/*/").
365+ expect ( Array . isArray ( result ) ) . toBe ( true )
366+ expect ( result . length ) . toBeGreaterThan ( 0 )
367+ } )
368+
369+ it ( 'returns empty array when pnpm-workspace.yaml is missing' , async ( ) => {
370+ const { safeReadFile } = vi . mocked ( await import ( '@socketsecurity/lib/fs' ) )
371+ safeReadFile . mockResolvedValueOnce ( undefined as any )
372+ const { getWorkspaceGlobs } = await import (
373+ '../../../../src/utils/fs/glob.mts'
374+ )
375+ const result = await getWorkspaceGlobs ( 'pnpm' , '/repo' )
376+ expect ( result ) . toEqual ( [ ] )
377+ } )
378+
379+ it ( 'returns empty array when pnpm-workspace.yaml is malformed' , async ( ) => {
380+ const { safeReadFile } = vi . mocked ( await import ( '@socketsecurity/lib/fs' ) )
381+ safeReadFile . mockResolvedValueOnce ( 'this is not :::valid::: yaml{{{' )
382+ const { getWorkspaceGlobs } = await import (
383+ '../../../../src/utils/fs/glob.mts'
384+ )
385+ const result = await getWorkspaceGlobs ( 'pnpm' , '/repo' )
386+ expect ( result ) . toEqual ( [ ] )
387+ } )
388+ } )
389+
390+ describe ( 'globWorkspace' , ( ) => {
391+ it ( 'returns empty array when no workspace globs (line 299-300)' , async ( ) => {
392+ const { safeReadFile } = vi . mocked ( await import ( '@socketsecurity/lib/fs' ) )
393+ // pnpm-workspace.yaml missing → empty workspaceGlobs → early-return [].
394+ safeReadFile . mockResolvedValueOnce ( undefined as any )
395+ const { globWorkspace } = await import (
396+ '../../../../src/utils/fs/glob.mts'
397+ )
398+ const result = await globWorkspace ( 'pnpm' , '/nonexistent/repo' )
399+ expect ( result ) . toEqual ( [ ] )
400+ } )
401+ } )
353402} )
0 commit comments