@@ -515,6 +515,110 @@ describe('Custom actions', () => {
515515 } ) ;
516516} ) ;
517517
518+ describe ( 'Custom primary actions' , ( ) => {
519+ test ( 'renders custom primary actions instead of default buttons' , ( ) => {
520+ const customActions = (
521+ < >
522+ < Button data-testid = "custom-cancel" > Custom Cancel</ Button >
523+ < Button data-testid = "custom-next" variant = "primary" >
524+ Custom Next
525+ </ Button >
526+ </ >
527+ ) ;
528+ const [ wrapper ] = renderDefaultWizard ( { customPrimaryActions : customActions } ) ;
529+
530+ expect ( wrapper . findPrimaryButton ( ) ) . toBeNull ( ) ;
531+ expect ( wrapper . findCancelButton ( ) ) . toBeNull ( ) ;
532+ expect ( wrapper . findPreviousButton ( ) ) . toBeNull ( ) ;
533+ expect ( wrapper . findActions ( ) ! . findButton ( '[data-testid="custom-cancel"]' ) ) . not . toBeNull ( ) ;
534+ expect ( wrapper . findActions ( ) ! . findButton ( '[data-testid="custom-next"]' ) ) . not . toBeNull ( ) ;
535+ } ) ;
536+
537+ test ( 'custom primary actions work on first step' , ( ) => {
538+ const onCustomClick = jest . fn ( ) ;
539+ const customActions = (
540+ < Button data-testid = "custom-action" onClick = { onCustomClick } >
541+ Custom Action
542+ </ Button >
543+ ) ;
544+
545+ const [ wrapper ] = renderDefaultWizard ( {
546+ customPrimaryActions : customActions ,
547+ activeStepIndex : 0 ,
548+ } ) ;
549+
550+ const customActionButtonWrapper = wrapper . findActions ( ) ! . findButton ( '[data-testid="custom-action"]' ) ;
551+ expect ( customActionButtonWrapper ) . not . toBeNull ( ) ;
552+ customActionButtonWrapper ! . click ( ) ;
553+ expect ( onCustomClick ) . toHaveBeenCalledTimes ( 1 ) ;
554+ } ) ;
555+
556+ test ( 'custom primary actions work on middle step' , ( ) => {
557+ const onCustomClick = jest . fn ( ) ;
558+ const customActions = (
559+ < Button data-testid = "custom-action" onClick = { onCustomClick } >
560+ Custom Action
561+ </ Button >
562+ ) ;
563+
564+ const [ wrapper ] = renderDefaultWizard ( {
565+ customPrimaryActions : customActions ,
566+ activeStepIndex : 1 ,
567+ } ) ;
568+
569+ const customActionButtonWrapper = wrapper . findActions ( ) ! . findButton ( '[data-testid="custom-action"]' ) ;
570+ expect ( customActionButtonWrapper ) . not . toBeNull ( ) ;
571+ customActionButtonWrapper ! . click ( ) ;
572+ expect ( onCustomClick ) . toHaveBeenCalledTimes ( 1 ) ;
573+ } ) ;
574+
575+ test ( 'custom primary actions work on last step' , ( ) => {
576+ const onCustomClick = jest . fn ( ) ;
577+ const customActions = (
578+ < Button data-testid = "custom-action" onClick = { onCustomClick } >
579+ Custom Action
580+ </ Button >
581+ ) ;
582+
583+ const [ wrapper ] = renderDefaultWizard ( {
584+ customPrimaryActions : customActions ,
585+ activeStepIndex : DEFAULT_STEPS . length - 1 ,
586+ } ) ;
587+
588+ const customActionButtonWrapper = wrapper . findActions ( ) ! . findButton ( '[data-testid="custom-action"]' ) ;
589+ expect ( customActionButtonWrapper ) . not . toBeNull ( ) ;
590+ customActionButtonWrapper ! . click ( ) ;
591+ expect ( onCustomClick ) . toHaveBeenCalledTimes ( 1 ) ;
592+ } ) ;
593+
594+ test ( 'custom primary actions override skip-to button' , ( ) => {
595+ const customActions = < Button > Custom Only</ Button > ;
596+ const [ wrapper ] = renderDefaultWizard ( {
597+ customPrimaryActions : customActions ,
598+ allowSkipTo : true ,
599+ } ) ;
600+
601+ expect ( wrapper . findSkipToButton ( ) ) . toBeNull ( ) ;
602+ expect ( wrapper . findActions ( ) ! . findButton ( ) ! . getElement ( ) ) . toHaveTextContent ( 'Custom Only' ) ;
603+ } ) ;
604+
605+ test ( 'falls back to default actions when customPrimaryActions is null' , ( ) => {
606+ const [ wrapper ] = renderDefaultWizard ( { customPrimaryActions : null } ) ;
607+
608+ expect ( wrapper . findPrimaryButton ( ) ) . not . toBeNull ( ) ;
609+ expect ( wrapper . findCancelButton ( ) ) . not . toBeNull ( ) ;
610+ expect ( wrapper . findPrimaryButton ( ) . getElement ( ) ) . toHaveTextContent ( DEFAULT_I18N_SETS [ 0 ] . nextButton ! ) ;
611+ } ) ;
612+
613+ test ( 'falls back to default actions when customPrimaryActions is undefined' , ( ) => {
614+ const [ wrapper ] = renderDefaultWizard ( { customPrimaryActions : undefined } ) ;
615+
616+ expect ( wrapper . findPrimaryButton ( ) ) . not . toBeNull ( ) ;
617+ expect ( wrapper . findCancelButton ( ) ) . not . toBeNull ( ) ;
618+ expect ( wrapper . findPrimaryButton ( ) . getElement ( ) ) . toHaveTextContent ( DEFAULT_I18N_SETS [ 0 ] . nextButton ! ) ;
619+ } ) ;
620+ } ) ;
621+
518622describe ( 'i18n' , ( ) => {
519623 test ( 'supports rendering static strings using i18n provider' , ( ) => {
520624 const { container } = render (
0 commit comments