chore: import upstream snapshot with attribution
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,151 @@
|
||||
import { createElement, type SVGProps } from 'react'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import type { BlockConfig } from '@/blocks/types'
|
||||
|
||||
const { mockGetAllBlocks, mockGetToolOperationsIndex, mockGetTriggersForSidebar } = vi.hoisted(
|
||||
() => ({
|
||||
mockGetAllBlocks: vi.fn(),
|
||||
mockGetToolOperationsIndex: vi.fn(() => []),
|
||||
mockGetTriggersForSidebar: vi.fn(() => []),
|
||||
})
|
||||
)
|
||||
|
||||
vi.mock('@/blocks', () => ({
|
||||
getAllBlocks: mockGetAllBlocks,
|
||||
}))
|
||||
|
||||
vi.mock('@/lib/search/tool-operations', () => ({
|
||||
getToolOperationsIndex: mockGetToolOperationsIndex,
|
||||
}))
|
||||
|
||||
vi.mock('@/lib/workflows/triggers/trigger-utils', () => ({
|
||||
getTriggersForSidebar: mockGetTriggersForSidebar,
|
||||
}))
|
||||
|
||||
import {
|
||||
buildCommandSearchableOptionSearchValue,
|
||||
useSearchModalStore,
|
||||
} from '@/stores/modals/search/store'
|
||||
|
||||
function TestIcon(props: SVGProps<SVGSVGElement>) {
|
||||
return createElement('svg', props)
|
||||
}
|
||||
|
||||
function createBlock(overrides: Partial<BlockConfig> = {}): BlockConfig {
|
||||
return {
|
||||
type: 'image_generator_v2',
|
||||
name: 'Image Generator',
|
||||
description: 'Generate images',
|
||||
category: 'tools',
|
||||
bgColor: '#4D5FFF',
|
||||
icon: TestIcon,
|
||||
subBlocks: [
|
||||
{
|
||||
id: 'provider',
|
||||
title: 'Provider',
|
||||
type: 'dropdown',
|
||||
commandSearchable: true,
|
||||
options: [
|
||||
{ label: 'OpenAI', id: 'openai' },
|
||||
{ label: 'Fal.ai (Multi-Model)', id: 'falai' },
|
||||
{ label: 'Hidden Provider', id: 'hidden', hidden: true },
|
||||
],
|
||||
},
|
||||
],
|
||||
tools: { access: ['image_generate'] },
|
||||
inputs: {},
|
||||
outputs: {},
|
||||
...overrides,
|
||||
}
|
||||
}
|
||||
|
||||
describe('search modal store', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
useSearchModalStore.setState({
|
||||
isOpen: false,
|
||||
data: {
|
||||
blocks: [],
|
||||
tools: [],
|
||||
triggers: [],
|
||||
toolOperations: [],
|
||||
docs: [],
|
||||
isInitialized: false,
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
describe('buildCommandSearchableOptionSearchValue', () => {
|
||||
it('builds search terms for marked static dropdown options', () => {
|
||||
const block = createBlock()
|
||||
const searchValue = buildCommandSearchableOptionSearchValue(block)
|
||||
|
||||
expect(searchValue).toContain('Provider')
|
||||
expect(searchValue).toContain('Fal.ai (Multi-Model)')
|
||||
expect(searchValue).toContain('falai')
|
||||
expect(searchValue).not.toContain('Hidden Provider')
|
||||
expect(searchValue).not.toContain('hidden')
|
||||
})
|
||||
|
||||
it('does not index dropdowns that only use in-dropdown search', () => {
|
||||
const block = createBlock({
|
||||
subBlocks: [
|
||||
{
|
||||
id: 'timezone',
|
||||
title: 'Timezone',
|
||||
type: 'dropdown',
|
||||
searchable: true,
|
||||
options: [{ label: 'UTC', id: 'utc' }],
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
expect(buildCommandSearchableOptionSearchValue(block)).toBe('')
|
||||
})
|
||||
|
||||
it('builds search terms for marked combobox option functions', () => {
|
||||
const block = createBlock({
|
||||
subBlocks: [
|
||||
{
|
||||
id: 'model',
|
||||
title: 'Model',
|
||||
type: 'combobox',
|
||||
commandSearchable: true,
|
||||
options: () => [
|
||||
{ label: 'claude-sonnet-4-6', id: 'claude-sonnet-4-6' },
|
||||
{ label: 'Hidden Model', id: 'hidden-model', hidden: true },
|
||||
],
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
const searchValue = buildCommandSearchableOptionSearchValue(block)
|
||||
|
||||
expect(searchValue).toContain('Model')
|
||||
expect(searchValue).toContain('claude-sonnet-4-6')
|
||||
expect(searchValue).not.toContain('Hidden Model')
|
||||
expect(searchValue).not.toContain('hidden-model')
|
||||
})
|
||||
})
|
||||
|
||||
it('adds command-searchable options to visible block search values without extra rows', () => {
|
||||
const visibleBlock = createBlock()
|
||||
const hiddenBlock = createBlock({
|
||||
type: 'hidden_generator',
|
||||
hideFromToolbar: true,
|
||||
})
|
||||
|
||||
mockGetAllBlocks.mockReturnValue([visibleBlock, hiddenBlock])
|
||||
|
||||
useSearchModalStore.getState().initializeData((blocks) => blocks)
|
||||
|
||||
const { tools } = useSearchModalStore.getState().data
|
||||
expect(tools).toHaveLength(1)
|
||||
expect(tools[0]).toEqual(
|
||||
expect.objectContaining({
|
||||
id: 'image_generator_v2',
|
||||
searchValue: expect.stringContaining('Fal.ai (Multi-Model)'),
|
||||
})
|
||||
)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user