@@ -233,6 +233,118 @@ describe('resolveWizardNavigation', () => {
233233 ) ;
234234 } ) ;
235235
236+ describe ( 'selectAll' , ( ) => {
237+ it ( 'returns preselectedOptions with all option ids when selectAll is true and options exist' , async ( ) => {
238+ const selectAllConfig = {
239+ provider : 'selectall' ,
240+ steps : [
241+ {
242+ id : 'step1' ,
243+ title : 'Pick all' ,
244+ selectionType : 'multi-select' as const ,
245+ selectAll : true ,
246+ optionsSource : {
247+ type : 'static' as const ,
248+ values : [
249+ { id : 'opt1' , displayName : 'Option 1' } ,
250+ { id : 'opt2' , displayName : 'Option 2' } ,
251+ ] ,
252+ } ,
253+ } ,
254+ ] ,
255+ } ;
256+ const selectAllAdapter : ProviderAdapter = {
257+ config : selectAllConfig ,
258+ resolveOptions : mockResolveOptions ,
259+ evaluateCondition : mockEvaluateCondition ,
260+ } ;
261+ adapters . set ( 'selectall' , selectAllAdapter ) ;
262+
263+ try {
264+ const result = await resolveWizardNavigation (
265+ 'selectall' ,
266+ { } ,
267+ TEST_PROJECT_ID ,
268+ ) ;
269+ expect ( result . preselectedOptions ) . toEqual ( [ 'opt1' , 'opt2' ] ) ;
270+ } finally {
271+ adapters . delete ( 'selectall' ) ;
272+ }
273+ } ) ;
274+
275+ it ( 'returns preselectedOptions as undefined when selectAll is true but options are empty' , async ( ) => {
276+ const selectAllEmptyConfig = {
277+ provider : 'selectall-empty' ,
278+ steps : [
279+ {
280+ id : 'step1' ,
281+ title : 'Pick all' ,
282+ selectionType : 'multi-select' as const ,
283+ selectAll : true ,
284+ optionsSource : { type : 'dynamic' as const , method : 'listOptions' } ,
285+ } ,
286+ ] ,
287+ } ;
288+ mockResolveOptions . mockResolvedValue ( [ ] ) ;
289+ const selectAllEmptyAdapter : ProviderAdapter = {
290+ config : selectAllEmptyConfig ,
291+ resolveOptions : mockResolveOptions ,
292+ evaluateCondition : mockEvaluateCondition ,
293+ } ;
294+ adapters . set ( 'selectall-empty' , selectAllEmptyAdapter ) ;
295+
296+ try {
297+ const result = await resolveWizardNavigation (
298+ 'selectall-empty' ,
299+ { } ,
300+ TEST_PROJECT_ID ,
301+ ) ;
302+ expect ( result . preselectedOptions ) . toBeUndefined ( ) ;
303+ } finally {
304+ adapters . delete ( 'selectall-empty' ) ;
305+ }
306+ } ) ;
307+
308+ it ( 'returns preselectedOptions as undefined when selectAll is not set' , async ( ) => {
309+ const result = await resolveWizardNavigation ( 'test' , { } , TEST_PROJECT_ID ) ;
310+ expect ( result . preselectedOptions ) . toBeUndefined ( ) ;
311+ } ) ;
312+
313+ it ( 'throws a validation error when selectAll is true but selectionType is single' , async ( ) => {
314+ const invalidConfig = {
315+ provider : 'selectall-single' ,
316+ steps : [
317+ {
318+ id : 'step1' ,
319+ title : 'Pick one' ,
320+ selectionType : 'single' as const ,
321+ selectAll : true ,
322+ optionsSource : {
323+ type : 'static' as const ,
324+ values : [ { id : 'opt1' , displayName : 'Option 1' } ] ,
325+ } ,
326+ } ,
327+ ] ,
328+ } ;
329+
330+ const invalidAdapter : ProviderAdapter = {
331+ config : invalidConfig ,
332+ resolveOptions : mockResolveOptions ,
333+ evaluateCondition : mockEvaluateCondition ,
334+ } ;
335+
336+ adapters . set ( 'selectall-single' , invalidAdapter ) ;
337+
338+ try {
339+ await expect (
340+ resolveWizardNavigation ( 'selectall-single' , { } , TEST_PROJECT_ID ) ,
341+ ) . rejects . toThrow ( ) ;
342+ } finally {
343+ adapters . delete ( 'selectall-single' ) ;
344+ }
345+ } ) ;
346+ } ) ;
347+
236348 it ( 'throws when conditional step is not last step and onFailure.skipToStep is not set' , async ( ) => {
237349 mockEvaluateCondition . mockResolvedValue ( false ) ;
238350 const misconfigConfig = {
0 commit comments