#!/usr/bin/env node /** * Test script for the new proposal tools * This validates the GraphQL query structure and tool functionality */ import { UpworkClient } from "./src/services/upwork-client.js"; import { getProposalDetailsTool } from "./src/tools/proposal/get-proposal-details.js"; import { formatProposalNotificationTool } from "./src/tools/proposal/format-proposal-notification.js"; // Test proposal ID from the enhancement guide const TEST_PROPOSAL_ID = "1958709255028473857"; async function testProposalTools() { console.log("🧪 Testing Upwork Proposal Tools\n"); const upworkClient = new UpworkClient(); try { console.log("1️⃣ Testing upwork_get_proposal_details..."); const detailsResult = await getProposalDetailsTool.handler( { proposalId: TEST_PROPOSAL_ID }, upworkClient ); console.log("✅ Get Proposal Details Result:"); console.log(detailsResult.content[0].text); console.log("\n" + "=".repeat(80) + "\n"); console.log("2️⃣ Testing upwork_format_proposal_notification..."); const notificationResult = await formatProposalNotificationTool.handler( { proposalId: TEST_PROPOSAL_ID, eventType: "VendorCreate" }, upworkClient ); console.log("✅ Format Notification Result:"); console.log(notificationResult.content[0].text); console.log("\n" + "=".repeat(80) + "\n"); console.log("🎉 All tests completed successfully!"); } catch (error) { console.error("❌ Test failed:", error); // Test error handling with invalid proposal ID console.log("\n3️⃣ Testing error handling with invalid proposal ID..."); try { const errorResult = await getProposalDetailsTool.handler( { proposalId: "invalid-id-12345" }, upworkClient ); console.log("Error handling result:", errorResult.content[0].text); } catch (errorHandlingError) { console.log("Error handling works correctly:", errorHandlingError.message); } } } // Run the test if this file is executed directly if (import.meta.url === `file://${process.argv[1]}`) { testProposalTools().catch(console.error); } export { testProposalTools };