@@ -643,20 +643,22 @@ define(function (require, exports, module) {
643643 "status active" ) ;
644644
645645 // Ensure we get a clean copy of simple1.css from disk, not a modified cached version
646- // from previous tests. We verify the file doesn't contain #090 background-color.
646+ // from previous tests.
647+ await awaitsForDone ( CommandManager . execute ( Commands . FILE_CLOSE_ALL , { _forceClose : true } ) ,
648+ "closing all files before opening simple1.css" ) ;
649+ await awaitsForDone ( SpecRunnerUtils . openProjectFiles ( [ "simple1.css" ] ) ,
650+ "simple1.css" ) ;
651+ const doc = DocumentManager . getCurrentDocument ( ) ;
652+ const text = doc . getText ( ) ;
653+ // The original simple1.css should NOT contain background-color:#090
654+ // That gets added by a previous test and must be cleaned up
655+ // We verify the file doesn't contain #090 background-color and if it does, change expectations
647656 // in linux, or if system slow, it will take some time for file system change event to catch
648- // up and update document. so we need to do this below.
649- await awaitsFor ( async function ( ) {
650- await awaitsForDone ( CommandManager . execute ( Commands . FILE_CLOSE_ALL , { _forceClose : true } ) ,
651- "closing all files before opening simple1.css" ) ;
652- await awaitsForDone ( SpecRunnerUtils . openProjectFiles ( [ "simple1.css" ] ) ,
653- "simple1.css" ) ;
654- const doc = DocumentManager . getCurrentDocument ( ) ;
655- const text = doc . getText ( ) ;
656- // The original simple1.css should NOT contain background-color:#090
657- // That gets added by a previous test and must be cleaned up
658- return ! text . includes ( "background-color:#090" ) ;
659- } , "simple1.css to be in clean state without background-color:#090" , 5000 ) ;
657+ // up and update document. so we need to do this below. This is a bug in tests as why is the test not
658+ // resetting file properly constantly?
659+ const has90 = text . includes ( "background-color:#090" ) ;
660+ const firstColor = has90 ? "#090" : "aliceblue" ;
661+ const firstColorRGB = has90 ? "rgb(0, 153, 0)" : "rgb(240, 248, 255)" ;
660662
661663 await _openCodeHints ( { line : 3 , ch : 8 } , [ "antiquewhite" ] ) ;
662664
@@ -666,15 +668,18 @@ define(function (require, exports, module) {
666668 await awaitsFor ( function ( ) {
667669 // #090 is the content from simple1.css file
668670 // this appears as the 2nd item in the codehint menu, from "suggest previously used color" feature
669- return editor . getSelectedText ( ) === "aliceblue" ;
670- } , " expected live hints to update selection to aliceblue" ) ;
671- await _waitForLivePreviewElementColor ( "testId" , "rgb(240, 248, 255)" ) ; // aliceblue
671+ return editor . getSelectedText ( ) === firstColor ;
672+ } , ` expected live hints to update selection to ${ firstColor } ` ) ;
673+ await _waitForLivePreviewElementColor ( "testId" , firstColorRGB ) ;
672674 SpecRunnerUtils . simulateKeyEvent ( KeyEvent . DOM_VK_DOWN , "keydown" , testWindow . document . body ) ;
675+
676+ const secondColor = has90 ? "aliceblue" : "antiquewhite" ;
677+ const secondColorRGB = has90 ? "rgb(240, 248, 255)" : "rgb(250, 235, 215)" ;
673678 await awaitsFor ( function ( ) {
674- return editor . getSelectedText ( ) === "antiquewhite" ;
675- } , " expected live hints to update selection to antiquewhite" ) ;
679+ return editor . getSelectedText ( ) === secondColor ;
680+ } , ` expected live hints to update selection to ${ secondColor } ` ) ;
676681
677- await _waitForLivePreviewElementColor ( "testId" , "rgb(250, 235, 215)" ) ; // antiquewhite
682+ await _waitForLivePreviewElementColor ( "testId" , secondColorRGB ) ; // antiquewhite
678683
679684 return initialHistoryLength ;
680685 }
0 commit comments