@@ -46,6 +46,12 @@ define(function (require, exports, module) {
4646 SidebarView = brackets . test . SidebarView ;
4747 WorkspaceManager = brackets . test . WorkspaceManager ;
4848 _$ = testWindow . $ ;
49+ // Load a real project with some files so anything that depends on a
50+ // populated project tree / file index (e.g. Quick Open's file picker)
51+ // has something to list. QuickOpen-test-files has a couple of html
52+ // files which are enough for the assertions here.
53+ await SpecRunnerUtils . loadProjectInTestWindow (
54+ SpecRunnerUtils . getTestPath ( "/spec/QuickOpen-test-files" ) ) ;
4955 } , 30000 ) ;
5056
5157 afterAll ( async function ( ) {
@@ -899,18 +905,22 @@ define(function (require, exports, module) {
899905
900906 afterEach ( async function ( ) {
901907 await hideToolsPanelIfVisible ( ) ;
902- // Close any modal find/quick-open bars left open.
903- if ( _$ ( "#find-what" ) . length ) {
904- _$ ( testWindow . document ) . trigger (
905- _$ . Event ( "keydown" , { keyCode : 27 /* Esc */ } )
906- ) ;
908+ // Close any modal find / quick-open bars left open so the next
909+ // test starts with a clean DOM.
910+ const findInput = _$ ( "#find-what" ) [ 0 ] ;
911+ if ( findInput ) {
912+ findInput . dispatchEvent ( new testWindow . KeyboardEvent ( "keydown" ,
913+ { keyCode : 27 /* Esc */ , bubbles : true } ) ) ;
914+ await awaitsFor ( function ( ) { return _$ ( "#find-what" ) . length === 0 ; } ,
915+ "find-in-files bar to close" , 3000 ) ;
907916 }
908- if ( _$ ( "input#quickOpenSearch" ) . length ) {
909- _$ ( testWindow . document ) . trigger (
910- _$ . Event ( "keydown" , { keyCode : 27 } )
911- ) ;
917+ const qoInput = _$ ( "input#quickOpenSearch" ) [ 0 ] ;
918+ if ( qoInput ) {
919+ qoInput . dispatchEvent ( new testWindow . KeyboardEvent ( "keydown" ,
920+ { keyCode : 27 , bubbles : true } ) ) ;
921+ await awaitsFor ( function ( ) { return _$ ( "input#quickOpenSearch" ) . length === 0 ; } ,
922+ "quick-open bar to close" , 3000 ) ;
912923 }
913- await awaits ( 0 ) ;
914924 } ) ;
915925
916926 it ( "should exit design mode and open the tools bottom panel when #app-drawer-button is clicked in design mode" , async function ( ) {
@@ -947,26 +957,115 @@ define(function (require, exports, module) {
947957 "find-in-files bar to mount" , 3000 ) ;
948958 } ) ;
949959
950- it ( "should stay in design mode and show a floating Quick Open bar when invoked in design mode" , async function ( ) {
951- await enterDesignMode ( ) ;
952- expect ( WorkspaceManager . isInDesignMode ( ) ) . toBe ( true ) ;
960+ describe ( "Quick Open in design mode" , function ( ) {
961+ // Quick Open has a dedicated design-mode variant (Spotlight-style
962+ // floating overlay) instead of the usual ModalBar, so we cover its
963+ // core user-facing behaviours here: bar shows up, dropdown lists
964+ // project files, typing filters the list, pressing Enter opens
965+ // the selected file.
966+
967+ function $bar ( ) { return _$ ( ".quick-open-floating-bar" ) ; }
968+ function $search ( ) { return _$ ( "input#quickOpenSearch" ) ; }
969+ function $dropdownItems ( ) { return _$ ( ".quick-search-container li" ) ; }
970+
971+ async function openQuickOpenInDesignMode ( ) {
972+ await enterDesignMode ( ) ;
973+ CommandManager . execute ( Commands . NAVIGATE_QUICK_OPEN ) ;
974+ await awaitsFor ( function ( ) { return $bar ( ) . length > 0 ; } ,
975+ "floating Quick Open bar to appear" , 3000 ) ;
976+ await awaitsFor ( function ( ) { return $search ( ) . length > 0 ; } ,
977+ "Quick Open search input to exist" , 2000 ) ;
978+ }
953979
954- CommandManager . execute ( Commands . NAVIGATE_QUICK_OPEN ) ;
980+ async function typeInSearch ( text ) {
981+ $search ( ) . val ( text ) ;
982+ $search ( ) . trigger ( "input" ) ;
983+ }
955984
956- // Quick Open uses a Spotlight-style floating bar in design mode
957- // (rather than exiting) — users see the picker on top of the live
958- // preview without losing design mode.
959- await awaitsFor ( function ( ) {
960- return _$ ( ".quick-open-floating-bar" ) . length > 0 ;
961- } , "floating Quick Open bar to appear" , 3000 ) ;
962- expect ( WorkspaceManager . isInDesignMode ( ) ) . toBe ( true ) ;
985+ async function closeQuickOpen ( ) {
986+ if ( $bar ( ) . length === 0 ) { return ; }
987+ const input = $search ( ) [ 0 ] ;
988+ if ( input ) {
989+ input . dispatchEvent ( new testWindow . KeyboardEvent ( "keydown" ,
990+ { keyCode : 27 , bubbles : true } ) ) ;
991+ }
992+ await awaitsFor ( function ( ) { return $bar ( ) . length === 0 ; } ,
993+ "floating Quick Open bar to close" , 3000 ) ;
994+ }
963995
964- // Close the picker.
965- const doc = testWindow . document ;
966- doc . dispatchEvent ( new testWindow . KeyboardEvent ( "keydown" , { keyCode : 27 , bubbles : true } ) ) ;
967- await awaitsFor ( function ( ) {
968- return _$ ( ".quick-open-floating-bar" ) . length === 0 ;
969- } , "floating Quick Open bar to close" , 3000 ) ;
996+ afterEach ( async function ( ) {
997+ await closeQuickOpen ( ) ;
998+ } ) ;
999+
1000+ it ( "should show the floating bar and stay in design mode (no ModalBar)" , async function ( ) {
1001+ await openQuickOpenInDesignMode ( ) ;
1002+ expect ( WorkspaceManager . isInDesignMode ( ) ) . toBe ( true ) ;
1003+ // Design-mode variant — the Quick Open search field lives inside
1004+ // the floating bar, not inside a normal ModalBar.
1005+ expect ( $search ( ) . closest ( ".quick-open-floating-bar" ) . length ) . toBe ( 1 ) ;
1006+ expect ( $search ( ) . closest ( ".modal-bar" ) . length ) . toBe ( 0 ) ;
1007+ } ) ;
1008+
1009+ it ( "should list project files in the dropdown" , async function ( ) {
1010+ await openQuickOpenInDesignMode ( ) ;
1011+ await awaitsFor ( function ( ) { return $dropdownItems ( ) . length > 0 ; } ,
1012+ "Quick Open dropdown to populate with project files" , 3000 ) ;
1013+ const names = $dropdownItems ( ) . map ( function ( ) {
1014+ return _$ ( this ) . text ( ) ;
1015+ } ) . get ( ) . join ( " | " ) ;
1016+ // The test project (QuickOpen-test-files) has lotsOfLines.html
1017+ // and somelines.html — both should surface without any query.
1018+ expect ( names ) . toContain ( "lotsOfLines.html" ) ;
1019+ expect ( names ) . toContain ( "somelines.html" ) ;
1020+ } ) ;
1021+
1022+ it ( "should filter the dropdown as the user types" , async function ( ) {
1023+ await openQuickOpenInDesignMode ( ) ;
1024+ await awaitsFor ( function ( ) { return $dropdownItems ( ) . length >= 2 ; } ,
1025+ "Quick Open dropdown to populate" , 3000 ) ;
1026+ const beforeCount = $dropdownItems ( ) . length ;
1027+
1028+ await typeInSearch ( "somelines" ) ;
1029+ await awaitsFor ( function ( ) {
1030+ const items = $dropdownItems ( ) ;
1031+ if ( items . length === 0 ) { return false ; }
1032+ // Every visible item must match the filter.
1033+ let allMatch = true ;
1034+ items . each ( function ( ) {
1035+ if ( ! / s o m e l i n e s / i. test ( _$ ( this ) . text ( ) ) ) { allMatch = false ; }
1036+ } ) ;
1037+ return allMatch && items . length < beforeCount ;
1038+ } , "dropdown to filter down to matching items" , 3000 ) ;
1039+
1040+ // The un-matching file shouldn't be present anymore.
1041+ const filteredNames = $dropdownItems ( ) . map ( function ( ) {
1042+ return _$ ( this ) . text ( ) ;
1043+ } ) . get ( ) . join ( " | " ) ;
1044+ expect ( filteredNames ) . toContain ( "somelines.html" ) ;
1045+ expect ( filteredNames ) . not . toContain ( "lotsOfLines.html" ) ;
1046+ } ) ;
1047+
1048+ it ( "should open the selected file when Enter is pressed from the floating bar" , async function ( ) {
1049+ await openQuickOpenInDesignMode ( ) ;
1050+ await awaitsFor ( function ( ) { return $dropdownItems ( ) . length >= 2 ; } ,
1051+ "Quick Open dropdown to populate" , 3000 ) ;
1052+
1053+ await typeInSearch ( "somelines" ) ;
1054+ await awaitsFor ( function ( ) {
1055+ const items = $dropdownItems ( ) ;
1056+ return items . length > 0 && / s o m e l i n e s / i. test ( _$ ( items [ 0 ] ) . text ( ) ) ;
1057+ } , "somelines.html to be the top match" , 3000 ) ;
1058+
1059+ const input = $search ( ) [ 0 ] ;
1060+ input . dispatchEvent ( new testWindow . KeyboardEvent ( "keydown" ,
1061+ { keyCode : 13 /* Enter */ , bubbles : true } ) ) ;
1062+
1063+ const DocumentManager = brackets . test . DocumentManager ;
1064+ await awaitsFor ( function ( ) {
1065+ const doc = DocumentManager . getCurrentDocument ( ) ;
1066+ return doc && doc . file && doc . file . name === "somelines.html" ;
1067+ } , "somelines.html to open in the editor" , 5000 ) ;
1068+ } ) ;
9701069 } ) ;
9711070
9721071 it ( "should exit design mode when the git toolbar icon is clicked in design mode" , async function ( ) {
0 commit comments