@@ -73,7 +73,7 @@ define(function (require, exports, module) {
7373 if ( line . includes ( 'this line a fixable error' ) ) {
7474 const wordPosition = findWordPosition ( line , 'fixable' ) ;
7575 error . fix = {
76- replaceText : "" ,
76+ replaceText : "no " ,
7777 rangeOffset : {
7878 start : currentEditor . indexFromPos ( { line : lineNumber , ch : wordPosition . start } ) ,
7979 end : currentEditor . indexFromPos ( { line : lineNumber , ch : wordPosition . end } )
@@ -180,7 +180,68 @@ define(function (require, exports, module) {
180180 CodeInspection . scrollToProblem ( 40 ) ;
181181 } ) ;
182182
183- // todo fix one, fix all, fix one undo, fix all undo, quick view error click, quick view fix click
183+ it ( "should show quick view over problem" , async function ( ) {
184+ await _openProjectFile ( "testFix.vbs" ) ;
185+
186+ expect ( $ ( "#problems-panel" ) . is ( ":visible" ) ) . toBeTrue ( ) ;
187+
188+ const $popup = await SpecRunnerUtils . showQuickViewAtPos ( 2 , 3 ) ;
189+ expect ( $popup . is ( ":visible" ) ) . toBeTrue ( ) ;
190+ expect ( $popup . text ( ) . includes ( "this line an error" ) ) . toBeTrue ( ) ;
191+ SpecRunnerUtils . dismissQuickView ( $popup ) ;
192+ } ) ;
193+
194+ async function _validateScroll ( lineNumber ) {
195+ CodeInspection . scrollToProblem ( lineNumber ) ;
196+ const expectedScrollTop = $ ( ".table-container" ) . scrollTop ( ) ;
197+ $ ( ".table-container" ) . scrollTop ( 0 ) ;
198+
199+ const $popup = await SpecRunnerUtils . showQuickViewAtPos ( lineNumber , 3 ) ;
200+ expect ( $popup . is ( ":visible" ) ) . toBeTrue ( ) ;
201+ $popup . find ( ".code-inspection-item div" ) . click ( ) ;
202+ expect ( $ ( ".table-container" ) . scrollTop ( ) ) . toBe ( expectedScrollTop ) ;
203+ SpecRunnerUtils . dismissQuickView ( $popup ) ;
204+ }
205+
206+ it ( "should clicking on quick view scroll to the editor" , async function ( ) {
207+ await _openProjectFile ( "testFix.vbs" ) ;
208+
209+ expect ( $ ( "#problems-panel" ) . is ( ":visible" ) ) . toBeTrue ( ) ;
210+ await _validateScroll ( 64 ) ;
211+
212+ await _openProjectFile ( "testNoFix.vbs" ) ;
213+
214+ expect ( $ ( "#problems-panel" ) . is ( ":visible" ) ) . toBeTrue ( ) ;
215+ await _validateScroll ( 57 ) ;
216+ } ) ;
217+
218+ async function _triggerLint ( fileName ) {
219+ await _openProjectFile ( "no-errors.js" ) ;
220+ await _openProjectFile ( fileName ) ;
221+ }
222+
223+ it ( "should fix by clicking fix button in quick view" , async function ( ) {
224+ await _openProjectFile ( "testFix.vbs" ) ;
225+
226+ expect ( $ ( "#problems-panel" ) . is ( ":visible" ) ) . toBeTrue ( ) ;
227+ const $popup = await SpecRunnerUtils . showQuickViewAtPos ( 64 , 3 ) ;
228+ expect ( $popup . is ( ":visible" ) ) . toBeTrue ( ) ;
229+ expect ( $ ( "#problems-panel .ph-fix-problem" ) . length ) . toBe ( 5 ) ; // 5 fix buttons should be there
230+ $popup . find ( ".code-inspection-item button" ) . click ( ) ;
231+ expect ( $ ( "#problems-panel .ph-fix-problem" ) . length ) . toBe ( 4 ) ; // 4 fix buttons as one is fixed
232+ SpecRunnerUtils . dismissQuickView ( $popup ) ;
233+
234+ const editor = EditorManager . getActiveEditor ( ) ;
235+ expect ( editor . getSelectedText ( ) ) . toBe ( "no" ) ;
236+
237+ // undo should work
238+ await awaitsForDone ( CommandManager . execute ( Commands . EDIT_UNDO ) , "undo" ) ;
239+ expect ( editor . getSelectedText ( ) ) . toBe ( "fixable" ) ;
240+ await _triggerLint ( "testFix.vbs" ) ;
241+ expect ( $ ( "#problems-panel .ph-fix-problem" ) . length ) . toBe ( 5 ) ; // 5 fix buttons should be there
242+ } ) ;
243+
244+ // todo fix all, fix all undo,
184245 // todo invalid fixes test, doc changed after fix dialog
185246
186247 } ) ;
0 commit comments