Skip to content

Commit e990b1b

Browse files
committed
test: code inspection integ tests no fix when doc changed
1 parent 1c7f6e6 commit e990b1b

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

test/spec/CodeInspection-fix-integ-test.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,41 @@ define(function (require, exports, module) {
287287
expect($("#problems-panel .ph-fix-problem").length).toBe(5); // 5 fix buttons should be there
288288
});
289289

290+
async function _validateCannotFix(fixAll) {
291+
await _openProjectFile("testFix.vbs");
292+
const editor = EditorManager.getActiveEditor();
293+
editor.setCursorPos(1, 1);
294+
295+
expect($("#problems-panel").is(":visible")).toBeTrue();
296+
expect($("#problems-panel .ph-fix-problem").length).toBe(5); // 5 fix buttons should be there
297+
298+
// now change doc to invalidate all fixes
299+
editor.replaceRange("hello", {line:0, ch: 0}, {line:1, ch: 0});
300+
301+
// fix error should raise an error dialog
302+
if(fixAll){
303+
$($("#problems-panel").find(".problems-fix-all-btn")).click();
304+
} else {
305+
$($("#problems-panel").find(".ph-fix-problem")[0]).click();
306+
}
307+
308+
// fixing multiple should place the cursor on first fix
309+
await SpecRunnerUtils.waitForModalDialog();
310+
const dialogText = $(".error-dialog").text();
311+
expect(dialogText.includes(Strings.CANNOT_FIX_TITLE)).toBeTrue();
312+
expect(dialogText.includes(Strings.CANNOT_FIX_MESSAGE)).toBeTrue();
313+
314+
await SpecRunnerUtils.clickDialogButton();
315+
}
316+
317+
it("should not be able to fix 1 error if document changed in between lint", async function () {
318+
await _validateCannotFix();
319+
});
320+
321+
it("should not be able to fix all error if document changed in between lint", async function () {
322+
await _validateCannotFix(true);
323+
});
324+
290325
// todo invalid fixes test, doc changed after fix dialog
291326

292327
});

0 commit comments

Comments
 (0)