Skip to content

Commit 0d4849b

Browse files
Adam GoughAdam Gough
authored andcommitted
removed comments
1 parent 215e1e9 commit 0d4849b

3 files changed

Lines changed: 3 additions & 33 deletions

File tree

apps/sim/app/w/[id]/components/control-bar/components/deployment-controls/deployment-controls.test.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
99

10-
// Mock the workflow registry store
1110
const mockDeploymentStatus = {
1211
isDeployed: false,
1312
needsRedeployment: false,
@@ -41,11 +40,9 @@ describe('DeploymentControls Change Detection Logic', () => {
4140

4241
describe('needsRedeployment Priority Logic', () => {
4342
it('should prioritize parent needsRedeployment over workflow registry', () => {
44-
// Simulate the logic from DeploymentControls component
4543
const parentNeedsRedeployment = true
4644
const workflowRegistryNeedsRedeployment = false
4745

48-
// The component logic: Trust the parent's change detection
4946
const workflowNeedsRedeployment = parentNeedsRedeployment
5047

5148
expect(workflowNeedsRedeployment).toBe(true)
@@ -60,19 +57,16 @@ describe('DeploymentControls Change Detection Logic', () => {
6057
})
6158

6259
it('should maintain consistency with parent state changes', () => {
63-
// Simulate state changes
6460
let parentNeedsRedeployment = false
6561
let workflowNeedsRedeployment = parentNeedsRedeployment
6662

6763
expect(workflowNeedsRedeployment).toBe(false)
6864

69-
// Parent detects changes
7065
parentNeedsRedeployment = true
7166
workflowNeedsRedeployment = parentNeedsRedeployment
7267

7368
expect(workflowNeedsRedeployment).toBe(true)
7469

75-
// Parent clears changes (after redeployment)
7670
parentNeedsRedeployment = false
7771
workflowNeedsRedeployment = parentNeedsRedeployment
7872

@@ -82,7 +76,6 @@ describe('DeploymentControls Change Detection Logic', () => {
8276

8377
describe('Deployment Status Integration', () => {
8478
it('should handle deployment status correctly', () => {
85-
// Mock deployment status
8679
mockDeploymentStatus.isDeployed = true
8780
mockDeploymentStatus.needsRedeployment = false
8881

@@ -95,7 +88,6 @@ describe('DeploymentControls Change Detection Logic', () => {
9588
})
9689

9790
it('should handle missing deployment status', () => {
98-
// Create a separate mock for this test case
9991
const tempMockRegistry = {
10092
getState: vi.fn(() => ({
10193
getWorkflowDeploymentStatus: vi.fn(() => null),
@@ -112,7 +104,6 @@ describe('DeploymentControls Change Detection Logic', () => {
112104

113105
expect(deploymentStatus).toBe(null)
114106

115-
// Restore original mock
116107
mockWorkflowRegistry.getState = originalMock
117108
})
118109

@@ -125,7 +116,6 @@ describe('DeploymentControls Change Detection Logic', () => {
125116
.getState()
126117
.getWorkflowDeploymentStatus('test-id')
127118

128-
// Should handle undefined properties gracefully
129119
const isDeployed = deploymentStatus?.isDeployed || false
130120
expect(isDeployed).toBe(false)
131121
})
@@ -188,7 +178,6 @@ describe('DeploymentControls Change Detection Logic', () => {
188178
it('should handle null activeWorkflowId gracefully', () => {
189179
const deploymentStatus = mockWorkflowRegistry.getState().getWorkflowDeploymentStatus(null)
190180

191-
// Should return the mocked result without throwing
192181
expect(deploymentStatus).toBeDefined()
193182
})
194183
})
@@ -207,16 +196,13 @@ describe('DeploymentControls Change Detection Logic', () => {
207196
it('should maintain prop consistency across re-renders', () => {
208197
let needsRedeployment = false
209198

210-
// Initial render
211199
let componentProps = { needsRedeployment }
212200
expect(componentProps.needsRedeployment).toBe(false)
213201

214-
// State change
215202
needsRedeployment = true
216203
componentProps = { needsRedeployment }
217204
expect(componentProps.needsRedeployment).toBe(true)
218205

219-
// State change back
220206
needsRedeployment = false
221207
componentProps = { needsRedeployment }
222208
expect(componentProps.needsRedeployment).toBe(false)

apps/sim/app/w/components/workflow-preview/workflow-preview.tsx

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ export function WorkflowPreview({
5656
defaultPosition,
5757
defaultZoom,
5858
}: WorkflowPreviewProps) {
59-
// Track structure changes efficiently
6059
const blocksStructure = useMemo(
6160
() => ({
6261
count: Object.keys(workflowState.blocks || {}).length,
@@ -89,48 +88,39 @@ export function WorkflowPreview({
8988
[workflowState.edges]
9089
)
9190

92-
// Helper function to calculate absolute position for child blocks
9391
const calculateAbsolutePosition = (
9492
block: any,
9593
blocks: Record<string, any>
9694
): { x: number; y: number } => {
97-
// If no parent, use the block's position as-is
9895
if (!block.data?.parentId) {
9996
return block.position
10097
}
10198

102-
// Find the parent block
10399
const parentBlock = blocks[block.data.parentId]
104100
if (!parentBlock) {
105101
logger.warn(`Parent block not found for child block: ${block.id}`)
106102
return block.position
107103
}
108104

109-
// Recursively calculate parent's absolute position (for nested containers)
110105
const parentAbsolutePosition = calculateAbsolutePosition(parentBlock, blocks)
111106

112-
// Add parent's absolute position to child's relative position
113107
return {
114108
x: parentAbsolutePosition.x + block.position.x,
115109
y: parentAbsolutePosition.y + block.position.y,
116110
}
117111
}
118112

119-
// Transform blocks and loops into ReactFlow nodes
120113
const nodes: Node[] = useMemo(() => {
121114
const nodeArray: Node[] = []
122115

123-
// Add block nodes using the same approach as workflow.tsx
124116
Object.entries(workflowState.blocks).forEach(([blockId, block]) => {
125117
if (!block || !block.type) {
126118
logger.warn(`Skipping invalid block: ${blockId}`)
127119
return
128120
}
129121

130-
// Calculate absolute position for proper preview positioning
131122
const absolutePosition = calculateAbsolutePosition(block, workflowState.blocks)
132123

133-
// Handle container nodes (loop and parallel) differently
134124
if (block.type === 'loop') {
135125
nodeArray.push({
136126
id: block.id,
@@ -169,14 +159,12 @@ export function WorkflowPreview({
169159
return
170160
}
171161

172-
// Handle regular blocks
173162
const blockConfig = getBlock(block.type)
174163
if (!blockConfig) {
175164
logger.error(`No configuration found for block type: ${block.type}`, { blockId })
176165
return
177166
}
178167

179-
// Create a deep clone of subBlocks to avoid any references to the original state
180168
const subBlocksClone = block.subBlocks ? cloneDeep(block.subBlocks) : {}
181169

182170
nodeArray.push({
@@ -195,25 +183,21 @@ export function WorkflowPreview({
195183
},
196184
})
197185

198-
// Add children of this block if it's a loop (for nested blocks)
199186
if (block.type === 'loop') {
200-
// Find all children of this loop
201187
const childBlocks = Object.entries(workflowState.blocks).filter(
202188
([_, childBlock]) => childBlock.data?.parentId === blockId
203189
)
204190

205-
// Add all child blocks to the node array
206191
childBlocks.forEach(([childId, childBlock]) => {
207192
const childConfig = getBlock(childBlock.type)
208193

209194
if (childConfig) {
210195
nodeArray.push({
211196
id: childId,
212197
type: 'workflowBlock',
213-
// Position child blocks relative to the parent
214198
position: {
215-
x: block.position.x + 50, // Offset children to the right
216-
y: block.position.y + (childBlock.position?.y || 100), // Preserve vertical positioning
199+
x: block.position.x + 50,
200+
y: block.position.y + (childBlock.position?.y || 100),
217201
},
218202
data: {
219203
type: childBlock.type,
@@ -236,7 +220,6 @@ export function WorkflowPreview({
236220
return nodeArray
237221
}, [blocksStructure, loopsStructure, parallelsStructure, showSubBlocks, workflowState.blocks])
238222

239-
// Transform edges
240223
const edges: Edge[] = useMemo(() => {
241224
return workflowState.edges.map((edge) => ({
242225
id: edge.id,

apps/sim/app/w/marketplace/components/workflow-card.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ export function WorkflowCard({ workflow, onHover }: WorkflowCardProps) {
100100
workflowState={{
101101
...workflow.workflowState,
102102
parallels: workflow.workflowState.parallels || {},
103+
loops: workflow.workflowState.loops || {},
103104
}}
104105
/>
105106
</div>

0 commit comments

Comments
 (0)