Skip to content

Commit 2ca8f22

Browse files
committed
test(mainview): load a real project and cover Quick Open design-mode behaviour
- Top-level beforeAll now loads /spec/QuickOpen-test-files so every CCB suite runs against a populated project tree. - Add four Quick Open tests under "11b. Auto-exit ..." covering the design-mode Spotlight variant: floating bar shows up and the search field lives inside .quick-open-floating-bar (not a ModalBar); dropdown lists project files without any query; typing "somelines" filters the list so the other file drops out; pressing Enter opens the selected file. - Harden the section-11b afterEach to actually close find-in-files and quick-open bars (native keyboard event + awaitsFor on removal) so no leftover .modal-bar leaks into later tests.
1 parent 7ac7b68 commit 2ca8f22

2 files changed

Lines changed: 126 additions & 76 deletions

File tree

test/control-bar-tests-todo.md

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -10,55 +10,6 @@ describe("mainview: central control bar + design mode", function () { … });
1010
Keep this file updated as we add coverage; remove lines as suites land.
1111

1212
---
13-
14-
## 10. `WorkspaceManager.setPluginPanelWidth` in design mode
15-
16-
- [ ] Setting width W while collapsed resizes the sidebar to
17-
`window - W - pluginIcons - 30 (CCB)` (clamped to ≥ 0) and derives
18-
main-toolbar width accordingly.
19-
- [ ] Setting width W in normal mode falls through to the original
20-
implementation (which clamps against 75% window / `window - sidebar
21-
- 100`).
22-
23-
## 11. Cycle stability
24-
25-
- [ ] Enter design → drag sidebar past cap → exit → re-enter: CCB,
26-
main-toolbar, sidebar all end up aligned (`ccb.left === sidebar.right`,
27-
`mainToolbar.left === sidebar.right + 30`).
28-
- [ ] After the cycle, `sidebar.style.width === sidebar.offsetWidth + "px"`
29-
(pinned at the capped value, not the uncapped Resizer value).
30-
- [ ] Toggle back to normal mode preserves live preview (panel stays open
31-
at `savedToolbarWidth` or the default).
32-
33-
## 11b. Auto-exit design mode from conflicting surfaces
34-
35-
Each of these invocations must exit design mode before running its
36-
own behavior. Verify `WorkspaceManager.isInDesignMode()` is `true`
37-
pre-action, then `false` post-action, and that the feature's UI
38-
renders on the normal editor chrome (not a blank / broken region).
39-
40-
- [ ] Clicking `#app-drawer-button` while in design mode exits design
41-
mode, then toggles the default (tools) bottom panel.
42-
- [ ] Running `Commands.CMD_FIND_IN_FILES` while in design mode exits
43-
design mode before the find bar / results panel mount.
44-
- [ ] Running `Commands.NAVIGATE_QUICK_OPEN` while in design mode
45-
exits design mode before Quick Open's modal bar is shown.
46-
- [ ] Clicking `#git-toolbar-icon` while in design mode exits design
47-
mode, then `Panel.toggle()` opens/closes the git panel.
48-
- [ ] In the above four cases, when NOT in design mode the auto-exit
49-
branch is skipped and the original behavior runs unchanged.
50-
51-
Future follow-ups (no tests yet — track as TODOs alongside the site
52-
comments added in the source files):
53-
54-
- [ ] Tools panel floats over live preview so users can peek without
55-
leaving design mode.
56-
- [ ] Find in Files renders an overlay modal bar and a floating
57-
results surface compatible with design mode.
58-
- [ ] Quick Open gets a spotlight-style floating picker usable in
59-
design mode.
60-
- [ ] Git panel gains a floating variant for design mode.
61-
6213
## 12. Integration with NoDistractions
6314

6415
- [ ] Design mode + toggling `noDistractions` preference to `true`:

test/spec/CentralControlBar-integ-test.js

Lines changed: 126 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ define(function (require, exports, module) {
4646
SidebarView = brackets.test.SidebarView;
4747
WorkspaceManager = brackets.test.WorkspaceManager;
4848
_$ = testWindow.$;
49+
// Load a real project with some files so anything that depends on a
50+
// populated project tree / file index (e.g. Quick Open's file picker)
51+
// has something to list. QuickOpen-test-files has a couple of html
52+
// files which are enough for the assertions here.
53+
await SpecRunnerUtils.loadProjectInTestWindow(
54+
SpecRunnerUtils.getTestPath("/spec/QuickOpen-test-files"));
4955
}, 30000);
5056

5157
afterAll(async function () {
@@ -899,18 +905,22 @@ define(function (require, exports, module) {
899905

900906
afterEach(async function () {
901907
await hideToolsPanelIfVisible();
902-
// Close any modal find/quick-open bars left open.
903-
if (_$("#find-what").length) {
904-
_$(testWindow.document).trigger(
905-
_$.Event("keydown", { keyCode: 27 /* Esc */ })
906-
);
908+
// Close any modal find / quick-open bars left open so the next
909+
// test starts with a clean DOM.
910+
const findInput = _$("#find-what")[0];
911+
if (findInput) {
912+
findInput.dispatchEvent(new testWindow.KeyboardEvent("keydown",
913+
{ keyCode: 27 /* Esc */, bubbles: true }));
914+
await awaitsFor(function () { return _$("#find-what").length === 0; },
915+
"find-in-files bar to close", 3000);
907916
}
908-
if (_$("input#quickOpenSearch").length) {
909-
_$(testWindow.document).trigger(
910-
_$.Event("keydown", { keyCode: 27 })
911-
);
917+
const qoInput = _$("input#quickOpenSearch")[0];
918+
if (qoInput) {
919+
qoInput.dispatchEvent(new testWindow.KeyboardEvent("keydown",
920+
{ keyCode: 27, bubbles: true }));
921+
await awaitsFor(function () { return _$("input#quickOpenSearch").length === 0; },
922+
"quick-open bar to close", 3000);
912923
}
913-
await awaits(0);
914924
});
915925

916926
it("should exit design mode and open the tools bottom panel when #app-drawer-button is clicked in design mode", async function () {
@@ -947,26 +957,115 @@ define(function (require, exports, module) {
947957
"find-in-files bar to mount", 3000);
948958
});
949959

950-
it("should stay in design mode and show a floating Quick Open bar when invoked in design mode", async function () {
951-
await enterDesignMode();
952-
expect(WorkspaceManager.isInDesignMode()).toBe(true);
960+
describe("Quick Open in design mode", function () {
961+
// Quick Open has a dedicated design-mode variant (Spotlight-style
962+
// floating overlay) instead of the usual ModalBar, so we cover its
963+
// core user-facing behaviours here: bar shows up, dropdown lists
964+
// project files, typing filters the list, pressing Enter opens
965+
// the selected file.
966+
967+
function $bar() { return _$(".quick-open-floating-bar"); }
968+
function $search() { return _$("input#quickOpenSearch"); }
969+
function $dropdownItems() { return _$(".quick-search-container li"); }
970+
971+
async function openQuickOpenInDesignMode() {
972+
await enterDesignMode();
973+
CommandManager.execute(Commands.NAVIGATE_QUICK_OPEN);
974+
await awaitsFor(function () { return $bar().length > 0; },
975+
"floating Quick Open bar to appear", 3000);
976+
await awaitsFor(function () { return $search().length > 0; },
977+
"Quick Open search input to exist", 2000);
978+
}
953979

954-
CommandManager.execute(Commands.NAVIGATE_QUICK_OPEN);
980+
async function typeInSearch(text) {
981+
$search().val(text);
982+
$search().trigger("input");
983+
}
955984

956-
// Quick Open uses a Spotlight-style floating bar in design mode
957-
// (rather than exiting) — users see the picker on top of the live
958-
// preview without losing design mode.
959-
await awaitsFor(function () {
960-
return _$(".quick-open-floating-bar").length > 0;
961-
}, "floating Quick Open bar to appear", 3000);
962-
expect(WorkspaceManager.isInDesignMode()).toBe(true);
985+
async function closeQuickOpen() {
986+
if ($bar().length === 0) { return; }
987+
const input = $search()[0];
988+
if (input) {
989+
input.dispatchEvent(new testWindow.KeyboardEvent("keydown",
990+
{ keyCode: 27, bubbles: true }));
991+
}
992+
await awaitsFor(function () { return $bar().length === 0; },
993+
"floating Quick Open bar to close", 3000);
994+
}
963995

964-
// Close the picker.
965-
const doc = testWindow.document;
966-
doc.dispatchEvent(new testWindow.KeyboardEvent("keydown", { keyCode: 27, bubbles: true }));
967-
await awaitsFor(function () {
968-
return _$(".quick-open-floating-bar").length === 0;
969-
}, "floating Quick Open bar to close", 3000);
996+
afterEach(async function () {
997+
await closeQuickOpen();
998+
});
999+
1000+
it("should show the floating bar and stay in design mode (no ModalBar)", async function () {
1001+
await openQuickOpenInDesignMode();
1002+
expect(WorkspaceManager.isInDesignMode()).toBe(true);
1003+
// Design-mode variant — the Quick Open search field lives inside
1004+
// the floating bar, not inside a normal ModalBar.
1005+
expect($search().closest(".quick-open-floating-bar").length).toBe(1);
1006+
expect($search().closest(".modal-bar").length).toBe(0);
1007+
});
1008+
1009+
it("should list project files in the dropdown", async function () {
1010+
await openQuickOpenInDesignMode();
1011+
await awaitsFor(function () { return $dropdownItems().length > 0; },
1012+
"Quick Open dropdown to populate with project files", 3000);
1013+
const names = $dropdownItems().map(function () {
1014+
return _$(this).text();
1015+
}).get().join(" | ");
1016+
// The test project (QuickOpen-test-files) has lotsOfLines.html
1017+
// and somelines.html — both should surface without any query.
1018+
expect(names).toContain("lotsOfLines.html");
1019+
expect(names).toContain("somelines.html");
1020+
});
1021+
1022+
it("should filter the dropdown as the user types", async function () {
1023+
await openQuickOpenInDesignMode();
1024+
await awaitsFor(function () { return $dropdownItems().length >= 2; },
1025+
"Quick Open dropdown to populate", 3000);
1026+
const beforeCount = $dropdownItems().length;
1027+
1028+
await typeInSearch("somelines");
1029+
await awaitsFor(function () {
1030+
const items = $dropdownItems();
1031+
if (items.length === 0) { return false; }
1032+
// Every visible item must match the filter.
1033+
let allMatch = true;
1034+
items.each(function () {
1035+
if (!/somelines/i.test(_$(this).text())) { allMatch = false; }
1036+
});
1037+
return allMatch && items.length < beforeCount;
1038+
}, "dropdown to filter down to matching items", 3000);
1039+
1040+
// The un-matching file shouldn't be present anymore.
1041+
const filteredNames = $dropdownItems().map(function () {
1042+
return _$(this).text();
1043+
}).get().join(" | ");
1044+
expect(filteredNames).toContain("somelines.html");
1045+
expect(filteredNames).not.toContain("lotsOfLines.html");
1046+
});
1047+
1048+
it("should open the selected file when Enter is pressed from the floating bar", async function () {
1049+
await openQuickOpenInDesignMode();
1050+
await awaitsFor(function () { return $dropdownItems().length >= 2; },
1051+
"Quick Open dropdown to populate", 3000);
1052+
1053+
await typeInSearch("somelines");
1054+
await awaitsFor(function () {
1055+
const items = $dropdownItems();
1056+
return items.length > 0 && /somelines/i.test(_$(items[0]).text());
1057+
}, "somelines.html to be the top match", 3000);
1058+
1059+
const input = $search()[0];
1060+
input.dispatchEvent(new testWindow.KeyboardEvent("keydown",
1061+
{ keyCode: 13 /* Enter */, bubbles: true }));
1062+
1063+
const DocumentManager = brackets.test.DocumentManager;
1064+
await awaitsFor(function () {
1065+
const doc = DocumentManager.getCurrentDocument();
1066+
return doc && doc.file && doc.file.name === "somelines.html";
1067+
}, "somelines.html to open in the editor", 5000);
1068+
});
9701069
});
9711070

9721071
it("should exit design mode when the git toolbar icon is clicked in design mode", async function () {

0 commit comments

Comments
 (0)