@@ -11,6 +11,7 @@ import ToggleButton from "@ui5/webcomponents/dist/ToggleButton.js";
1111import ListItemStandard from "@ui5/webcomponents/dist/ListItemStandard.js" ;
1212import Avatar from "@ui5/webcomponents/dist/Avatar.js" ;
1313import Switch from "@ui5/webcomponents/dist/Switch.js" ;
14+ import Search from "../../src/Search.js" ;
1415
1516const RESIZE_THROTTLE_RATE = 300 ; // ms
1617
@@ -324,13 +325,13 @@ describe("Slots", () => {
324325 function assertStartSeparatorVisibility ( expectedExist : boolean ) {
325326 cy . get ( "#shellbar" )
326327 . shadow ( )
327- . find ( ".ui5-shellbar-overflow-container-right-inner > .ui5-shellbar-separator-start" )
328+ . find ( ".ui5-shellbar-content-items > .ui5-shellbar-separator-start" )
328329 . should ( expectedExist ? "exist" : "not.exist" ) ;
329330 }
330331 function assertEndSeparatorVisibility ( expectedExist : boolean ) {
331332 cy . get ( "#shellbar" )
332333 . shadow ( )
333- . find ( ".ui5-shellbar-overflow-container-right-inner > .ui5-shellbar-separator-end" )
334+ . find ( ".ui5-shellbar-content-items > .ui5-shellbar-separator-end" )
334335 . should ( expectedExist ? "exist" : "not.exist" ) ;
335336 }
336337
@@ -390,4 +391,136 @@ describe("Slots", () => {
390391 . should ( "not.exist" ) ;
391392 } ) ;
392393 } ) ;
394+
395+ describe ( "Search field slot" , ( ) => {
396+ it ( "Test search button is not visible when the search field slot is empty" , ( ) => {
397+ cy . mount (
398+ < ShellBar id = "shellbar" > </ ShellBar >
399+ ) ;
400+ cy . get ( "#shellbar" )
401+ . shadow ( )
402+ . find ( ".ui5-shellbar-search-button" )
403+ . should ( "not.exist" ) ;
404+ } ) ;
405+
406+ it ( "Test search button is visible when the search field slot is not empty" , ( ) => {
407+ cy . mount (
408+ < ShellBar id = "shellbar" >
409+ < Input slot = "searchField" > </ Input >
410+ </ ShellBar >
411+ ) ;
412+ cy . get ( "#shellbar" )
413+ . shadow ( )
414+ . find ( ".ui5-shellbar-search-button" )
415+ . should ( "exist" ) ;
416+ } ) ;
417+
418+ it ( "Test search button is not visible when the hide-search-button property is set to true" , ( ) => {
419+ cy . mount (
420+ < ShellBar id = "shellbar" hideSearchButton = { true } >
421+ < Input slot = "searchField" > </ Input >
422+ </ ShellBar >
423+ ) ;
424+ cy . get ( "#shellbar" )
425+ . shadow ( )
426+ . find ( ".ui5-shellbar-search-button" )
427+ . should ( "not.exist" ) ;
428+ } ) ;
429+
430+ it ( "Test search field is collapsed by default and expanded on click" , ( ) => {
431+ cy . mount (
432+ < ShellBar id = "shellbar" >
433+ < Input slot = "searchField" > </ Input >
434+ </ ShellBar >
435+ ) ;
436+ cy . get ( "#shellbar" ) . shadow ( ) . as ( "shellbar" ) ;
437+ cy . get ( "@shellbar" ) . find ( ".ui5-shellbar-search-field" ) . should ( "not.exist" ) ;
438+ cy . get ( "@shellbar" ) . find ( ".ui5-shellbar-search-button" ) . click ( ) ;
439+ cy . get ( "@shellbar" ) . find ( ".ui5-shellbar-search-field" ) . should ( "exist" ) ;
440+ } ) ;
441+
442+ it ( "Test search field is expanded by default when show-search-field is set to true" , ( ) => {
443+ cy . mount (
444+ < ShellBar id = "shellbar" showSearchField = { true } >
445+ < Input slot = "searchField" > </ Input >
446+ </ ShellBar >
447+ ) ;
448+ cy . get ( "#shellbar" )
449+ . shadow ( )
450+ . find ( ".ui5-shellbar-search-field" )
451+ . should ( "exist" ) ;
452+ } ) ;
453+
454+ it ( "Test search button is not visible when a self-collapsible search field slot is empty" , ( ) => {
455+ cy . mount (
456+ < ShellBar id = "shellbar" >
457+ < Search slot = "searchField" > </ Search >
458+ </ ShellBar >
459+ ) ;
460+ cy . get ( "#shellbar" )
461+ . shadow ( )
462+ . find ( ".ui5-shellbar-search-button" )
463+ . should ( "not.exist" ) ;
464+ } ) ;
465+
466+ it ( "Test self-collapsible search is expanded and collapsed by the show-search-field property" , ( ) => {
467+ cy . mount (
468+ < ShellBar id = "shellbar" showSearchField = { true } >
469+ < Search id = "search" slot = "searchField" > </ Search >
470+ </ ShellBar >
471+ ) ;
472+ cy . get ( "#search" ) . should ( "have.prop" , "collapsed" , false ) ;
473+ cy . get ( "#shellbar" ) . invoke ( "prop" , "showSearchField" , false ) ;
474+ cy . get ( "#search" ) . should ( "have.prop" , "collapsed" , true ) ;
475+ } ) ;
476+
477+
478+ it ( "Test showSearchField property is true when using expanded search field" , ( ) => {
479+ cy . mount (
480+ < ShellBar id = "shellbar" >
481+ < Search id = "search" slot = "searchField" > </ Search >
482+ </ ShellBar >
483+ ) ;
484+ cy . get ( "#search" ) . should ( "have.prop" , "collapsed" , false ) ;
485+ cy . get ( "#shellbar" ) . invoke ( "prop" , "showSearchField" ) . should ( "equal" , true ) ;
486+ } ) ;
487+
488+ it ( "Test showSearchField property is false when using collapsed search field" , ( ) => {
489+ cy . mount (
490+ < ShellBar id = "shellbar" >
491+ < Search id = "search" slot = "searchField" collapsed > </ Search >
492+ </ ShellBar >
493+ ) ;
494+ cy . get ( "#search" ) . should ( "have.prop" , "collapsed" , true ) ;
495+ cy . get ( "#shellbar" ) . invoke ( "prop" , "showSearchField" ) . should ( "equal" , false ) ;
496+ } ) ;
497+ } ) ;
393498} ) ;
499+
500+ describe ( "Events" , ( ) => {
501+ it ( "Test click on the search button fires search-button-click event" , ( ) => {
502+ cy . mount (
503+ < ShellBar >
504+ < Input slot = "searchField" > </ Input >
505+ </ ShellBar >
506+ ) ;
507+ cy . get ( "[ui5-shellbar" )
508+ . as ( "shellbar" ) ;
509+
510+ cy . get ( "@shellbar" )
511+ . then ( shellbar => {
512+ shellbar . get ( 0 ) . addEventListener ( "ui5-search-button-click" , cy . stub ( ) . as ( "searchButtonClick" ) ) ;
513+ } ) ;
514+
515+ cy . get ( "@shellbar" )
516+ . shadow ( )
517+ . find ( ".ui5-shellbar-search-button" )
518+ . as ( "searchButton" ) ;
519+
520+ cy . get ( "@searchButton" )
521+ . click ( ) ;
522+
523+ cy . get ( "@searchButtonClick" )
524+ . should ( "have.been.calledOnce" ) ;
525+ } ) ;
526+ } ) ;
0 commit comments