Repository navigation
test(ai-adapter): add comprehensive unit test suite covering all adapters and validation - #1457
Open
kafeelraza wants to merge 1 commit into
Open
kafeelraza wants to merge 1 commit into
kafeelraza wants to merge 1 commit into
Conversation
…ters and validation
Author
|
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! 🚀 |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.