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 {
|
||||
createConditionBranchID,
|
||||
isBranchRowActionTarget,
|
||||
normalizeNodeConfig,
|
||||
type WorkflowConditionBranch,
|
||||
} from "./workflow-utils"
|
||||
@@ -99,6 +100,9 @@ function WorkflowConditionBranchRow({
|
||||
)}
|
||||
onPointerDownCapture={(event) => {
|
||||
event.stopPropagation()
|
||||
if (isBranchRowActionTarget(event.target)) {
|
||||
return
|
||||
}
|
||||
onSelect()
|
||||
}}
|
||||
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", () => {
|
||||
it("updates node data without changing unrelated nodes", async () => {
|
||||
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(
|
||||
node: AIWorkflowDefinition["nodes"][number] | undefined,
|
||||
specs: AIWorkflowNodeSpec[] = []
|
||||
|
||||
Reference in New Issue
Block a user