feat: row detail options for hosts and credentials, open manage from sidebar header

This commit is contained in:
LukeGus committed 2026-10-06 14:41:57 -05:00
1 parent 08db1fcdde
commit a72aa5b57b
18 files changed
+415 -45

No files matched your search

@@ -56,3 +56,31 @@ describe("getCredentialRowHeight", () => {
).toBe(base);
});
});
describe("detail row", () => {
it("drops the username line height in comfortable density only", () => {
const shape = {
isKey: false,
alwaysShowActions: false,
actionsOnly: false,
isOpen: false,
showTags: false,
tagCount: 0,
};
const full = getCredentialRowHeight({ density: "comfortable", ...shape });
expect(
getCredentialRowHeight({
density: "comfortable",
...shape,
hasDetailRow: false,
}),
).toBe(full - 15);
expect(
getCredentialRowHeight({
density: "compact",
...shape,
hasDetailRow: false,
}),
).toBe(getCredentialRowHeight({ density: "compact", ...shape }));
});
});
@@ -43,7 +43,11 @@ vi.mock("@/main-axios", () => ({
getHostPassword: vi.fn(),
}));
import { HostItem } from "../../../../sidebar/tree/HostItem/HostItem";
import {
HostItem,
formatHostAddress,
} from "../../../../sidebar/tree/HostItem/HostItem";
import { defaultHostRowFields } from "@/types/host-sidebar-preferences";
const baseHost: Host = {
id: "1",
@@ -356,3 +360,45 @@ describe("HostItem click behavior", () => {
}
});
});
describe("HostItem row fields", () => {
function renderWith(
fields: Partial<ReturnType<typeof defaultHostRowFields>>,
) {
return render(
<HostItem
host={baseHost}
onOpenTab={noop}
onEditHost={noop}
onDelete={noop}
onDuplicate={noop}
density="comfortable"
rowFields={{ ...defaultHostRowFields(), ...fields }}
/>,
);
}
it("shows user@address by default", () => {
renderWith({});
expect(screen.getByText("root@10.0.0.5")).toBeTruthy();
});
it("hides the address when turned off", () => {
renderWith({ showAddress: false });
expect(screen.queryByText(/10\.0\.0\.5/)).toBeNull();
});
it("hides the pin icon when turned off", () => {
renderWith({ showPinIcon: false });
expect(document.querySelector(".lucide-pin")).toBeNull();
});
it("formats the address from the chosen parts", () => {
expect(
formatHostAddress(baseHost, { showUsername: false, showPort: true }),
).toBe("10.0.0.5:22");
expect(
formatHostAddress(baseHost, { showUsername: true, showPort: false }),
).toBe("root@10.0.0.5");
});
});
@@ -20,6 +20,11 @@ describe("defaultCredentialSidebarPreferences", () => {
density: "comfortable",
showTags: true,
trayTrigger: "always",
showUsername: true,
showUsageCount: true,
showTypeBadge: true,
showPinIcon: true,
showSharedBadge: true,
},
});
});
@@ -51,6 +56,11 @@ describe("sanitizeCredentialSidebarPreferences", () => {
density: "compact",
showTags: false,
trayTrigger: "click",
showUsername: false,
showUsageCount: false,
showTypeBadge: false,
showPinIcon: true,
showSharedBadge: false,
},
};
expect(sanitizeCredentialSidebarPreferences(valid)).toEqual(valid);
@@ -90,3 +100,14 @@ describe("sanitizeCredentialSidebarPreferences", () => {
expect(result.version).toBe(CREDENTIAL_SIDEBAR_PREFS_VERSION);
});
});
describe("credential row fields", () => {
it("keeps boolean choices and defaults the rest", () => {
const prefs = sanitizeCredentialSidebarPreferences({
display: { showUsername: false, showTypeBadge: "off" },
});
expect(prefs.display.showUsername).toBe(false);
expect(prefs.display.showTypeBadge).toBe(true);
expect(prefs.display.showUsageCount).toBe(true);
});
});
@@ -29,6 +29,12 @@ describe("defaultHostSidebarPreferences", () => {
showFolderPaths: true,
hostClickBehavior: "newTab",
barActions: {},
showAddress: true,
showUsername: true,
showPort: false,
showPinIcon: true,
showSharedBadge: true,
showBadges: true,
},
});
});
@@ -69,6 +75,12 @@ describe("sanitizeHostSidebarPreferences", () => {
showFolderPaths: false,
hostClickBehavior: "focusExistingDoubleClickNew",
barActions: { maintenance: true },
showAddress: false,
showUsername: false,
showPort: true,
showPinIcon: false,
showSharedBadge: false,
showBadges: true,
},
};
expect(sanitizeHostSidebarPreferences(valid)).toEqual(valid);
@@ -174,3 +186,23 @@ describe("barActions", () => {
).toEqual({});
});
});
describe("row fields", () => {
it("keeps boolean row field choices", () => {
const prefs = sanitizeHostSidebarPreferences({
display: { showAddress: false, showPort: true, showBadges: false },
});
expect(prefs.display.showAddress).toBe(false);
expect(prefs.display.showPort).toBe(true);
expect(prefs.display.showBadges).toBe(false);
expect(prefs.display.showUsername).toBe(true);
});
it("falls back to defaults for non-boolean values", () => {
const prefs = sanitizeHostSidebarPreferences({
display: { showAddress: "no", showPort: 1 },
});
expect(prefs.display.showAddress).toBe(true);
expect(prefs.display.showPort).toBe(false);
});
});