@@ -669,7 +669,22 @@ describe('utils', () => {
669669 expect ( mainPanel ?. [ 'data-test-subj' ] ) . toBeUndefined ( ) ; // Main panel has no test ID by default
670670 } ) ;
671671
672- it ( 'should append staticItems after regular items in the main panel' , ( ) => {
672+ it ( 'should not show a separator when only static items are present' , ( ) => {
673+ const items : AppMenuPopoverItem [ ] = [ ] ;
674+ const staticItems : AppMenuPopoverItem [ ] = [
675+ { id : 'static1' , label : 'Static 1' , run : jest . fn ( ) , order : 1 } ,
676+ { id : 'static2' , label : 'Static 2' , run : jest . fn ( ) , order : 2 } ,
677+ ] ;
678+
679+ const panels = getPopoverPanels ( { items, staticItems } ) ;
680+
681+ expect ( panels ) . toHaveLength ( 1 ) ;
682+ const panelItems = panels [ 0 ] . items as Array < { key ?: string ; isSeparator ?: boolean } > ;
683+ expect ( panelItems [ 0 ] . isSeparator ) . not . toBe ( true ) ;
684+ expect ( panelItems . map ( ( i ) => i . key ) ) . toEqual ( [ 'static1' , 'static2' ] ) ;
685+ } ) ;
686+
687+ it ( 'should add a separator between regular and static items' , ( ) => {
673688 const items : AppMenuPopoverItem [ ] = [
674689 { id : '1' , label : 'Item 1' , run : jest . fn ( ) , order : 2 } ,
675690 { id : '2' , label : 'Item 2' , run : jest . fn ( ) , order : 1 } ,
@@ -681,9 +696,9 @@ describe('utils', () => {
681696 const panels = getPopoverPanels ( { items, staticItems } ) ;
682697
683698 expect ( panels ) . toHaveLength ( 1 ) ;
684- const panelItems = panels [ 0 ] . items as Array < { key ?: string } > ;
685- // Regular items sorted by order: Item 2 (order 1), Item 1 (order 2), then static
686- expect ( panelItems . map ( ( i ) => i . key ) ) . toEqual ( [ '2' , '1' , 'static1' ] ) ;
699+ const panelItems = panels [ 0 ] . items as Array < { key ?: string ; isSeparator ?: boolean } > ;
700+ expect ( panelItems . map ( ( i ) => i . key ) ) . toEqual ( [ '2' , '1' , ' static-items-separator' , 'static1' ] ) ;
701+ expect ( panelItems [ 2 ] . isSeparator ) . toBe ( true ) ;
687702 } ) ;
688703
689704 it ( 'should not re-sort staticItems together with regular items' , ( ) => {
@@ -854,27 +869,27 @@ describe('utils', () => {
854869 expect ( result . every ( ( item ) => item . overflow === true ) ) . toBe ( true ) ;
855870 } ) ;
856871
857- it ( 'should add separator "above" only to the first item ' , ( ) => {
872+ it ( 'should not add separator to items ' , ( ) => {
858873 const items = [
859874 createStaticItem ( { id : 'a' , order : 1 } ) ,
860875 createStaticItem ( { id : 'b' , order : 2 } ) ,
861876 createStaticItem ( { id : 'c' , order : 3 } ) ,
862877 ] ;
863878 const result = processStaticItems ( items ) ;
864879
865- expect ( result [ 0 ] . separator ) . toBe ( 'above' ) ;
880+ expect ( result [ 0 ] . separator ) . toBeUndefined ( ) ;
866881 expect ( result [ 1 ] . separator ) . toBeUndefined ( ) ;
867882 expect ( result [ 2 ] . separator ) . toBeUndefined ( ) ;
868883 } ) ;
869884
870- it ( 'should strip existing separator values from non-first items' , ( ) => {
885+ it ( 'should strip existing separator values from items' , ( ) => {
871886 const items = [
872887 createStaticItem ( { id : 'a' , order : 1 , separator : 'below' } ) ,
873888 createStaticItem ( { id : 'b' , order : 2 , separator : 'above' } ) ,
874889 ] ;
875890 const result = processStaticItems ( items ) ;
876891
877- expect ( result [ 0 ] . separator ) . toBe ( 'above' ) ;
892+ expect ( result [ 0 ] . separator ) . toBeUndefined ( ) ;
878893 expect ( result [ 1 ] . separator ) . toBeUndefined ( ) ;
879894 } ) ;
880895
@@ -889,15 +904,15 @@ describe('utils', () => {
889904 expect ( result . map ( ( item ) => item . id ) ) . toEqual ( [ 'a' , 'b' , 'c' ] ) ;
890905 } ) ;
891906
892- it ( 'should add separator "above" to the first item after sorting' , ( ) => {
907+ it ( 'should not add separator to the first item after sorting' , ( ) => {
893908 const items = [
894909 createStaticItem ( { id : 'c' , order : 3 } ) ,
895910 createStaticItem ( { id : 'a' , order : 1 } ) ,
896911 ] ;
897912 const result = processStaticItems ( items ) ;
898913
899914 expect ( result [ 0 ] . id ) . toBe ( 'a' ) ;
900- expect ( result [ 0 ] . separator ) . toBe ( 'above' ) ;
915+ expect ( result [ 0 ] . separator ) . toBeUndefined ( ) ;
901916 } ) ;
902917 } ) ;
903918} ) ;
0 commit comments