#!/usr/bin/env node
// Test script to verify the original issue is fixed
// This recreates the exact scenario: searching for ranibizumab by activeIngredient
import { FDAClient } from './dist/apis/fda.js';
async function testOriginalIssue() {
console.log('π¬ Testing Original FDA Issue: ranibizumab search\n');
const fdaClient = new FDAClient();
console.log('π Original request that was failing:');
console.log(' Tool: fda_search_drugs');
console.log(' Request: { "activeIngredient": "ranibizumab" }');
console.log(' Expected: Drug information, not 404 error\n');
try {
const startTime = Date.now();
// This is the exact call that was failing before
const result = await fdaClient.searchDrugs({
activeIngredient: 'ranibizumab'
});
const endTime = Date.now();
console.log('β
SUCCESS! FDA search completed successfully');
console.log(`β±οΈ Response time: ${endTime - startTime}ms`);
console.log(`π Results found: ${result.totalCount} total, ${result.drugs.length} returned`);
if (result.drugs.length > 0) {
console.log('\nπ Drug Details:');
result.drugs.forEach((drug, index) => {
console.log(`\n ${index + 1}. ${drug.brandName || drug.genericName || 'Unknown Name'}`);
console.log(` Application: ${drug.applicationNumber}`);
console.log(` Sponsor: ${drug.sponsorName}`);
console.log(` Active Ingredients: ${drug.activeIngredients.map(ai => `${ai.name} (${ai.strength})`).join(', ')}`);
console.log(` Approval Date: ${drug.approvalDate}`);
console.log(` Dosage Form: ${drug.dosageForm}`);
});
}
console.log('\nπ Issue Resolution Summary:');
console.log(' β
No more 404 errors');
console.log(' β
Proper field names for FDA API');
console.log(' β
Fallback search strategies working');
console.log(' β
Comprehensive error handling');
console.log(' β
Size monitoring integrated');
} catch (error) {
console.log('β FAILURE! The issue still exists:');
console.log(` Error: ${error.message}`);
process.exit(1);
}
}
// Run the test
testOriginalIssue().catch(error => {
console.error('β Test failed:', error);
process.exit(1);
});