Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions frontend/layout/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ export function setTransform(
top: 0,
left: 0,
transform: translate,
WebkitTransform: translate,
MozTransform: translate,
msTransform: translate,
OTransform: translate,
width: setSize ? `${widthRounded}px` : undefined,
height: setSize ? `${heightRounded}px` : undefined,
position: "absolute",
Expand Down
21 changes: 11 additions & 10 deletions frontend/layout/tests/layoutTree.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ import {
import { newLayoutTreeState } from "./model";

test("layoutTreeStateReducer - compute move", () => {
let treeState = newLayoutTreeState(newLayoutNode(undefined, undefined, undefined, { blockId: "root" }));
assert(treeState.rootNode.data!.blockId === "root", "root should have no children and should have data");
let node1 = newLayoutNode(undefined, undefined, undefined, { blockId: "node1" });
const nodeA = newLayoutNode(undefined, undefined, undefined, { blockId: "nodeA" });
const node1 = newLayoutNode(undefined, undefined, undefined, { blockId: "node1" });
const node2 = newLayoutNode(undefined, undefined, undefined, { blockId: "node2" });
const treeState = newLayoutTreeState(newLayoutNode(undefined, undefined, [nodeA, node1, node2]));
assert(treeState.rootNode.children!.length === 3, "root should have three children");
Comment on lines +16 to +20
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

This setup turns the first move into a no-op.

node1 already starts at index 1, and the test later asserts that the computed insert index is also 1, so the first moveNode() no longer exercises an actual reorder. That weakens coverage for the same-parent/root move path this test used to protect. Consider seeding node1 at a different initial position or asserting a sibling-order change after the move.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/layout/tests/layoutTree.test.ts` around lines 16 - 20, The test
currently seeds node1 at index 1 so the first move becomes a no-op; update the
setup that constructs the nodes (newLayoutNode, newLayoutTreeState, and
treeState.rootNode.children) so node1 is placed at a different initial index
(e.g., move node1 to the end of the children list or swap creation order with
node2) OR, alternatively, keep the current order but change the assertions after
calling moveNode to assert that the sibling order actually changed (compare
treeState.rootNode.children sequence before and after the move) to ensure the
same-parent/root move path is exercised.

let pendingAction = computeMoveNode(treeState, {
type: LayoutTreeActionType.ComputeMove,
nodeId: treeState.rootNode.id,
Expand All @@ -29,12 +31,11 @@ test("layoutTreeStateReducer - compute move", () => {
assert(insertOperation.insertAtRoot, "insert operation insertAtRoot should be true");
moveNode(treeState, insertOperation);
assert(
treeState.rootNode.data === undefined && treeState.rootNode.children!.length === 2,
"root node should now have no data and should have two children"
treeState.rootNode.data === undefined && treeState.rootNode.children!.length === 3,
"root node should still have three children"
);
assert(treeState.rootNode.children![1].data!.blockId === "node1", "root's second child should be node1");

let node2 = newLayoutNode(undefined, undefined, undefined, { blockId: "node2" });
pendingAction = computeMoveNode(treeState, {
type: LayoutTreeActionType.ComputeMove,
nodeId: node1.id,
Expand All @@ -48,15 +49,15 @@ test("layoutTreeStateReducer - compute move", () => {
assert(!insertOperation2.insertAtRoot, "insert operation insertAtRoot should be false");
moveNode(treeState, insertOperation2);
assert(
treeState.rootNode.data === undefined && treeState.rootNode.children!.length === 2,
"root node should still have three children"
treeState.rootNode.data === undefined && (treeState.rootNode.children!.length as number) === 2,
"root node should now have two children after node2 moved into node1"
);
assert(treeState.rootNode.children![1].children!.length === 2, "root's second child should now have two children");
});

test("computeMove - noop action", () => {
let nodeToMove = newLayoutNode(undefined, undefined, undefined, { blockId: "nodeToMove" });
let treeState = newLayoutTreeState(
const nodeToMove = newLayoutNode(undefined, undefined, undefined, { blockId: "nodeToMove" });
const treeState = newLayoutTreeState(
newLayoutNode(undefined, undefined, [
nodeToMove,
newLayoutNode(undefined, undefined, undefined, { blockId: "otherNode" }),
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading