Skip to content

Commit cac498e

Browse files
committed
test: stabilize integration timing on slow Chromium runners
Reuse scrolling fixtures and populate real working-set tabs without loading every editor. Reset pane state and allow filesystem cleanup to finish. Wait for preference diagnostics and their visible status together, using the inspection timeout instead of the default two-second UI wait. Verified development and production Integration categories at 857/857 each, Tab Bar at 49/49 with 4x CPU throttling, and delayed PreferencesManager at 7/7.
1 parent 3215b17 commit cac498e

2 files changed

Lines changed: 56 additions & 66 deletions

File tree

‎test/spec/Extn-Tabbar-integ-test.js‎

Lines changed: 31 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -285,16 +285,15 @@ define(function (require, exports, module) {
285285
CommandManager.execute(Commands.FILE_OPEN, { fullPath: testFilePath }),
286286
"Open test file"
287287
);
288-
}, 5000);
288+
}, 30000);
289289

290290
afterAll(async function () {
291-
// Close all files without prompting to save
292-
await testWindow.closeAllFiles();
293-
294-
testWindow = null;
291+
// closeTestWindow closes the files and parks the project before deleting fixtures.
292+
// Browser IndexedDB cleanup needs the same budget as other integration teardown.
295293
await SpecRunnerUtils.closeTestWindow();
296294
await SpecRunnerUtils.deletePathAsync(testFolder, true);
297-
}, 5000);
295+
testWindow = null;
296+
}, 30000);
298297

299298
/**
300299
* Helper function to check if a tab for a specific file exists in the tab bar
@@ -2745,47 +2744,47 @@ define(function (require, exports, module) {
27452744
describe("Tab Bar Scrolling", function () {
27462745
let longTestFilePaths = [];
27472746

2748-
beforeEach(async function () {
2749-
// Create multiple test files to ensure scrolling is needed
2750-
longTestFilePaths = [];
2747+
beforeAll(async function () {
2748+
// These files are read-only fixtures; create them once rather than rewriting
2749+
// the same 15 files and notifying filesystem watchers before every scroll test.
27512750
for (let i = 1; i <= 15; i++) {
27522751
const filePath = testFolder + `/scroll-test-file-${i}.js`;
27532752
longTestFilePaths.push(filePath);
27542753
await jsPromise(
27552754
SpecRunnerUtils.createTextFile(filePath, `// Test file ${i} for scrolling`, FileSystem)
27562755
);
27572756
}
2757+
}, 30000);
27582758

2759-
// Open all files to create many tabs
2760-
for (let filePath of longTestFilePaths) {
2761-
await awaitsForDone(
2762-
CommandManager.execute(Commands.FILE_OPEN, { fullPath: filePath }),
2763-
`Open ${filePath}`
2764-
);
2759+
beforeEach(async function () {
2760+
await testWindow.closeAllFiles();
2761+
MainViewManager.setLayoutScheme(1, 1);
2762+
PreferencesManager.set("tabBar.options", { showTabBar: true, numberOfTabs: -1 });
2763+
await awaitsForDone(
2764+
CommandManager.execute(Commands.FILE_OPEN, { fullPath: longTestFilePaths[0] }),
2765+
"Open the scrolling fixture's active editor"
2766+
);
2767+
// Working-set entries create real tabs without loading and linting 14 more
2768+
// editors. These cases exercise tab scrolling, not document activation.
2769+
for (const filePath of longTestFilePaths.slice(1)) {
2770+
MainViewManager.addToWorkingSet("first-pane", FileSystem.getFileForPath(filePath));
27652771
}
27662772

2767-
// Wait for tabs to be rendered
2773+
// Require actual overflow so no scrolling assertion can pass without scrolling.
27682774
await awaitsFor(
27692775
function () {
2770-
return getTabCount() >= 15;
2776+
const tabBar = $("#phoenix-tab-bar")[0];
2777+
return getTabCount() === longTestFilePaths.length && tabBar &&
2778+
tabBar.scrollWidth > tabBar.clientWidth;
27712779
},
2772-
"All tabs to be created"
2780+
"All scrolling tabs to be created and overflow"
27732781
);
2782+
$("#phoenix-tab-bar").scrollLeft(0);
27742783
});
27752784

27762785
afterEach(async function () {
2777-
// Close all test files
2778-
for (let filePath of longTestFilePaths) {
2779-
const fileObj = FileSystem.getFileForPath(filePath);
2780-
try {
2781-
await awaitsForDone(
2782-
CommandManager.execute(Commands.FILE_CLOSE, { file: fileObj }),
2783-
`Close ${filePath}`
2784-
);
2785-
} catch (e) {
2786-
// Ignore errors if file is already closed
2787-
}
2788-
}
2786+
await testWindow.closeAllFiles();
2787+
MainViewManager.setLayoutScheme(1, 1);
27892788
});
27902789

27912790
it("should scroll tab bar horizontally when mouse wheel is scrolled", function () {
@@ -2879,13 +2878,7 @@ define(function (require, exports, module) {
28792878

28802879
// Open multiple files in second pane to enable scrolling
28812880
for (let i = 1; i < 8; i++) {
2882-
await awaitsForDone(
2883-
CommandManager.execute(Commands.FILE_OPEN, {
2884-
fullPath: longTestFilePaths[i],
2885-
paneId: "second-pane"
2886-
}),
2887-
`Open file ${i} in second pane`
2888-
);
2881+
MainViewManager.addToWorkingSet("second-pane", FileSystem.getFileForPath(longTestFilePaths[i]));
28892882
}
28902883

28912884
// Wait for tabs to be rendered in second pane
@@ -2920,14 +2913,9 @@ define(function (require, exports, module) {
29202913
const $tabBar = $("#phoenix-tab-bar");
29212914
expect($tabBar.length).toBe(1);
29222915

2923-
// Ensure the tab bar is scrollable by checking if scrollWidth > clientWidth
2924-
if ($tabBar[0].scrollWidth <= $tabBar[0].clientWidth) {
2925-
// Skip test if tab bar is not scrollable
2926-
return;
2927-
}
2928-
29292916
// Set initial scroll position to middle to allow scrolling in both directions
29302917
const maxScroll = $tabBar[0].scrollWidth - $tabBar[0].clientWidth;
2918+
expect(maxScroll).toBeGreaterThan(200);
29312919
const midScroll = Math.floor(maxScroll / 2);
29322920
$tabBar.scrollLeft(midScroll);
29332921

‎test/spec/PreferencesManager-integ-test.js‎

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,27 @@ define(function (require, exports, module) {
5252
await SpecRunnerUtils.closeTestWindow();
5353
}, 30000);
5454

55+
/**
56+
* Wait for asynchronous inspection to publish both the diagnostic and its visible status.
57+
* @param {string} fileName Current fixture name, used in failure messages.
58+
* @param {boolean} hasConflict Whether the preferences conflict should be reported.
59+
* @return {Promise<void>}
60+
*/
61+
async function _waitForPreferenceInspection(fileName, hasConflict) {
62+
// Inspectors may take up to asyncTimeout; the default two-second UI wait can
63+
// expire while valid filesystem-backed inspection is still running on CI.
64+
const timeout = PreferencesManager.getExtensionPrefs("linting").get("asyncTimeout") + 5000;
65+
await awaitsFor(()=>{
66+
const $indicator = testWindow.$("#status-inspection");
67+
const conflictShown = testWindow.$("#problems-panel").text()
68+
.includes(Strings.ERROR_PREFS_PROJECT_LINT_MESSAGE);
69+
const iconMatches = hasConflict
70+
? $indicator.is(".inspection-errors, .inspection-repair")
71+
: $indicator.hasClass("inspection-valid");
72+
return $indicator.is(":visible") && iconMatches && conflictShown === hasConflict;
73+
}, "inspection diagnostic and visible status for " + fileName, timeout);
74+
}
75+
5576
async function _verifySinglePreference(fileName, expectedSpaceUnits) {
5677
const projectWithoutSettings = SpecRunnerUtils.getTestPath("/spec/WorkingSetView-test-files"),
5778
FileViewController = testWindow.brackets.test.FileViewController;
@@ -156,36 +177,17 @@ define(function (require, exports, module) {
156177

157178
// there will be an error in problems panel if both present
158179
await awaitsForDone(SpecRunnerUtils.openProjectFiles(".phcode.json"));
159-
// Keep the visual assertion: another provider can offer a fix, which changes
160-
// the warning icon to a repair icon while the preference conflict still exists.
161-
await awaitsFor(()=>{
162-
return testWindow.$("#status-inspection").is(":visible") &&
163-
testWindow.$("#status-inspection").is(".inspection-errors, .inspection-repair");
164-
}, "visible problem indicator on .phcode.json");
165180
if (!testWindow.$("#problems-panel").is(":visible")) {
166181
CommandManager.execute(Commands.VIEW_TOGGLE_PROBLEMS);
167182
}
168-
await awaitsFor(()=>{
169-
return testWindow.$("#problems-panel").text().includes(Strings.ERROR_PREFS_PROJECT_LINT_MESSAGE);
170-
}, "problem panel on .phcode.json");
183+
await _waitForPreferenceInspection(".phcode.json", true);
171184

172185
await awaitsForDone(SpecRunnerUtils.openProjectFiles("test.json"));
173-
await awaitsFor(()=>{
174-
return !testWindow.$("#problems-panel").text().includes(Strings.ERROR_PREFS_PROJECT_LINT_MESSAGE);
175-
}, "no preference conflict for normal test.json file");
176-
await awaitsFor(()=>{
177-
return testWindow.$("#status-inspection").is(".inspection-valid:visible");
178-
}, "valid inspection indicator for normal test.json file");
186+
await _waitForPreferenceInspection("test.json", false);
179187

180188
await awaitsForDone(SpecRunnerUtils.openProjectFiles(".brackets.json"));
181-
await awaitsFor(()=>{
182-
return testWindow.$("#problems-panel").text().includes(Strings.ERROR_PREFS_PROJECT_LINT_MESSAGE);
183-
}, "problem panel on .brackets.json");
184-
await awaitsFor(()=>{
185-
return testWindow.$("#status-inspection").is(":visible") &&
186-
testWindow.$("#status-inspection").is(".inspection-errors, .inspection-repair");
187-
}, "visible problem indicator on .brackets.json");
188-
});
189+
await _waitForPreferenceInspection(".brackets.json", true);
190+
}, 45000);
189191

190192
it("should open .brackets.json file if it has json errors", async function () {
191193
await SpecRunnerUtils.loadProjectInTestWindow(testPathBracketsPrefsOnlyCorrupt);

0 commit comments

Comments
 (0)