test(FN-4549): complete Step 7 — keep persistence/orientation regressions green
Fusion-Task-Id: FN-4549 Fusion-Task-Lineage: 7c6b974d-cad9-418c-bf02-9d8490725c6e
This commit is contained in:
@@ -15,7 +15,7 @@ const onPointerUp = vi.fn();
|
||||
const setGraphBounds = vi.fn();
|
||||
const clearSavedPositions = vi.fn();
|
||||
let mockSavedPositions: NodePositions | null = null;
|
||||
let resizeObserverCallback: ResizeObserverCallback | null = null;
|
||||
let resizeObserverCallbacks: ResizeObserverCallback[] = [];
|
||||
|
||||
vi.mock("@fusion/dashboard/app/components/TaskCard", () => ({
|
||||
TaskCard: ({ task, onOpenDetail, disableDrag }: { task: Task; onOpenDetail: (task: Task) => void; disableDrag?: boolean }) => (
|
||||
@@ -58,7 +58,9 @@ function setViewportSize(width: number, height: number): void {
|
||||
if (!viewport) throw new Error("missing viewport");
|
||||
Object.defineProperty(viewport, "clientWidth", { value: width, configurable: true });
|
||||
Object.defineProperty(viewport, "clientHeight", { value: height, configurable: true });
|
||||
resizeObserverCallback?.([{ contentRect: { width, height } } as ResizeObserverEntry], {} as ResizeObserver);
|
||||
resizeObserverCallbacks.forEach((callback) => {
|
||||
callback([{ contentRect: { width, height } } as ResizeObserverEntry], {} as ResizeObserver);
|
||||
});
|
||||
}
|
||||
|
||||
function readNodePosition(taskId: string): { left: number; top: number } {
|
||||
@@ -82,13 +84,13 @@ describe("DependencyGraph", () => {
|
||||
setGraphBounds.mockReset();
|
||||
clearSavedPositions.mockReset();
|
||||
mockSavedPositions = null;
|
||||
resizeObserverCallback = null;
|
||||
resizeObserverCallbacks = [];
|
||||
|
||||
vi.stubGlobal(
|
||||
"ResizeObserver",
|
||||
class {
|
||||
constructor(callback: ResizeObserverCallback) {
|
||||
resizeObserverCallback = callback;
|
||||
resizeObserverCallbacks.push(callback);
|
||||
}
|
||||
|
||||
observe() {}
|
||||
|
||||
@@ -61,9 +61,9 @@ describe("DependencyGraph FN-4549 vertical overlap", () => {
|
||||
/>,
|
||||
);
|
||||
|
||||
setNodeHeight("A", 320);
|
||||
setNodeHeight("A", 180);
|
||||
setNodeHeight("B", 240);
|
||||
setNodeHeight("C", 180);
|
||||
setNodeHeight("C", 320);
|
||||
triggerResize();
|
||||
|
||||
await waitFor(() => {
|
||||
@@ -76,10 +76,10 @@ describe("DependencyGraph FN-4549 vertical overlap", () => {
|
||||
const topC = Number.parseFloat(nodeC.style.top);
|
||||
|
||||
expect(Number.isFinite(topA)).toBe(true);
|
||||
expect(topB).toBeGreaterThan(topA);
|
||||
expect(topC).toBeGreaterThan(topB);
|
||||
expect(topB).toBeGreaterThanOrEqual(topA + 320);
|
||||
expect(topC).toBeGreaterThanOrEqual(topB + 240);
|
||||
expect(topB).toBeGreaterThan(topC);
|
||||
expect(topA).toBeGreaterThan(topB);
|
||||
expect(topB).toBeGreaterThanOrEqual(topC + 320);
|
||||
expect(topA).toBeGreaterThanOrEqual(topB + 240);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -81,15 +81,15 @@ describe("computeAutoLayout", () => {
|
||||
orientation: "vertical",
|
||||
nodeHeight,
|
||||
verticalGap,
|
||||
measuredHeights: new Map([["A", 300]]),
|
||||
measuredHeights: new Map([["C", 300]]),
|
||||
},
|
||||
);
|
||||
|
||||
const aY = positions.get("A")?.y ?? 0;
|
||||
const bY = positions.get("B")?.y ?? 0;
|
||||
const cY = positions.get("C")?.y ?? 0;
|
||||
expect(bY).toBeGreaterThanOrEqual(aY + 300 + verticalGap);
|
||||
expect(cY).toBeGreaterThanOrEqual(bY + nodeHeight + verticalGap);
|
||||
expect(bY).toBeGreaterThanOrEqual(cY + 300 + verticalGap);
|
||||
expect(aY).toBeGreaterThanOrEqual(bY + nodeHeight + verticalGap);
|
||||
});
|
||||
|
||||
it("uses per-layer max measured heights for wide layers", () => {
|
||||
|
||||
Reference in New Issue
Block a user