@@ -344,4 +344,42 @@ describe("Toolbar general interaction", () => {
344344 . eq ( 0 )
345345 . should ( "not.have.attr" , "selected" ) ;
346346 } ) ;
347+
348+ it ( "Should ensure only one option is selected at any time" , ( ) => {
349+ cy . mount (
350+ < >
351+ < Toolbar >
352+ < ToolbarSelect >
353+ < ToolbarSelectOption id = "opt1" > 1</ ToolbarSelectOption >
354+ < ToolbarSelectOption id = "opt2" > 2</ ToolbarSelectOption >
355+ < ToolbarSelectOption id = "opt3" > 3</ ToolbarSelectOption >
356+ </ ToolbarSelect >
357+ </ Toolbar >
358+ < Button id = "selectMultiple" > Select Multiple</ Button >
359+ </ >
360+ ) ;
361+
362+ // Set up button to attempt selecting multiple options
363+ cy . get ( "#selectMultiple" ) . then ( $btn => {
364+ $btn . get ( 0 ) . addEventListener ( "ui5-click" , ( ) => {
365+ const opt1 = document . getElementById ( "opt1" ) as ToolbarSelectOption ;
366+ const opt2 = document . getElementById ( "opt2" ) as ToolbarSelectOption ;
367+ const opt3 = document . getElementById ( "opt3" ) as ToolbarSelectOption ;
368+
369+ // Try to select multiple options
370+ opt1 . selected = true ;
371+ opt2 . selected = true ;
372+ opt3 . selected = true ; // This should be the final selection
373+ } ) ;
374+ } ) ;
375+
376+ // Click button to attempt multiple selections
377+ cy . get ( "#selectMultiple" ) . realClick ( ) ;
378+
379+ // Verify only the last option (opt3) is selected
380+ cy . get ( "[ui5-toolbar-select-option]" ) . eq ( 2 ) . should ( "have.attr" , "selected" ) ;
381+ cy . get ( "[ui5-toolbar-select-option]" ) . eq ( 0 ) . should ( "not.have.attr" , "selected" ) ;
382+ cy . get ( "[ui5-toolbar-select-option]" ) . eq ( 1 ) . should ( "not.have.attr" , "selected" ) ;
383+ cy . get ( "ui5-select" , { includeShadowDom : true } ) . should ( "have.attr" , "value" , "3" ) ;
384+ } ) ;
347385} ) ;
0 commit comments