|
| 1 | +/** |
| 2 | + * @vitest-environment node |
| 3 | + */ |
| 4 | +import { describe, expect, it } from 'vitest' |
| 5 | +import { KittBlock } from '@/blocks/blocks/kitt' |
| 6 | + |
| 7 | +function mapParams(params: Record<string, unknown>): Record<string, unknown> { |
| 8 | + const mapper = KittBlock.tools.config.params |
| 9 | + if (!mapper) throw new Error('Kitt block is missing tools.config.params') |
| 10 | + return mapper(params) |
| 11 | +} |
| 12 | + |
| 13 | +describe('Kitt block tool wiring', () => { |
| 14 | + it('selects both registered operation IDs and rejects unknown operations', () => { |
| 15 | + expect(KittBlock.tools.config.tool({ operation: 'kitt_find_email' })).toBe('kitt_find_email') |
| 16 | + expect(KittBlock.tools.config.tool({ operation: 'kitt_verify_email' })).toBe( |
| 17 | + 'kitt_verify_email' |
| 18 | + ) |
| 19 | + expect(() => KittBlock.tools.config.tool({ operation: 'unsupported' })).toThrow( |
| 20 | + /Unsupported Kitt operation/ |
| 21 | + ) |
| 22 | + }) |
| 23 | + |
| 24 | + it('maps finder fields and coerces the strict-name dropdown during execution', () => { |
| 25 | + expect( |
| 26 | + mapParams({ |
| 27 | + operation: 'kitt_find_email', |
| 28 | + apiKey: 'test-key', |
| 29 | + fe_fullName: 'Erol Toker', |
| 30 | + fe_domain: 'trykitt.ai', |
| 31 | + fe_linkedinStandardProfileURL: 'https://linkedin.com/in/eroltoker', |
| 32 | + fe_strictNameMatches: 'false', |
| 33 | + fe_customData: 'crm-123', |
| 34 | + }) |
| 35 | + ).toEqual({ |
| 36 | + apiKey: 'test-key', |
| 37 | + fullName: 'Erol Toker', |
| 38 | + domain: 'trykitt.ai', |
| 39 | + linkedinStandardProfileURL: 'https://linkedin.com/in/eroltoker', |
| 40 | + strictNameMatches: false, |
| 41 | + customData: 'crm-123', |
| 42 | + }) |
| 43 | + }) |
| 44 | + |
| 45 | + it('maps verifier fields and coerces the alias dropdown during execution', () => { |
| 46 | + expect( |
| 47 | + mapParams({ |
| 48 | + operation: 'kitt_verify_email', |
| 49 | + apiKey: 'test-key', |
| 50 | + ve_email: 'erol@trykitt.ai', |
| 51 | + ve_treatAliasesAsValid: 'true', |
| 52 | + ve_customData: 'crm-456', |
| 53 | + }) |
| 54 | + ).toEqual({ |
| 55 | + apiKey: 'test-key', |
| 56 | + email: 'erol@trykitt.ai', |
| 57 | + treatAliasesAsValid: true, |
| 58 | + customData: 'crm-456', |
| 59 | + }) |
| 60 | + }) |
| 61 | + |
| 62 | + it('hides the required API key field on hosted Sim', () => { |
| 63 | + const apiKey = KittBlock.subBlocks.find((subBlock) => subBlock.id === 'apiKey') |
| 64 | + expect(apiKey).toMatchObject({ required: true, password: true, hideWhenHosted: true }) |
| 65 | + }) |
| 66 | +}) |
0 commit comments