feat: implement isBranchRowActionTarget function and add tests for branch row interaction
This commit is contained in:
@@ -5,6 +5,7 @@ import { cn } from "@/lib/utils"
|
|||||||
import { useWorkflowBranchSelection } from "./workflow-branch-selection"
|
import { useWorkflowBranchSelection } from "./workflow-branch-selection"
|
||||||
import {
|
import {
|
||||||
createConditionBranchID,
|
createConditionBranchID,
|
||||||
|
isBranchRowActionTarget,
|
||||||
normalizeNodeConfig,
|
normalizeNodeConfig,
|
||||||
type WorkflowConditionBranch,
|
type WorkflowConditionBranch,
|
||||||
} from "./workflow-utils"
|
} from "./workflow-utils"
|
||||||
@@ -99,6 +100,9 @@ function WorkflowConditionBranchRow({
|
|||||||
)}
|
)}
|
||||||
onPointerDownCapture={(event) => {
|
onPointerDownCapture={(event) => {
|
||||||
event.stopPropagation()
|
event.stopPropagation()
|
||||||
|
if (isBranchRowActionTarget(event.target)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
onSelect()
|
onSelect()
|
||||||
}}
|
}}
|
||||||
onMouseDownCapture={(event) => {
|
onMouseDownCapture={(event) => {
|
||||||
|
|||||||
@@ -262,6 +262,23 @@ describe("workflow variable display helpers", () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe("workflow branch interaction helpers", () => {
|
||||||
|
it("detects branch row action targets inside buttons", async () => {
|
||||||
|
const { isBranchRowActionTarget } = await loadModule()
|
||||||
|
|
||||||
|
assert.equal(isBranchRowActionTarget({
|
||||||
|
closest(selector) {
|
||||||
|
return selector === "button" ? {} : null
|
||||||
|
},
|
||||||
|
}), true)
|
||||||
|
assert.equal(isBranchRowActionTarget({
|
||||||
|
closest() {
|
||||||
|
return null
|
||||||
|
},
|
||||||
|
}), false)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe("workflow definition mutations", () => {
|
describe("workflow definition mutations", () => {
|
||||||
it("updates node data without changing unrelated nodes", async () => {
|
it("updates node data without changing unrelated nodes", async () => {
|
||||||
const { updateWorkflowNodeData } = await loadModule()
|
const { updateWorkflowNodeData } = await loadModule()
|
||||||
|
|||||||
@@ -126,6 +126,11 @@ export function buildVariableSpecDisplay(variable: WorkflowVariableSpec): Workfl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isBranchRowActionTarget(target: EventTarget | null): boolean {
|
||||||
|
const maybeElement = target as { closest?: (selector: string) => Element | null } | null
|
||||||
|
return typeof maybeElement?.closest === "function" && maybeElement.closest("button") !== null
|
||||||
|
}
|
||||||
|
|
||||||
export function getNodeTitle(
|
export function getNodeTitle(
|
||||||
node: AIWorkflowDefinition["nodes"][number] | undefined,
|
node: AIWorkflowDefinition["nodes"][number] | undefined,
|
||||||
specs: AIWorkflowNodeSpec[] = []
|
specs: AIWorkflowNodeSpec[] = []
|
||||||
|
|||||||
Reference in New Issue
Block a user