Skip to content

Commit 1fdcf51

Browse files
committed
test(nav): stop new click-dispatch tests from leaking state into the suite
Two changes to the new click-dispatch tests added in fa455de: - #showInfileTree test no longer opens test.css. recordCommands hooks EVENT_BEFORE_EXECUTE_COMMAND, which fires whether or not handleShowInTree's activeFile branch runs, so the openFile call added nothing to the assertion but did leak a test.css entry into session-restore state, shifting the nav-history ordering that _validateNavForFiles("test.css", ...) expects. - #searchNav test now closes the Find-in-Files bar via FindInFilesUI._closeFindBar and awaits .modal-bar removal before returning. Leaving the modal open caused full-suite runs to fail subsequent navigation tests with "Active file to be test.css timed out" because the stale modal bar's focus/key handling persisted across closeTestWindow + loadProjectInTestWindow. Nav suite passes 6/6 in isolation across three consecutive runs.
1 parent 6dd641c commit 1fdcf51

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

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

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,11 @@ define(function (require, exports, module) {
356356
return executed;
357357
}
358358

359-
it("Should dispatch NAVIGATE_SHOW_IN_FILE_TREE when #showInfileTree is clicked", async function () {
360-
await openFile("test.css");
359+
it("Should dispatch NAVIGATE_SHOW_IN_FILE_TREE when #showInfileTree is clicked", function () {
360+
// Don't open a file here. `recordCommands` hooks EVENT_BEFORE_EXECUTE_COMMAND,
361+
// which fires regardless of whether handleShowInTree's activeFile branch runs.
362+
// Opening a file would leak into the session-restore state and shift the
363+
// nav-history ordering the subsequent _validateNavForFiles tests depend on.
361364
const $btn = $("#showInfileTree");
362365
expect($btn.length).toBe(1);
363366
const executed = recordCommands(function () {
@@ -366,13 +369,25 @@ define(function (require, exports, module) {
366369
expect(executed).toContain(Commands.NAVIGATE_SHOW_IN_FILE_TREE);
367370
}, 15000);
368371

369-
it("Should dispatch CMD_FIND_IN_FILES when #searchNav is clicked", function () {
372+
it("Should dispatch CMD_FIND_IN_FILES when #searchNav is clicked", async function () {
370373
const $btn = $("#searchNav");
371374
expect($btn.length).toBe(1);
372375
const executed = recordCommands(function () {
373376
$btn.trigger("click");
374377
});
375378
expect(executed).toContain(Commands.CMD_FIND_IN_FILES);
379+
// The click opens the Find-in-Files bar; close it before the
380+
// next test's beforeEach reloads, otherwise the modal bar leaks
381+
// across the reload and subsequent navigation tests fail with
382+
// "Active file to be ... timed out" because the new window's
383+
// focus/key handling is stuck behind the stale bar.
384+
const FindInFilesUI = testWindow.brackets.test.FindInFilesUI;
385+
if (FindInFilesUI && FindInFilesUI._closeFindBar) {
386+
FindInFilesUI._closeFindBar(true);
387+
}
388+
await awaitsFor(function () {
389+
return $(".modal-bar").length === 0;
390+
}, "find bar to close", 2000);
376391
}, 15000);
377392

378393
it("Should navigate back and forward between text files", async function () {

0 commit comments

Comments
 (0)