@@ -536,12 +536,12 @@ define(function (require, exports, module) {
536536 await awaitsFor ( function ( ) {
537537 return editor . getSelectedText ( ) === "indianred" ;
538538 } , "expected live hints to update selection to indianred" ) ;
539- await _waitForLivePreviewElementColor ( "testId " , "rgb(205, 92, 92)" ) ; // indian red
539+ await _waitForLivePreviewElementColor ( "testId2 " , "rgb(205, 92, 92)" ) ; // indian red
540540 SpecRunnerUtils . simulateKeyEvent ( KeyEvent . DOM_VK_DOWN , "keydown" , testWindow . document . body ) ;
541541 await awaitsFor ( function ( ) {
542542 return editor . getSelectedText ( ) === "mediumvioletred" ;
543543 } , "expected live hints to update selection to mediumvioletred" ) ;
544- await _waitForLivePreviewElementColor ( "testId " , "rgb(199, 21, 133)" ) ;
544+ await _waitForLivePreviewElementColor ( "testId2 " , "rgb(199, 21, 133)" ) ;
545545 return initialHistoryLength ;
546546 }
547547
@@ -584,6 +584,74 @@ define(function (require, exports, module) {
584584 await endPreviewSession ( ) ;
585585 } , 30000 ) ;
586586
587+ async function _livePreviewCodeHintsCSS ( ) {
588+ await awaitsForDone ( SpecRunnerUtils . openProjectFiles ( [ "inline-style.html" ] ) ,
589+ "SpecRunnerUtils.openProjectFiles inline-style.html" ) ;
590+
591+ await waitsForLiveDevelopmentToOpen ( ) ;
592+
593+ await awaitsFor ( ( ) => LiveDevMultiBrowser . status === LiveDevMultiBrowser . STATUS_ACTIVE ,
594+ "status active" ) ;
595+
596+ await awaitsForDone ( SpecRunnerUtils . openProjectFiles ( [ "simple1.css" ] ) ,
597+ "simple1.css" ) ;
598+
599+ await _openCodeHints ( { line : 3 , ch : 8 } , [ "antiquewhite" ] ) ;
600+
601+ let editor = EditorManager . getActiveEditor ( ) ;
602+ const initialHistoryLength = editor . getHistory ( ) . done . length ;
603+ SpecRunnerUtils . simulateKeyEvent ( KeyEvent . DOM_VK_DOWN , "keydown" , testWindow . document . body ) ;
604+ await awaitsFor ( function ( ) {
605+ return editor . getSelectedText ( ) === "antiquewhite" ;
606+ } , "expected live hints to update selection to antiquewhite" ) ;
607+ await _waitForLivePreviewElementColor ( "testId" , "rgb(250, 235, 215)" ) ; // antiquewhite
608+ SpecRunnerUtils . simulateKeyEvent ( KeyEvent . DOM_VK_DOWN , "keydown" , testWindow . document . body ) ;
609+ await awaitsFor ( function ( ) {
610+ return editor . getSelectedText ( ) === "aqua" ;
611+ } , "expected live hints to update selection to aqua" ) ;
612+ await _waitForLivePreviewElementColor ( "testId" , "rgb(0, 255, 255)" ) ; //aqua
613+ return initialHistoryLength ;
614+ }
615+
616+ it ( "should Live preview push css code hints selection changes to browser(linked css)" , async function ( ) {
617+ const expectedHistoryLength = await _livePreviewCodeHintsCSS ( ) ;
618+ let editor = EditorManager . getActiveEditor ( ) ;
619+
620+ // now dismiss with escape
621+ SpecRunnerUtils . simulateKeyEvent ( KeyEvent . DOM_VK_ESCAPE , "keydown" , testWindow . document . body ) ;
622+ await awaitsFor ( function ( ) {
623+ return ! testWindow . $ ( ".codehint-menu" ) . is ( ":visible" ) ;
624+ } , "codehints to be hidden" ) ;
625+ await awaitsFor ( function ( ) {
626+ return editor . getSelectedText ( ) === "" ;
627+ } , "to restore the text to old state" ) ;
628+ expect ( editor . getToken ( ) . string ) . toBe ( " " ) ;
629+
630+ // the undo history should be same as when we started
631+ expect ( editor . getHistory ( ) . done . length ) . toBe ( expectedHistoryLength ) ;
632+ await endPreviewSession ( ) ;
633+ } , 30000 ) ;
634+
635+ it ( "should Live preview push css code hints selection changes to browser and commit(linked css)" , async function ( ) {
636+ const expectedHistoryLength = await _livePreviewCodeHintsCSS ( ) ;
637+ let editor = EditorManager . getActiveEditor ( ) ;
638+
639+ // now dismiss with escape
640+ SpecRunnerUtils . simulateKeyEvent ( KeyEvent . DOM_VK_RETURN , "keydown" , testWindow . document . body ) ;
641+ await awaitsFor ( function ( ) {
642+ return ! testWindow . $ ( ".codehint-menu" ) . is ( ":visible" ) ;
643+ } , "codehints to be hidden" ) ;
644+ await awaitsFor ( function ( ) {
645+ return editor . getSelectedText ( ) === "" ;
646+ } , "to restore the text to old state" ) ;
647+ // check if we have the new value
648+ expect ( editor . getToken ( ) . string ) . toBe ( "aqua" ) ;
649+
650+ // the undo history should be just one above
651+ expect ( editor . getHistory ( ) . done . length ) . toBe ( expectedHistoryLength + 3 ) ;
652+ await endPreviewSession ( ) ;
653+ } , 30000 ) ;
654+
587655 it ( "should Live preview work even if we switch html files" , async function ( ) {
588656 await awaitsForDone ( SpecRunnerUtils . openProjectFiles ( [ "simple1.html" ] ) ,
589657 "SpecRunnerUtils.openProjectFiles simple1.html" ) ;
0 commit comments