Skip to content

Commit 208f22c

Browse files
committed
fix: code inspection legacy integ tests failing
1 parent 5757c93 commit 208f22c

File tree

2 files changed

+29
-20
lines changed

2 files changed

+29
-20
lines changed

test/spec/CodeInspection-integ-test.js

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,10 @@ define(function (require, exports, module) {
477477
beforeEach(function () {
478478
CodeInspection._unregisterAll();
479479
CodeInspection.toggleEnabled(true);
480+
// Ensure problems panel starts hidden for each test
481+
if ($("#problems-panel").is(":visible")) {
482+
CommandManager.execute(Commands.VIEW_TOGGLE_PROBLEMS);
483+
}
480484
});
481485

482486
// Utility to create an async provider where the testcase can control when each async result resolves
@@ -512,7 +516,7 @@ define(function (require, exports, module) {
512516

513517
await awaitsForDone(SpecRunnerUtils.openProjectFiles(["errors.js"]), "open test file", 5000);
514518

515-
expect($("#problems-panel").is(":visible")).toBe(true);
519+
expect($("#status-inspection").hasClass("inspection-errors")).toBe(true);
516520
var $statusBar = $("#status-inspection");
517521
expect($statusBar.is(":visible")).toBe(true);
518522
});
@@ -523,7 +527,7 @@ define(function (require, exports, module) {
523527

524528
await awaitsForDone(SpecRunnerUtils.openProjectFiles(["errors.js"]), "open test file", 5000);
525529

526-
expect($("#problems-panel").is(":visible")).toBe(true);
530+
expect($("#status-inspection").hasClass("inspection-errors")).toBe(true);
527531
let marks = EditorManager.getActiveEditor().getAllMarks("codeInspector");
528532
expect(marks.length).toBe(1);
529533
expect(marks[0].className).toBe("editor-text-fragment-warn");
@@ -535,7 +539,8 @@ define(function (require, exports, module) {
535539

536540
await awaitsForDone(SpecRunnerUtils.openProjectFiles(["errors.js"]), "open test file", 5000);
537541

538-
expect($("#problems-panel").is(":visible")).toBe(true);
542+
expect($("#status-inspection").hasClass("inspection-errors") ||
543+
$("#status-inspection").hasClass("inspection-repair")).toBe(true);
539544
let marks = EditorManager.getActiveEditor().getGutterMarker(1, CodeInspection.CODE_INSPECTION_GUTTER);
540545
expect(marks.title).toBe('Some errors here and there at column: 4');
541546
marks = $(marks);
@@ -594,7 +599,7 @@ define(function (require, exports, module) {
594599

595600
await awaitsForDone(SpecRunnerUtils.openProjectFiles(["errors.js"]), "open test file");
596601

597-
expect($("#problems-panel").is(":visible")).toBe(true);
602+
expect($("#status-inspection").hasClass("inspection-errors")).toBe(true);
598603
let marks = $(EditorManager.getActiveEditor()
599604
.getGutterMarker(1, CodeInspection.CODE_INSPECTION_GUTTER));
600605
expect(marks.find('span').hasClass('line-icon-problem_type_info')).toBeTrue();
@@ -633,7 +638,7 @@ define(function (require, exports, module) {
633638

634639
await awaitsForDone(SpecRunnerUtils.openProjectFiles(["errors.js"]), "open test file");
635640

636-
expect($("#problems-panel").is(":visible")).toBe(true);
641+
expect($("#status-inspection").hasClass("inspection-errors")).toBe(true);
637642
let marks = EditorManager.getActiveEditor().getAllMarks("codeInspector");
638643
expect(marks.length).toBe(numMarksExpected);
639644

@@ -716,7 +721,8 @@ define(function (require, exports, module) {
716721
// Finish new (current) linting session - verify results are shown
717722
asyncProvider.futures[noErrorsJS][1].resolve(failLintResult());
718723
await awaits(100);
719-
expect($("#problems-panel").is(":visible")).toBe(true);
724+
725+
expect($("#status-inspection").hasClass("inspection-errors")).toBe(true);
720726
});
721727

722728
it("should ignore async results from previous run in same file - finishing reverse order", async function () {
@@ -740,12 +746,14 @@ define(function (require, exports, module) {
740746
// Finish new (current) linting session - verify results are shown
741747
asyncProvider.futures[noErrorsJS][1].resolve(failLintResult());
742748
await awaits(100);
743-
expect($("#problems-panel").is(":visible")).toBe(true);
749+
750+
expect($("#status-inspection").hasClass("inspection-errors")).toBe(true);
744751

745752
// Finish old (stale) linting session - verify results don't replace current results
746753
asyncProvider.futures[noErrorsJS][0].resolve(successfulLintResult());
747754
await awaits(100);
748-
expect($("#problems-panel").is(":visible")).toBe(true);
755+
// Status bar should still show errors (stale success result should be ignored)
756+
expect($("#status-inspection").hasClass("inspection-errors")).toBe(true);
749757
});
750758

751759
it("should ignore async results after linting disabled", async function () {
@@ -792,7 +800,7 @@ define(function (require, exports, module) {
792800

793801
await awaitsForDone(SpecRunnerUtils.openProjectFiles(["errors.js"]), "open test file", 5000);
794802

795-
expect($("#problems-panel").is(":visible")).toBe(true);
803+
expect($("#status-inspection").hasClass("inspection-errors")).toBe(true);
796804
var $statusBar = $("#status-inspection");
797805
expect($statusBar.is(":visible")).toBe(true);
798806

@@ -866,6 +874,9 @@ define(function (require, exports, module) {
866874

867875
await awaitsForDone(SpecRunnerUtils.openProjectFiles(["errors.js"]), "open test file", 5000);
868876

877+
expect($("#status-inspection").hasClass("inspection-errors") ||
878+
$("#status-inspection").hasClass("inspection-repair")).toBe(true);
879+
CommandManager.execute(Commands.VIEW_TOGGLE_PROBLEMS);
869880
expect($("#problems-panel").is(":visible")).toBe(true);
870881
expect($(".inspector-section").is(":visible")).toBeFalsy();
871882
}
@@ -890,6 +901,8 @@ define(function (require, exports, module) {
890901

891902
await awaitsForDone(SpecRunnerUtils.openProjectFiles(["errors.js"]), "open test file", 5000);
892903

904+
expect($("#status-inspection").hasClass("inspection-errors")).toBe(true);
905+
CommandManager.execute(Commands.VIEW_TOGGLE_PROBLEMS);
893906
expect($("#problems-panel").is(":visible")).toBe(true);
894907

895908
var $inspectorSections = $(".inspector-section");
@@ -904,17 +917,18 @@ define(function (require, exports, module) {
904917

905918
await awaitsForDone(SpecRunnerUtils.openProjectFiles(["errors.js"]), "open test file");
906919

907-
toggleJSLintResults(false);
908920
toggleJSLintResults(true);
921+
toggleJSLintResults(false);
909922
});
910923

911-
it("status icon should not toggle Errors panel when no errors present", async function () {
924+
it("status icon should toggle Errors panel even when no errors present", async function () {
912925
var codeInspector = createCodeInspector("javascript linter", successfulLintResult());
913926
CodeInspection.register("javascript", codeInspector);
914927

915928
await awaitsForDone(SpecRunnerUtils.openProjectFiles(["no-errors.js"]), "open test file");
916929

917-
toggleJSLintResults(false);
930+
// Status bar click always toggles the panel regardless of error state
931+
toggleJSLintResults(true);
918932
toggleJSLintResults(false);
919933
});
920934

@@ -1307,8 +1321,7 @@ define(function (require, exports, module) {
13071321

13081322
await awaits(prefs.get(CodeInspection._PREF_ASYNC_TIMEOUT) + 20);
13091323

1310-
var $problemsPanel = $("#problems-panel");
1311-
expect($problemsPanel.is(":visible")).toBe(true);
1324+
expect($("#status-inspection").hasClass("inspection-errors")).toBe(true);
13121325

13131326
var $problemsPanelTitle = $("#problems-panel .title").text();
13141327
expect($problemsPanelTitle).toBe(StringUtils.format(Strings.SINGLE_ERROR, "SlowAsyncLinter", "errors.js"));
@@ -1337,8 +1350,7 @@ define(function (require, exports, module) {
13371350

13381351
await awaitsForDone(SpecRunnerUtils.openProjectFiles(["errors.js"]), "open test file");
13391352

1340-
var $problemsPanel = $("#problems-panel");
1341-
expect($problemsPanel.is(":visible")).toBe(true);
1353+
expect($("#status-inspection").hasClass("inspection-errors")).toBe(true);
13421354

13431355
var $problemsPanelTitle = $("#problems-panel .title").text();
13441356
expect($problemsPanelTitle).toBe(StringUtils.format(Strings.SINGLE_ERROR, providerName, "errors.js"));
@@ -1363,8 +1375,7 @@ define(function (require, exports, module) {
13631375

13641376
await awaitsForDone(SpecRunnerUtils.openProjectFiles(["errors.js"]), "open test file");
13651377

1366-
var $problemsPanel = $("#problems-panel");
1367-
expect($problemsPanel.is(":visible")).toBe(true);
1378+
expect($("#status-inspection").hasClass("inspection-errors")).toBe(true);
13681379

13691380
var $problemsPanelTitle = $("#problems-panel .title").text();
13701381
expect($problemsPanelTitle).toBe(StringUtils.format(Strings.SINGLE_ERROR, providerName, "errors.js"));

test/spec/PreferencesManager-integ-test.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ define(function (require, exports, module) {
104104

105105
// there will be an error in problems panel if both present
106106
await awaitsForDone(SpecRunnerUtils.openProjectFiles(".phcode.json"));
107-
// The panel no longer auto-shows; ensure it is visible to check content
108107
await awaitsFor(()=>{
109108
return testWindow.$("#status-inspection").hasClass("inspection-errors");
110109
}, "lint errors detected on .phcode.json");
@@ -116,7 +115,6 @@ define(function (require, exports, module) {
116115
}, "problem panel on .phcode.json");
117116

118117
await awaitsForDone(SpecRunnerUtils.openProjectFiles("test.json"));
119-
// The panel no longer auto-hides; check status bar for no-errors state instead
120118
await awaitsFor(()=>{
121119
return !testWindow.$("#status-inspection").hasClass("inspection-errors");
122120
}, "no lint errors for normal test.json file");

0 commit comments

Comments
 (0)