Files
fusion/packages/dashboard/app/components/__tests__/agentsOrgChartLayout.test.ts
Fusion ad94ff3016 feat(FN-3472): expand org chart regression test assertions
The merge adds expanded regression assertions for the org chart feature, covering agent CSS classes and mobile agents view components. The tests verify styling and layout behavior across both desktop and mobile contexts.

Fusion-Task-Id: FN-3472
2026-05-05 07:05:41 -07:00

44 lines
1.5 KiB
TypeScript

import { describe, expect, it } from "vitest";
import type { OrgTreeNode } from "../../api";
import { estimateOrgChartWidth, resolveOrgChartLayoutMode } from "../agentsOrgChartLayout";
function makeNode(id: string, children: OrgTreeNode[] = []): OrgTreeNode {
return {
agent: {
id,
name: id,
role: "executor",
state: "active",
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
metadata: {},
},
children,
};
}
describe("agentsOrgChartLayout", () => {
it("returns horizontal when estimated width fits", () => {
const tree = [makeNode("root", [makeNode("child")])];
const width = estimateOrgChartWidth(tree);
expect(resolveOrgChartLayoutMode({ tree, availableWidth: width + 1 })).toBe("horizontal");
});
it("returns vertical when estimated width exceeds available width", () => {
const tree = [
makeNode("root", [
makeNode("a", [makeNode("a1"), makeNode("a2")]),
makeNode("b", [makeNode("b1"), makeNode("b2")]),
]),
makeNode("root-2", [makeNode("c"), makeNode("d")]),
];
expect(resolveOrgChartLayoutMode({ tree, availableWidth: 400 })).toBe("vertical");
});
it("stays horizontal for single-root trees and zero-width measurement", () => {
const tree = [makeNode("solo", [makeNode("child-1"), makeNode("child-2")])];
expect(resolveOrgChartLayoutMode({ tree, availableWidth: 0 })).toBe("horizontal");
expect(resolveOrgChartLayoutMode({ tree, availableWidth: 120 })).toBe("horizontal");
});
});