Skip to main content
Glama
shared-setup.ts4.21 kB
/** * Shared setup and imports for Notes Management E2E Tests */ import { vi } from 'vitest'; import { E2ETestBase } from '../../setup.js'; import { E2EAssertions } from '../../utils/assertions.js'; import { CompanyFactory, PersonFactory, noteFixtures, noteScenarios, edgeCaseNotes, performanceNotes, } from '../../fixtures/index.js'; import type { TestDataObject, McpToolResponse, RecordData, } from '../../types/index.js'; // Type interfaces for proper type safety export interface AttioRecord { id: { record_id: string; object_id?: string; }; values: Record<string, unknown>; created_at?: string; updated_at?: string; } export interface NoteRecord { id: string; title: string; content: string; format?: string; created_at?: string; updated_at?: string; } // Import enhanced tool caller with logging and migration import { callNotesTool, callUniversalTool, validateTestEnvironment, getToolMigrationStats, } from '../../utils/enhanced-tool-caller.js'; import { startTestSuite, endTestSuite } from '../../utils/logger.js'; // Shared test data storage export const testCompanies: TestDataObject[] = []; export const testPeople: TestDataObject[] = []; export const createdNotes: TestDataObject[] = []; // Shared setup utilities export function createSharedSetup() { return { beforeAll: async () => { // Start comprehensive logging for this test suite startTestSuite('notes-management'); // Validate test environment and tool migration setup const envValidation = await validateTestEnvironment(); if (!envValidation.valid) { console.warn('⚠️ Test environment warnings:', envValidation.warnings); } console.error('📊 Tool migration stats:', getToolMigrationStats()); await E2ETestBase.setup({ requiresRealApi: false, // Use mock data instead of real API for reliable testing cleanupAfterTests: true, timeout: 120000, }); console.error( '🚀 Starting Notes Management E2E Tests with Universal Tools' ); }, afterAll: async () => { // Cleanup is handled automatically by E2ETestBase.setup() // End comprehensive logging for this test suite endTestSuite(); console.error( '✅ Notes Management E2E Tests completed with enhanced logging' ); }, beforeEach: () => { vi.clearAllMocks(); }, }; } // Shared test data creation utilities export async function createTestCompany(): Promise<void> { try { const companyData = CompanyFactory.create(); const response = (await callUniversalTool('create-record', { resource_type: 'companies', record_data: companyData as unknown as RecordData, })) as McpToolResponse; if (response.isError) { console.error( '[Setup] createTestCompany failed with real API:', response.error ); return; } const company = E2EAssertions.expectMcpData( response ) as unknown as AttioRecord; E2EAssertions.expectCompanyRecord(company); testCompanies.push(company); console.error('🏢 Created test company:', company.id.record_id); } catch (e) { console.error('[Setup] createTestCompany threw:', e); } } export async function createTestPerson(): Promise<void> { try { const personData = PersonFactory.create(); const response = (await callUniversalTool('create-record', { resource_type: 'people', record_data: personData as unknown as RecordData, })) as McpToolResponse; if (response.isError) { console.error( '[Setup] createTestPerson failed with real API:', response.error ); return; } const person = E2EAssertions.expectMcpData( response ) as unknown as AttioRecord; E2EAssertions.expectPersonRecord(person); testPeople.push(person); console.error('👤 Created test person:', person.id.record_id); } catch (e) { console.error('[Setup] createTestPerson threw:', e); } } // Export shared utilities export { callNotesTool, callUniversalTool, E2EAssertions, noteFixtures, noteScenarios, edgeCaseNotes, performanceNotes, };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kesslerio/attio-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server