Files
Netcatty/components/vault/VaultPageHeader.test.ts
T
27a55f8b40 fix(window): fit main window to half-screen tiling cells (#4254)
* fix(window): fit main window to half-screen tiling cells

macOS and Windows window tiling keep the app's minimum size when the
requested cell is smaller, so the 1100x640 minimum pushed half-tiled
windows past the screen edge. Cap the effective minimum at half the
display work area minus the macOS tiling margin, and pull restored
bounds back inside the work area while preserving windows that span
adjacent displays.

Let Vault page headers wrap their action buttons on narrow half-screen
windows instead of clipping them.

Tests: window manager suite (127) and Vault header/layout tests pass.

Co-Authored-By: Claude Code <noreply@anthropic.com>

* fix(vault): allow nested VaultPageHeader action groups to wrap

---------

Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: bincxz <16399091+binaricat@users.noreply.github.com>
2026-11-23 17:04:14 +08:00

41 lines
2.0 KiB
TypeScript

import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import test from "node:test";
const source = readFileSync(new URL("./VaultPageHeader.tsx", import.meta.url), "utf8");
const keychainSource = readFileSync(new URL("../KeychainManager.tsx", import.meta.url), "utf8");
const knownHostsSource = readFileSync(new URL("../KnownHostsManager.tsx", import.meta.url), "utf8");
const portForwardingSource = readFileSync(new URL("../PortForwardingNew.tsx", import.meta.url), "utf8");
test("vault page headers wrap their actions instead of clipping them on narrow windows", () => {
// Half-screen tiling can hand the content a ~520px-wide surface. The fixed
// action buttons must move to a second row there instead of being cut off
// by the window edge.
assert.match(source, /min-h-14[^"]*flex-wrap/);
assert.match(source, /gap-y-2/);
assert.doesNotMatch(source, /"h-14 px-4 py-2 flex items-center gap-3 app-no-drag"/);
});
test("nested VaultPageHeader action groups wrap so controls stay visible at narrow half-screen widths", () => {
const keychainHeader = keychainSource.match(/<VaultPageHeader>[\s\S]*?<\/VaultPageHeader>/)?.[0] ?? "";
assert.ok(keychainHeader, "expected VaultPageHeader in KeychainManager.tsx");
assert.match(
keychainHeader,
/Action buttons: New Key \(split\) \| Import Certificate \| New Identity[\s\S]*?<div className="[^"]*flex-wrap[^"]*">/,
);
const knownHostsHeader = knownHostsSource.match(/<VaultPageHeader>[\s\S]*?<\/VaultPageHeader>/)?.[0] ?? "";
assert.ok(knownHostsHeader, "expected VaultPageHeader in KnownHostsManager.tsx");
assert.match(
knownHostsHeader,
/<div className="[^"]*flex-wrap[^"]*">\s*<Button[\s\S]*?knownHosts\.action\.scanSystem/,
);
const portForwardingHeader = portForwardingSource.match(/<VaultPageHeader[^>]*>[\s\S]*?<\/VaultPageHeader>/)?.[0] ?? "";
assert.ok(portForwardingHeader, "expected VaultPageHeader in PortForwardingNew.tsx");
assert.match(
portForwardingHeader,
/<div className="[^"]*flex-wrap[^"]*min-w-0[^"]*">\s*<VaultHeaderSearch/,
);
});