@@ -109,4 +109,48 @@ describe('createSessionAwareTool', () => {
109109 expect ( result . content [ 0 ] . text ) . toContain ( 'Parameter validation failed' ) ;
110110 expect ( result . content [ 0 ] . text ) . toContain ( 'Tip: set session defaults' ) ;
111111 } ) ;
112+
113+ it ( 'exclusivePairs should prune conflicting session defaults when user provides null' , async ( ) => {
114+ const handlerWithExclusive = createSessionAwareTool < Params > ( {
115+ internalSchema,
116+ logicFunction : logic ,
117+ getExecutor : ( ) => createMockExecutor ( { success : true } ) ,
118+ requirements : [
119+ { allOf : [ 'scheme' ] , message : 'scheme is required' } ,
120+ { oneOf : [ 'projectPath' , 'workspacePath' ] , message : 'Provide a project or workspace' } ,
121+ ] ,
122+ exclusivePairs : [ [ 'projectPath' , 'workspacePath' ] ] ,
123+ } ) ;
124+
125+ sessionStore . setDefaults ( {
126+ scheme : 'App' ,
127+ projectPath : '/path/proj.xcodeproj' ,
128+ } ) ;
129+
130+ const res = await handlerWithExclusive ( { workspacePath : null as unknown as string } ) ;
131+ expect ( res . isError ) . toBe ( true ) ;
132+ expect ( res . content [ 0 ] . text ) . toContain ( 'Provide a project or workspace' ) ;
133+ } ) ;
134+
135+ it ( 'exclusivePairs should prune when user provides undefined (key present)' , async ( ) => {
136+ const handlerWithExclusive = createSessionAwareTool < Params > ( {
137+ internalSchema,
138+ logicFunction : logic ,
139+ getExecutor : ( ) => createMockExecutor ( { success : true } ) ,
140+ requirements : [
141+ { allOf : [ 'scheme' ] , message : 'scheme is required' } ,
142+ { oneOf : [ 'projectPath' , 'workspacePath' ] , message : 'Provide a project or workspace' } ,
143+ ] ,
144+ exclusivePairs : [ [ 'projectPath' , 'workspacePath' ] ] ,
145+ } ) ;
146+
147+ sessionStore . setDefaults ( {
148+ scheme : 'App' ,
149+ projectPath : '/path/proj.xcodeproj' ,
150+ } ) ;
151+
152+ const res = await handlerWithExclusive ( { workspacePath : undefined as unknown as string } ) ;
153+ expect ( res . isError ) . toBe ( true ) ;
154+ expect ( res . content [ 0 ] . text ) . toContain ( 'Provide a project or workspace' ) ;
155+ } ) ;
112156} ) ;
0 commit comments