Repository navigation
test(ai-adapter): add comprehensive unit test suite covering all adapters and validation - #1457
kafeelraza wants to merge 2 commits into
Conversation
…ters and validation
|
Hi @Aryan-Verma-999 👋 It covers all adapters (Base, Mock, Gemini, OpenAI, Ollama) and UI-Kit block extraction with 39 tests (100% pass, ~312ms offline). Would love your feedback and review when you have some time! Thank you! 🚀 |
|
Hi @kafeelraza! Great job putting together a comprehensive unit test suite for the AI adapters — having test coverage here is a huge plus! A few technical observations while testing the suite locally:
|
|
Hi @swarnendusahu10-dotcom, thank you so much for testing the suite locally and for the insightful feedback! 🙌 I've addressed all three observations in the latest commit:
All tests are passing cleanly. Would love to know if there's anything else to polish! |
Description
Prior to this PR,
@embeddedchat/ai-adapterhad no test suite configured ("test": "echo \"Error: no test specified\" && exit 1").This PR establishes a zero-dependency, lightning-fast unit testing suite using Node.js's native test runner (
node:testandnode:assert/strict), matching the testing pattern used inpackages/layout_editor.Test Coverage (39 tests, 100% pass)
BaseAIAdapter:buildChatMessagessystem prompt prepending and assistant role mappinggetSuggestionscleaning (stripping bullets, numbers, quotes, and participant labels)summarizetranscript formattingMockAdapter:sendPromptmock response and suggestionsgenerateUIBlocksfor forms, profiles, galleries, CTAs, and info fallbacksGeminiAdapter:contentsarray with roles and parts)systemInstruction,generationConfig)isAvailablemodels ping check and network failure resilienceOpenAIAdapter:buildResponseFormat(json_schemastrict mode for GPT-4/GPT-4o vsjson_objectfallback)generateUIBlocksschema validationisAvailablemodels endpoint pingOllamaAdapter:/api/chatrequest body format (stream: false,num_predict,temperature)generateUIBlockswithformat: UI_KIT_JSON_SCHEMAisAvailabletags endpoint pingvalidation:validateAndExtractBlocksJSON parsing and schema validationVerification
yarn testinpackages/ai-adapter: all 39 tests passed in ~312ms.yarn format:check: all files formatted according to Prettier.@embeddedchat/ai-adapter.