Skip to content

Commit 182daef

Browse files
devvaannshabose
authored andcommitted
fix: central control bar tests failing
1 parent e36afa6 commit 182daef

1 file changed

Lines changed: 17 additions & 9 deletions

File tree

test/spec/CentralControlBar-integ-test.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -887,30 +887,38 @@ define(function (require, exports, module) {
887887
expect(Math.abs(mtRect.right - testWindow.innerWidth)).toBeLessThan(2);
888888
});
889889

890-
it("should, in normal mode, resize only the plugin-panel (sidebar untouched) and respect the 75%/sidebar clamp", async function () {
890+
it("should, in normal mode, progressively shrink the sidebar when an oversized plugin-panel width is requested", async function () {
891891
await openLivePreview();
892892
const iconsW = _$("#plugin-icons-bar").outerWidth();
893893
const sidebarBefore = _$("#sidebar")[0].offsetWidth;
894894

895-
// Request a very wide panel — should be clamped against 75% window
896-
// and (window - sidebar - 100). Either way sidebar must stay put.
895+
// Request a very wide panel — the sidebar should shrink (or
896+
// collapse) to make room, then the toolbar is clamped to
897+
// (window - finalSidebarWidth - MIN_EDITOR_WIDTH).
897898
const requested = testWindow.innerWidth; // intentionally over-large
898899
WorkspaceManager.setPluginPanelWidth(requested);
899900
await awaits(0);
900901

901-
expect(_$("#sidebar")[0].offsetWidth).toBe(sidebarBefore);
902+
// Sidebar must have shrunk or collapsed to accommodate the request.
903+
const sidebarAfter = SidebarView.isVisible() ? _$("#sidebar")[0].offsetWidth : 0;
904+
expect(sidebarAfter).toBeLessThan(sidebarBefore);
902905

903906
const toolbar = _$("#main-toolbar").outerWidth();
904-
const maxAllowed = Math.min(
905-
testWindow.innerWidth * 0.75,
906-
testWindow.innerWidth - sidebarBefore - 100
907-
);
908-
// Toolbar must honour the clamp (+iconsBar = the WSM math).
907+
// Toolbar is clamped to (window - sidebar - MIN_EDITOR_WIDTH).
908+
const maxAllowed = testWindow.innerWidth - sidebarAfter - 100;
909909
expect(toolbar).toBeLessThanOrEqual(maxAllowed + 3);
910910
// And at minimum it's the icons-bar + LP's minWidth.
911911
const lp = livePanel();
912912
const minToolbar = (lp && lp.minWidth ? lp.minWidth : 0) + iconsW;
913913
expect(toolbar).toBeGreaterThanOrEqual(minToolbar);
914+
915+
// Restore sidebar for subsequent tests.
916+
if (!SidebarView.isVisible()) {
917+
SidebarView.show();
918+
await awaitsFor(function () { return SidebarView.isVisible(); },
919+
"sidebar to come back", 2000);
920+
}
921+
SidebarView.resize(200);
914922
});
915923
});
916924

0 commit comments

Comments
 (0)