fix(FN-2158): constrain settings modal sidebar overflow

- Make .settings-layout fill available space and allow shrinking with flex: 1 and min-height: 0
- Enable vertical scrolling on .settings-sidebar in desktop layout to prevent content clipping
- Add a SettingsModal regression test that loads styles.css and asserts desktop overflow/scroll computed styles
This commit is contained in:
Fusion
2026-04-19 13:05:47 -07:00
committed by gsxdsm
parent e106d87fcb
commit 4c08b1c32a
2 changed files with 38 additions and 1 deletions

View File

@@ -1,3 +1,5 @@
import fs from "node:fs";
import path from "node:path";
import { useState } from "react";
import { describe, it, expect, vi, beforeEach } from "vitest";
import { render, screen, fireEvent, waitFor } from "@testing-library/react";
@@ -11,6 +13,19 @@ type SettingsWithAutoArchive = Settings & {
archiveAgentLogMode?: "none" | "compact" | "full";
};
const stylesPath = path.resolve(__dirname, "../../styles.css");
const ensureTestStylesLoaded = () => {
if (document.getElementById("settings-modal-test-styles")) {
return;
}
const styleTag = document.createElement("style");
styleTag.id = "settings-modal-test-styles";
styleTag.textContent = fs.readFileSync(stylesPath, "utf-8");
document.head.appendChild(styleTag);
};
const defaultSettings: SettingsWithAutoArchive = {
maxConcurrent: 2,
maxTriageConcurrent: 2,
@@ -2154,6 +2169,26 @@ describe("SettingsModal", () => {
expect(layout!.querySelector(".settings-content")).toBeTruthy();
});
it("applies scroll-constrained desktop layout styles to sidebar and layout", async () => {
ensureTestStylesLoaded();
const { container } = render(<SettingsModal onClose={onClose} addToast={addToast} />);
await waitFor(() => expect(fetchSettings).toHaveBeenCalled());
const layout = container.querySelector(".settings-layout") as HTMLElement | null;
const sidebar = container.querySelector(".settings-sidebar") as HTMLElement | null;
expect(layout).toBeTruthy();
expect(sidebar).toBeTruthy();
const layoutStyles = window.getComputedStyle(layout!);
const sidebarStyles = window.getComputedStyle(sidebar!);
expect(layoutStyles.flex).toContain("1");
expect(layoutStyles.overflow).toBe("hidden");
expect(sidebarStyles.overflowY).toBe("auto");
});
it("has .settings-sidebar with 17 .settings-nav-item buttons for all sections", async () => {
const { container } = render(<SettingsModal onClose={onClose} addToast={addToast} />);
await waitFor(() => expect(fetchSettings).toHaveBeenCalled());