Skip to content

Add comprehensive tests and CI for A2UI Composer#754

Merged
jacobsimionato merged 9 commits intogoogle:mainfrom
jacobsimionato:composer-readmes
Mar 3, 2026
Merged

Add comprehensive tests and CI for A2UI Composer#754
jacobsimionato merged 9 commits intogoogle:mainfrom
jacobsimionato:composer-readmes

Conversation

@jacobsimionato
Copy link
Collaborator

@jacobsimionato jacobsimionato commented Mar 3, 2026

Summary

This PR introduces a robust testing infrastructure and a dedicated CI workflow for the A2UI Composer tool. It also includes critical bug fixes for JSON parsing of AI-generated content.

Key Changes

  • Testing Suite: Implemented unit and integration tests using Vitest and React Testing Library.
    • : Validates robust parsing of malformed or double-stringified JSON.
    • : Verifies interactions for persistent widget storage.
    • : Tests state management and widget lifecycle.
    • Component Tests: Coverage for , , and , including mocks for complex third-party libraries like Monaco Editor and CopilotKit.
  • Bug Fixes: Enhanced to handle recursive parsing of JSON strings, ensuring reliability when receiving double-stringified data from LLMs.
  • CI/CD Integration: Added to automate linting, building, and testing on every PR/push affecting .
  • Documentation: Updated with instructions for running tests and configuring necessary environment variables.
  • Maintenance: Updated with testing dependencies and scripts.

How to Test Locally

  1. Navigate to the composer directory:
    cd tools/composer
  2. Install dependencies:
    pnpm install
  3. Run the test suite:
    pnpm test

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request is a significant improvement, introducing a comprehensive testing suite with Vitest and React Testing Library, which was much needed. The bug fix for robust JSON parsing is also a critical enhancement, especially for handling varied LLM outputs. The overall restructuring of the project by moving the composer into its own tools directory is a good organizational change. I have one minor suggestion to improve the maintainability of the JSON parsing logic.

Comment on lines +47 to +52
try {
return parseRobustJSON(result);
} catch {
// If recursive call fails, return the first result
return result;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This logic for handling nested JSON is great. For better readability and to reuse the safe parsing utility you've already defined, you could simplify this try-catch block by using parseRobustJSONSafe. It achieves the same result (returning the string if the inner parse fails) but makes the intent more explicit.

        // Attempt to parse the nested JSON string. If it fails, return the string itself.
        return parseRobustJSONSafe(result, result);

@jacobsimionato jacobsimionato merged commit caf0e28 into google:main Mar 3, 2026
6 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in A2UI Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants