diff --git a/sim/blocks/blocks/airtable.test.ts b/sim/blocks/blocks/airtable.test.ts deleted file mode 100644 index 41869aad43..0000000000 --- a/sim/blocks/blocks/airtable.test.ts +++ /dev/null @@ -1,89 +0,0 @@ -/** - * @vitest-environment jsdom - * - * Airtable Block Integration Tests - */ -import { describe, expect, test } from 'vitest' -import { AirtableBlock } from './airtable' - -describe('Airtable Block', () => { - test('should have correct configuration', () => { - expect(AirtableBlock.type).toBe('airtable') - expect(AirtableBlock.category).toBe('tools') - expect(AirtableBlock.tools.access).toContain('airtable_read') - expect(AirtableBlock.tools.access).toContain('airtable_write') - expect(AirtableBlock.tools.access).toContain('airtable_update') - }) - - test('should select correct tool based on operation', () => { - const config = AirtableBlock.tools.config - - if (!config) { - throw new Error('Tool config is missing') - } - - expect(config.tool({ operation: 'read' })).toBe('airtable_read') - expect(config.tool({ operation: 'write' })).toBe('airtable_write') - expect(config.tool({ operation: 'update' })).toBe('airtable_update') - expect(() => config.tool({ operation: 'invalid' })).toThrow('Invalid Airtable operation') - }) - - test('should transform parameters correctly', () => { - const config = AirtableBlock.tools.config - - if (!config || !config.params) { - throw new Error('Tool config or params is missing') - } - - // Test read operation - const readParams = config.params({ - operation: 'read', - credential: 'oauth_token', - baseId: 'base123', - tableId: 'table456', - maxRecords: '100', - filterFormula: "Status='Active'" - }) - - expect(readParams.accessToken).toBe('oauth_token') - expect(readParams.baseId).toBe('base123') - expect(readParams.tableId).toBe('table456') - - // Test write operation - const writeParams = config.params({ - operation: 'write', - credential: 'oauth_token', - baseId: 'base123', - tableId: 'table456', - records: JSON.stringify([{ fields: { Name: 'Test' } }]) - }) - - expect(writeParams.accessToken).toBe('oauth_token') - expect(writeParams.records).toEqual([{ fields: { Name: 'Test' } }]) - - // Test update operation - const updateParams = config.params({ - operation: 'update', - credential: 'oauth_token', - baseId: 'base123', - tableId: 'table456', - recordId: 'rec789', - records: JSON.stringify({ fields: { Name: 'Updated' } }) - }) - - expect(updateParams.accessToken).toBe('oauth_token') - expect(updateParams.recordId).toBe('rec789') - expect(updateParams.fields).toEqual({ fields: { Name: 'Updated' } }) - }) - - test('should have required OAuth configuration', () => { - const subBlocks = AirtableBlock.subBlocks - const credentialBlock = subBlocks.find(block => block.id === 'credential') - - expect(credentialBlock).toBeDefined() - expect(credentialBlock?.type).toBe('oauth-input') - expect(credentialBlock?.provider).toBe('airtable') - expect(credentialBlock?.requiredScopes).toContain('data.records:read') - expect(credentialBlock?.requiredScopes).toContain('data.records:write') - }) -}) \ No newline at end of file diff --git a/sim/blocks/blocks/airtable.ts b/sim/blocks/blocks/airtable.ts index 17da52321a..a251fc9997 100644 --- a/sim/blocks/blocks/airtable.ts +++ b/sim/blocks/blocks/airtable.ts @@ -1,8 +1,8 @@ import { AirtableIcon } from '@/components/icons' import { AirtableReadResponse, - AirtableWriteResponse, AirtableUpdateResponse, + AirtableWriteResponse, } from '@/tools/airtable/types' import { BlockConfig } from '../types' @@ -12,12 +12,12 @@ export const AirtableBlock: BlockConfig = { type: 'airtable', name: 'Airtable', description: 'Read, write, and update Airtable records', - longDescription: + longDescription: 'Integrate Airtable functionality to manage table records. Read data from existing tables, ' + 'write new records, and update existing ones using OAuth authentication. Supports table ' + 'selection and record operations with custom field mapping.', category: 'tools', - bgColor: '#FCB400', + bgColor: '#E0E0E0', icon: AirtableIcon, subBlocks: [ // Operation selector @@ -120,7 +120,7 @@ export const AirtableBlock: BlockConfig = { }, params: (params) => { const { credential, records, ...rest } = params - + if (params.operation === 'update' && records) { const parsedRecords = JSON.parse(records) return { @@ -129,7 +129,7 @@ export const AirtableBlock: BlockConfig = { ...rest, } } - + return { accessToken: credential, records: records ? JSON.parse(records) : undefined, @@ -147,8 +147,8 @@ export const AirtableBlock: BlockConfig = { maxRecords: { type: 'number', required: false }, filterFormula: { type: 'string', required: false }, // Write/Update operation inputs - records: { - type: 'json', + records: { + type: 'json', required: false, schema: { type: 'object', diff --git a/sim/components/icons.tsx b/sim/components/icons.tsx index 51a3fb145b..94fb15e2e4 100644 --- a/sim/components/icons.tsx +++ b/sim/components/icons.tsx @@ -1516,19 +1516,34 @@ export function RedditIcon(props: SVGProps) { export function AirtableIcon(props: SVGProps) { return ( - - - - - + + + + + + ) }