Skip to content

Commit b0feacd

Browse files
devvaannshabose
authored andcommitted
feat: tests covering the new live preview full screen mode
1 parent 8422d24 commit b0feacd

1 file changed

Lines changed: 157 additions & 0 deletions

File tree

test/spec/CentralControlBar-integ-test.js

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,5 +1316,162 @@ define(function (require, exports, module) {
13161316
expect(CentralControlBar.isEditorCollapsed()).toBe(false);
13171317
});
13181318
});
1319+
1320+
describe("14. Live preview full screen", function () {
1321+
// Full screen is derived state: live preview is full screen exactly when
1322+
// the editor is collapsed and the sidebar is away. These cover the state
1323+
// rule and the enter/exit contract, not icon classes or tooltip strings.
1324+
let PreferencesManager;
1325+
1326+
beforeAll(function () {
1327+
PreferencesManager = brackets.test.PreferencesManager;
1328+
});
1329+
1330+
async function enterFullScreen() {
1331+
if (WorkspaceManager.isInLPFullScreen()) {
1332+
return;
1333+
}
1334+
CommandManager.execute(Commands.VIEW_TOGGLE_LP_FULL_SCREEN);
1335+
await awaitsFor(function () { return WorkspaceManager.isInLPFullScreen(); },
1336+
"full screen to activate", 10000);
1337+
await awaitsFor(function () {
1338+
const p = livePanel();
1339+
return p && p.isVisible();
1340+
}, "live preview to be visible in full screen", 10000);
1341+
}
1342+
1343+
async function exitFullScreen() {
1344+
if (!WorkspaceManager.isInLPFullScreen()) {
1345+
return;
1346+
}
1347+
CommandManager.execute(Commands.VIEW_TOGGLE_LP_FULL_SCREEN);
1348+
await awaitsFor(function () { return !WorkspaceManager.isInLPFullScreen(); },
1349+
"full screen to deactivate", 10000);
1350+
}
1351+
1352+
it("should collapse the editor and give live preview the full width minus the control bar",
1353+
async function () {
1354+
await openLivePreview();
1355+
await enterFullScreen();
1356+
1357+
expect(WorkspaceManager.isInDesignMode()).toBe(true);
1358+
expect(SidebarView.isVisible()).toBe(false);
1359+
1360+
const ccbLeft = _$("#centralControlBar")[0].getBoundingClientRect().left;
1361+
expect(ccbLeft).toBeLessThan(2);
1362+
1363+
const mtWidth = _$("#main-toolbar").outerWidth();
1364+
expect(Math.abs(mtWidth - (testWindow.innerWidth - CCB_WIDTH))).toBeLessThan(5);
1365+
});
1366+
1367+
it("should return to the code editor with the sidebar back when entered from the editor",
1368+
async function () {
1369+
await openLivePreview();
1370+
await enterFullScreen();
1371+
await exitFullScreen();
1372+
1373+
expect(WorkspaceManager.isInDesignMode()).toBe(false);
1374+
expect(SidebarView.isVisible()).toBe(true);
1375+
// Live preview was open before full screen, so it stays open.
1376+
expect(livePanel().isVisible()).toBe(true);
1377+
});
1378+
1379+
it("should return to design mode, not the editor, when entered from design mode",
1380+
async function () {
1381+
await enterDesignMode();
1382+
await enterFullScreen();
1383+
await exitFullScreen();
1384+
1385+
expect(WorkspaceManager.isInDesignMode()).toBe(true);
1386+
expect(SidebarView.isVisible()).toBe(true);
1387+
});
1388+
1389+
it("should turn on and off as the sidebar is hidden and shown in design mode", async function () {
1390+
await enterDesignMode();
1391+
expect(WorkspaceManager.isInLPFullScreen()).toBe(false);
1392+
1393+
SidebarView.hide();
1394+
await awaitsFor(function () { return WorkspaceManager.isInLPFullScreen(); },
1395+
"full screen to follow the sidebar collapsing", 3000);
1396+
1397+
SidebarView.show();
1398+
await awaitsFor(function () { return !WorkspaceManager.isInLPFullScreen(); },
1399+
"full screen to follow the sidebar coming back", 3000);
1400+
// Only the sidebar came back, the editor stays collapsed.
1401+
expect(WorkspaceManager.isInDesignMode()).toBe(true);
1402+
});
1403+
1404+
it("should not be full screen when the sidebar is hidden but the editor is still up",
1405+
async function () {
1406+
expect(WorkspaceManager.isInDesignMode()).toBe(false);
1407+
1408+
SidebarView.hide();
1409+
await awaitsFor(function () { return !SidebarView.isVisible(); },
1410+
"sidebar to hide", 2000);
1411+
1412+
expect(WorkspaceManager.isInLPFullScreen()).toBe(false);
1413+
});
1414+
1415+
it("should drop to design mode when the CCB sidebar toggle is clicked in full screen",
1416+
async function () {
1417+
await openLivePreview();
1418+
await enterFullScreen();
1419+
1420+
_$("#ccbSidebarToggleBtn").trigger("click");
1421+
1422+
await awaitsFor(function () { return !WorkspaceManager.isInLPFullScreen(); },
1423+
"full screen to exit on sidebar toggle", 5000);
1424+
expect(WorkspaceManager.isInDesignMode()).toBe(true);
1425+
expect(SidebarView.isVisible()).toBe(true);
1426+
});
1427+
1428+
it("should leave the stored sidebar visibility alone so quitting from full screen restores it",
1429+
async function () {
1430+
await openLivePreview();
1431+
await enterFullScreen();
1432+
1433+
// Resizer writes visible:false on hide. Full screen is not a
1434+
// persisted mode, so the stored flag must stay true or the next
1435+
// launch comes up with no sidebar.
1436+
expect(SidebarView.isVisible()).toBe(false);
1437+
expect(PreferencesManager.getViewState("sidebar").visible).toBe(true);
1438+
});
1439+
1440+
it("should keep the sidebar hidden on exit when the user hid it themselves", async function () {
1441+
await openLivePreview();
1442+
SidebarView.hide();
1443+
await awaitsFor(function () { return !SidebarView.isVisible(); },
1444+
"sidebar to hide", 2000);
1445+
1446+
await enterFullScreen();
1447+
await exitFullScreen();
1448+
1449+
expect(SidebarView.isVisible()).toBe(false);
1450+
});
1451+
1452+
it("should exit and restore the sidebar when live preview is closed in full screen",
1453+
async function () {
1454+
await openLivePreview();
1455+
await enterFullScreen();
1456+
1457+
livePanel().hide();
1458+
1459+
await awaitsFor(function () { return !WorkspaceManager.isInLPFullScreen(); },
1460+
"full screen to exit when live preview closes", 5000);
1461+
expect(WorkspaceManager.isInDesignMode()).toBe(false);
1462+
expect(SidebarView.isVisible()).toBe(true);
1463+
});
1464+
1465+
it("should dispatch VIEW_TOGGLE_LP_FULL_SCREEN from the live preview expand button",
1466+
async function () {
1467+
await openLivePreview();
1468+
1469+
const executed = recordCommands(function () {
1470+
_$("#fullScreenLivePreviewButton").trigger("click");
1471+
});
1472+
1473+
expect(executed).toContain(Commands.VIEW_TOGGLE_LP_FULL_SCREEN);
1474+
});
1475+
});
13191476
});
13201477
});

0 commit comments

Comments
 (0)