mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-24 15:45:35 +08:00
resolved comments
This commit is contained in:
-1
@@ -27,7 +27,6 @@ export function DeployedWorkflowCard({
|
||||
const workflowToShow = showingDeployed ? deployedWorkflowState : currentWorkflowState
|
||||
const activeWorkflowId = useWorkflowRegistry((state) => state.activeWorkflowId)
|
||||
|
||||
// // Generate a unique key for the workflow preview
|
||||
const previewKey = useMemo(() => {
|
||||
return `${showingDeployed ? 'deployed' : 'current'}-preview-${activeWorkflowId}}`
|
||||
}, [showingDeployed, activeWorkflowId])
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
// Mock the stores
|
||||
const mockWorkflowStore = {
|
||||
getState: vi.fn(),
|
||||
subscribe: vi.fn(),
|
||||
@@ -52,7 +51,6 @@ vi.mock('@/stores/workflows/utils', () => ({
|
||||
mergeSubblockState: vi.fn((blocks) => blocks),
|
||||
}))
|
||||
|
||||
// Mock other dependencies
|
||||
vi.mock('@/lib/logs/console-logger', () => ({
|
||||
createLogger: () => ({
|
||||
error: vi.fn(),
|
||||
@@ -62,8 +60,6 @@ vi.mock('@/lib/logs/console-logger', () => ({
|
||||
}),
|
||||
}))
|
||||
|
||||
// Import the function we want to test
|
||||
// Since it's inside a component, we'll extract it for testing
|
||||
const normalizeBlocksForComparison = (blocks: Record<string, any>) => {
|
||||
if (!blocks) return []
|
||||
|
||||
@@ -121,13 +117,11 @@ describe('normalizeBlocksForComparison', () => {
|
||||
|
||||
expect(result).toHaveLength(2)
|
||||
|
||||
// Should only contain type, name, and subBlocks
|
||||
result.forEach((block) => {
|
||||
expect(block).toHaveProperty('type')
|
||||
expect(block).toHaveProperty('name')
|
||||
expect(block).toHaveProperty('subBlocks')
|
||||
|
||||
// Should NOT contain metadata properties
|
||||
expect(block).not.toHaveProperty('id')
|
||||
expect(block).not.toHaveProperty('position')
|
||||
expect(block).not.toHaveProperty('height')
|
||||
@@ -145,7 +139,6 @@ describe('normalizeBlocksForComparison', () => {
|
||||
|
||||
const result = normalizeBlocksForComparison(blocks)
|
||||
|
||||
// Should be sorted: agent blocks first (by name), then api blocks (by name)
|
||||
expect(result[0]).toEqual({ type: 'agent', name: 'Agent 1', subBlocks: {} })
|
||||
expect(result[1]).toEqual({ type: 'agent', name: 'Agent 2', subBlocks: {} })
|
||||
expect(result[2]).toEqual({ type: 'api', name: 'API 1', subBlocks: {} })
|
||||
@@ -164,7 +157,6 @@ describe('normalizeBlocksForComparison', () => {
|
||||
'block-2': {
|
||||
type: 'agent',
|
||||
name: 'Agent 1',
|
||||
// subBlocks missing
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
+5
-6
@@ -1,5 +1,5 @@
|
||||
import type { ReactElement } from 'react'
|
||||
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { Wand2 } from 'lucide-react'
|
||||
import { highlight, languages } from 'prismjs'
|
||||
import 'prismjs/components/prism-javascript'
|
||||
@@ -60,11 +60,10 @@ export function Code({
|
||||
previewValue,
|
||||
}: CodeProps) {
|
||||
// Determine the AI prompt placeholder based on language
|
||||
const aiPromptPlaceholder = useMemo(() => {
|
||||
return language === 'json'
|
||||
? 'Describe the JSON schema you need...'
|
||||
: 'Describe the function you need...'
|
||||
}, [language])
|
||||
const aiPromptPlaceholder =
|
||||
language === 'json'
|
||||
? 'Describe the JSON schema to generate...'
|
||||
: 'Describe the JavaScript code to generate...'
|
||||
|
||||
// State management
|
||||
const [storeValue, setStoreValue] = useSubBlockValue(blockId, subBlockId)
|
||||
|
||||
+12
-15
@@ -85,24 +85,21 @@ export function EvalInput({
|
||||
)
|
||||
}
|
||||
|
||||
const updateThreshold = (id: string, value: string) => {
|
||||
if (isPreview) return
|
||||
|
||||
// Allow empty values for clearing
|
||||
const sanitizedValue = value.replace(/[^0-9.-]/g, '')
|
||||
if (sanitizedValue === '') {
|
||||
setStoreValue(
|
||||
metrics.map((metric) => (metric.id === id ? { ...metric, threshold: undefined } : metric))
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
// Validation handlers
|
||||
const handleRangeBlur = (id: string, field: 'min' | 'max', value: string) => {
|
||||
const sanitizedValue = value.replace(/[^\d.-]/g, '')
|
||||
const numValue = Number.parseFloat(sanitizedValue)
|
||||
|
||||
setStoreValue(
|
||||
metrics.map((metric) =>
|
||||
metric.id === id
|
||||
? { ...metric, threshold: Number.isNaN(numValue) ? undefined : numValue }
|
||||
? {
|
||||
...metric,
|
||||
range: {
|
||||
...metric.range,
|
||||
[field]: !Number.isNaN(numValue) ? numValue : 0,
|
||||
},
|
||||
}
|
||||
: metric
|
||||
)
|
||||
)
|
||||
@@ -190,7 +187,7 @@ export function EvalInput({
|
||||
type='text'
|
||||
value={metric.range.min}
|
||||
onChange={(e) => updateRange(metric.id, 'min', e.target.value)}
|
||||
onBlur={(e) => updateThreshold(metric.id, e.target.value)}
|
||||
onBlur={(e) => handleRangeBlur(metric.id, 'min', e.target.value)}
|
||||
disabled={isPreview}
|
||||
className='placeholder:text-muted-foreground/50'
|
||||
/>
|
||||
@@ -201,7 +198,7 @@ export function EvalInput({
|
||||
type='text'
|
||||
value={metric.range.max}
|
||||
onChange={(e) => updateRange(metric.id, 'max', e.target.value)}
|
||||
onBlur={(e) => updateThreshold(metric.id, e.target.value)}
|
||||
onBlur={(e) => handleRangeBlur(metric.id, 'max', e.target.value)}
|
||||
disabled={isPreview}
|
||||
className='placeholder:text-muted-foreground/50'
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user