Skip to content

Commit 80bb728

Browse files
devvaannshabose
authored andcommitted
fix: code inspection jshint eslint integ tests failing
1 parent 488f129 commit 80bb728

5 files changed

Lines changed: 60 additions & 20 deletions

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ define(function (require, exports, module) {
135135

136136
async function _openProjectFile(fileName) {
137137
await awaitsForDone(SpecRunnerUtils.openProjectFiles([fileName]), "opening "+ fileName);
138+
139+
if (!$("#problems-panel").is(":visible")) {
140+
CommandManager.execute(Commands.VIEW_TOGGLE_PROBLEMS);
141+
}
138142
}
139143

140144
it("should run test linter when a vbscript document opens show fix buttons in the panel", async function () {

test/spec/Extn-ESLint-integ-test.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,22 @@ define(function (require, exports, module) {
8585
}
8686

8787
async function _waitForProblemsPanelVisible(visible) {
88-
await awaitsFor(()=>{
89-
return $("#problems-panel").is(":visible") === visible;
90-
}, "Problems panel to be visible", 15000);
88+
if (visible) {
89+
// Wait for lint to detect errors, then ensure panel is shown
90+
await awaitsFor(()=>{
91+
return $("#status-inspection").hasClass("inspection-errors") ||
92+
$("#status-inspection").hasClass("inspection-repair");
93+
}, "Lint errors to be detected", 15000);
94+
if (!$("#problems-panel").is(":visible")) {
95+
CommandManager.execute(Commands.VIEW_TOGGLE_PROBLEMS);
96+
}
97+
} else {
98+
// Wait for no-errors state in the status bar
99+
await awaitsFor(()=>{
100+
return !$("#status-inspection").hasClass("inspection-errors") &&
101+
!$("#status-inspection").hasClass("inspection-repair");
102+
}, "No lint errors detected", 15000);
103+
}
91104
}
92105

93106
async function _openSimpleES6Project() {

test/spec/Extn-HTMLCodeHints-Lint-integ-test.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,22 @@ define(function (require, exports, module) {
8585
}
8686

8787
async function _waitForProblemsPanelVisible(visible) {
88-
await awaitsFor(()=>{
89-
return $("#problems-panel").is(":visible") === visible;
90-
}, "Problems panel to be visible");
88+
if (visible) {
89+
// Wait for lint to detect errors, then ensure panel is shown
90+
await awaitsFor(()=>{
91+
return $("#status-inspection").hasClass("inspection-errors") ||
92+
$("#status-inspection").hasClass("inspection-repair");
93+
}, "Lint errors to be detected");
94+
if (!$("#problems-panel").is(":visible")) {
95+
CommandManager.execute(Commands.VIEW_TOGGLE_PROBLEMS);
96+
}
97+
} else {
98+
// Wait for no-errors state in the status bar
99+
await awaitsFor(()=>{
100+
return !$("#status-inspection").hasClass("inspection-errors") &&
101+
!$("#status-inspection").hasClass("inspection-repair");
102+
}, "No lint errors detected");
103+
}
91104
}
92105

93106
async function _siwtchFilesTo(destinationFile) {
@@ -99,6 +112,7 @@ define(function (require, exports, module) {
99112

100113
it("should show html lint error with no config file", async function () {
101114
await _openProjectFile("simple1.html");
115+
await _waitForProblemsPanelVisible(true);
102116
await awaitsFor(()=>{
103117
return $("#problems-panel").text().includes(
104118
"<html> is missing required \"lang\" attribute (element-required-attributes)");

test/spec/Extn-JSHint-integ-test.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,14 @@ define(function (require, exports, module) {
8585

8686
await awaits(100);
8787
await awaitsFor(()=>{
88-
return !$("#problems-panel").is(":visible");
89-
}, "Problems panel to be hidden");
88+
return $("#status-inspection").hasClass("inspection-valid");
89+
}, "No lint errors for es6.js");
9090

9191
// using es8 async feature in es6 jshint mode should have errors in problems panel
9292
await awaitsForDone(SpecRunnerUtils.openProjectFiles(["es8.js"]), "open test file es8.js");
9393
await awaitsFor(()=>{
94-
return $("#problems-panel").is(":visible");
95-
}, "Problems panel to be visible");
94+
return $("#status-inspection").hasClass("inspection-errors");
95+
}, "Lint errors detected for es8.js");
9696
});
9797

9898
it("should extend valid es6 .jshintrc in project", async function () {
@@ -102,14 +102,14 @@ define(function (require, exports, module) {
102102

103103
await awaits(100);
104104
await awaitsFor(()=>{
105-
return !$("#problems-panel").is(":visible");
106-
}, "Problems panel to be hidden");
105+
return $("#status-inspection").hasClass("inspection-valid");
106+
}, "No lint errors for es6.js");
107107

108108
// using es8 async feature in es6 jshint mode should have errors in problems panel
109109
await awaitsForDone(SpecRunnerUtils.openProjectFiles(["es8.js"]), "open test file es8.js");
110110
await awaitsFor(()=>{
111-
return $("#problems-panel").is(":visible");
112-
}, "Problems panel to be visible");
111+
return $("#status-inspection").hasClass("inspection-errors");
112+
}, "Lint errors detected for es8.js");
113113
});
114114

115115
it("should show errors if invalid .jshintrc extend file detected", async function () {

test/spec/PreferencesManager-integ-test.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ define(function (require, exports, module) {
9393
});
9494

9595
it("should show a problem when both .phcode.json and .brackets.json are present in project", async function () {
96+
const CommandManager = testWindow.brackets.test.CommandManager;
97+
const Commands = testWindow.brackets.test.Commands;
98+
9699
await SpecRunnerUtils.loadProjectInTestWindow(testPathBothPrefs);
97100
await awaitsForDone(SpecRunnerUtils.openProjectFiles(".phcode.json"));
98101
await awaitsFor(()=>{
@@ -101,20 +104,26 @@ define(function (require, exports, module) {
101104

102105
// there will be an error in problems panel if both present
103106
await awaitsForDone(SpecRunnerUtils.openProjectFiles(".phcode.json"));
107+
// The panel no longer auto-shows; ensure it is visible to check content
108+
await awaitsFor(()=>{
109+
return testWindow.$("#status-inspection").hasClass("inspection-errors");
110+
}, "lint errors detected on .phcode.json");
111+
if (!testWindow.$("#problems-panel").is(":visible")) {
112+
CommandManager.execute(Commands.VIEW_TOGGLE_PROBLEMS);
113+
}
104114
await awaitsFor(()=>{
105-
return testWindow.$("#problems-panel").is(":visible") &&
106-
testWindow.$("#problems-panel").text().includes(Strings.ERROR_PREFS_PROJECT_LINT_MESSAGE);
115+
return testWindow.$("#problems-panel").text().includes(Strings.ERROR_PREFS_PROJECT_LINT_MESSAGE);
107116
}, "problem panel on .phcode.json");
108117

109118
await awaitsForDone(SpecRunnerUtils.openProjectFiles("test.json"));
119+
// The panel no longer auto-hides; check status bar for no-errors state instead
110120
await awaitsFor(()=>{
111-
return !testWindow.$("#problems-panel").is(":visible");
112-
}, "problem panel should not be there for normal test.json file");
121+
return !testWindow.$("#status-inspection").hasClass("inspection-errors");
122+
}, "no lint errors for normal test.json file");
113123

114124
await awaitsForDone(SpecRunnerUtils.openProjectFiles(".brackets.json"));
115125
await awaitsFor(()=>{
116-
return testWindow.$("#problems-panel").is(":visible") &&
117-
testWindow.$("#problems-panel").text().includes(Strings.ERROR_PREFS_PROJECT_LINT_MESSAGE);
126+
return testWindow.$("#problems-panel").text().includes(Strings.ERROR_PREFS_PROJECT_LINT_MESSAGE);
118127
}, "problem panel on .brackets.json");
119128
});
120129

0 commit comments

Comments
 (0)