removed comments

This commit is contained in:
Adam Gough
2025-06-02 10:11:16 -07:00
parent 215e1e9831
commit 0d4849b812
3 changed files with 3 additions and 33 deletions
@@ -7,7 +7,6 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
// Mock the workflow registry store
const mockDeploymentStatus = {
isDeployed: false,
needsRedeployment: false,
@@ -41,11 +40,9 @@ describe('DeploymentControls Change Detection Logic', () => {
describe('needsRedeployment Priority Logic', () => {
it('should prioritize parent needsRedeployment over workflow registry', () => {
// Simulate the logic from DeploymentControls component
const parentNeedsRedeployment = true
const workflowRegistryNeedsRedeployment = false
// The component logic: Trust the parent's change detection
const workflowNeedsRedeployment = parentNeedsRedeployment
expect(workflowNeedsRedeployment).toBe(true)
@@ -60,19 +57,16 @@ describe('DeploymentControls Change Detection Logic', () => {
})
it('should maintain consistency with parent state changes', () => {
// Simulate state changes
let parentNeedsRedeployment = false
let workflowNeedsRedeployment = parentNeedsRedeployment
expect(workflowNeedsRedeployment).toBe(false)
// Parent detects changes
parentNeedsRedeployment = true
workflowNeedsRedeployment = parentNeedsRedeployment
expect(workflowNeedsRedeployment).toBe(true)
// Parent clears changes (after redeployment)
parentNeedsRedeployment = false
workflowNeedsRedeployment = parentNeedsRedeployment
@@ -82,7 +76,6 @@ describe('DeploymentControls Change Detection Logic', () => {
describe('Deployment Status Integration', () => {
it('should handle deployment status correctly', () => {
// Mock deployment status
mockDeploymentStatus.isDeployed = true
mockDeploymentStatus.needsRedeployment = false
@@ -95,7 +88,6 @@ describe('DeploymentControls Change Detection Logic', () => {
})
it('should handle missing deployment status', () => {
// Create a separate mock for this test case
const tempMockRegistry = {
getState: vi.fn(() => ({
getWorkflowDeploymentStatus: vi.fn(() => null),
@@ -112,7 +104,6 @@ describe('DeploymentControls Change Detection Logic', () => {
expect(deploymentStatus).toBe(null)
// Restore original mock
mockWorkflowRegistry.getState = originalMock
})
@@ -125,7 +116,6 @@ describe('DeploymentControls Change Detection Logic', () => {
.getState()
.getWorkflowDeploymentStatus('test-id')
// Should handle undefined properties gracefully
const isDeployed = deploymentStatus?.isDeployed || false
expect(isDeployed).toBe(false)
})
@@ -188,7 +178,6 @@ describe('DeploymentControls Change Detection Logic', () => {
it('should handle null activeWorkflowId gracefully', () => {
const deploymentStatus = mockWorkflowRegistry.getState().getWorkflowDeploymentStatus(null)
// Should return the mocked result without throwing
expect(deploymentStatus).toBeDefined()
})
})
@@ -207,16 +196,13 @@ describe('DeploymentControls Change Detection Logic', () => {
it('should maintain prop consistency across re-renders', () => {
let needsRedeployment = false
// Initial render
let componentProps = { needsRedeployment }
expect(componentProps.needsRedeployment).toBe(false)
// State change
needsRedeployment = true
componentProps = { needsRedeployment }
expect(componentProps.needsRedeployment).toBe(true)
// State change back
needsRedeployment = false
componentProps = { needsRedeployment }
expect(componentProps.needsRedeployment).toBe(false)
@@ -56,7 +56,6 @@ export function WorkflowPreview({
defaultPosition,
defaultZoom,
}: WorkflowPreviewProps) {
// Track structure changes efficiently
const blocksStructure = useMemo(
() => ({
count: Object.keys(workflowState.blocks || {}).length,
@@ -89,48 +88,39 @@ export function WorkflowPreview({
[workflowState.edges]
)
// Helper function to calculate absolute position for child blocks
const calculateAbsolutePosition = (
block: any,
blocks: Record<string, any>
): { x: number; y: number } => {
// If no parent, use the block's position as-is
if (!block.data?.parentId) {
return block.position
}
// Find the parent block
const parentBlock = blocks[block.data.parentId]
if (!parentBlock) {
logger.warn(`Parent block not found for child block: ${block.id}`)
return block.position
}
// Recursively calculate parent's absolute position (for nested containers)
const parentAbsolutePosition = calculateAbsolutePosition(parentBlock, blocks)
// Add parent's absolute position to child's relative position
return {
x: parentAbsolutePosition.x + block.position.x,
y: parentAbsolutePosition.y + block.position.y,
}
}
// Transform blocks and loops into ReactFlow nodes
const nodes: Node[] = useMemo(() => {
const nodeArray: Node[] = []
// Add block nodes using the same approach as workflow.tsx
Object.entries(workflowState.blocks).forEach(([blockId, block]) => {
if (!block || !block.type) {
logger.warn(`Skipping invalid block: ${blockId}`)
return
}
// Calculate absolute position for proper preview positioning
const absolutePosition = calculateAbsolutePosition(block, workflowState.blocks)
// Handle container nodes (loop and parallel) differently
if (block.type === 'loop') {
nodeArray.push({
id: block.id,
@@ -169,14 +159,12 @@ export function WorkflowPreview({
return
}
// Handle regular blocks
const blockConfig = getBlock(block.type)
if (!blockConfig) {
logger.error(`No configuration found for block type: ${block.type}`, { blockId })
return
}
// Create a deep clone of subBlocks to avoid any references to the original state
const subBlocksClone = block.subBlocks ? cloneDeep(block.subBlocks) : {}
nodeArray.push({
@@ -195,14 +183,11 @@ export function WorkflowPreview({
},
})
// Add children of this block if it's a loop (for nested blocks)
if (block.type === 'loop') {
// Find all children of this loop
const childBlocks = Object.entries(workflowState.blocks).filter(
([_, childBlock]) => childBlock.data?.parentId === blockId
)
// Add all child blocks to the node array
childBlocks.forEach(([childId, childBlock]) => {
const childConfig = getBlock(childBlock.type)
@@ -210,10 +195,9 @@ export function WorkflowPreview({
nodeArray.push({
id: childId,
type: 'workflowBlock',
// Position child blocks relative to the parent
position: {
x: block.position.x + 50, // Offset children to the right
y: block.position.y + (childBlock.position?.y || 100), // Preserve vertical positioning
x: block.position.x + 50,
y: block.position.y + (childBlock.position?.y || 100),
},
data: {
type: childBlock.type,
@@ -236,7 +220,6 @@ export function WorkflowPreview({
return nodeArray
}, [blocksStructure, loopsStructure, parallelsStructure, showSubBlocks, workflowState.blocks])
// Transform edges
const edges: Edge[] = useMemo(() => {
return workflowState.edges.map((edge) => ({
id: edge.id,
@@ -100,6 +100,7 @@ export function WorkflowCard({ workflow, onHover }: WorkflowCardProps) {
workflowState={{
...workflow.workflowState,
parallels: workflow.workflowState.parallels || {},
loops: workflow.workflowState.loops || {},
}}
/>
</div>