11import { describe , expect , it , vi } from 'vitest' ;
22import { handleCommandsAvailable } from './commands-available.js' ;
3- import { DEFAULT_SLASH_COMMANDS } from '../../shared/default- slash-commands.generated ' ;
3+ import { commandsOrDefault } from '../../shared/slash-commands.js ' ;
44
55const silentLogger = { info : ( ) => { } , warn : ( ) => { } } ;
66
@@ -18,10 +18,13 @@ describe('handleCommandsAvailable', () => {
1818 ) ;
1919
2020 expect ( setAvailableCommands ) . toHaveBeenCalledTimes ( 1 ) ;
21- expect ( setAvailableCommands ) . toHaveBeenCalledWith ( [
22- { name : 'review' , description : 'Review' , hints : [ ] } ,
23- { name : 'init' , hints : [ '$ARGUMENTS' ] , source : 'command' } ,
24- ] ) ;
21+ expect ( setAvailableCommands ) . toHaveBeenCalledWith (
22+ expect . arrayContaining ( [
23+ expect . objectContaining ( { name : 'review' , description : 'Review' , hints : [ ] } ) ,
24+ expect . objectContaining ( { name : 'init' , hints : [ '$ARGUMENTS' ] , source : 'command' } ) ,
25+ { name : 'compact' , description : 'compact the current session context' , hints : [ ] } ,
26+ ] )
27+ ) ;
2528 } ) ;
2629
2730 it ( 'drops items missing a name without rejecting the whole event' , async ( ) => {
@@ -31,7 +34,12 @@ describe('handleCommandsAvailable', () => {
3134 { setAvailableCommands, logger : silentLogger }
3235 ) ;
3336
34- expect ( setAvailableCommands ) . toHaveBeenCalledWith ( [ { name : 'ok' , hints : [ ] } ] ) ;
37+ expect ( setAvailableCommands ) . toHaveBeenCalledWith (
38+ expect . arrayContaining ( [
39+ expect . objectContaining ( { name : 'ok' , hints : [ ] } ) ,
40+ { name : 'compact' , description : 'compact the current session context' , hints : [ ] } ,
41+ ] )
42+ ) ;
3543 } ) ;
3644
3745 it ( 'warns and skips when commands array is missing' , async ( ) => {
@@ -60,7 +68,7 @@ describe('handleCommandsAvailable', () => {
6068 await handleCommandsAvailable ( { commands : [ ] } , { setAvailableCommands, logger : silentLogger } ) ;
6169
6270 expect ( setAvailableCommands ) . toHaveBeenCalledTimes ( 1 ) ;
63- expect ( setAvailableCommands ) . toHaveBeenCalledWith ( DEFAULT_SLASH_COMMANDS ) ;
71+ expect ( setAvailableCommands ) . toHaveBeenCalledWith ( commandsOrDefault ( undefined ) ) ;
6472 } ) ;
6573
6674 it ( 'persists defaults when all items fail validation' , async ( ) => {
@@ -71,6 +79,6 @@ describe('handleCommandsAvailable', () => {
7179 ) ;
7280
7381 expect ( setAvailableCommands ) . toHaveBeenCalledTimes ( 1 ) ;
74- expect ( setAvailableCommands ) . toHaveBeenCalledWith ( DEFAULT_SLASH_COMMANDS ) ;
82+ expect ( setAvailableCommands ) . toHaveBeenCalledWith ( commandsOrDefault ( undefined ) ) ;
7583 } ) ;
7684} ) ;
0 commit comments