Canvas AI: Create tests for Canvas AI Page builder Agent and Canvas AI Template Builder Agent
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3591457. -->
Reported by: [akhil babu](https://www.drupal.org/user/3632866)
>>>
<h3 id="overview">Overview</h3>
<p>This issue will get broken down in to several sub issues in future.</p>
<p><span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/canvas/-/work_items/3582390" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/canvas/-/work_items/3582390</a></span> would add automated tests for the Canvas AI Orchestrtator agent. In the same way create tests for the Page builder agent and template builder agent so that we could save a lot of time in manual testing whenevr their system prompts changes. On a high level, to achieve this.</p>
<ul>
<li>For the tests, the agent should only see the components available in the canvas_test_sdc module to ensure that anyone can run the tests consistently. For that, Implement a hook in the canvas_ai_agents_test module that restricts the component list to only the components defined in the canvas_test_sdc module. <span class="drupalorg-gitlab-issue-link project-issue-status-info project-issue-status-1"><a href="https://www.drupal.org/project/canvas/issues/3591516" title="Status: Active">#3591516: Canvas AI: Restrict component catalog to canvas_test_sdc components when canvas_ai_agents_test is installed</a></span></li>
<li>Both agents depend on the current layout stored in tempstore via CanvasAiTempStore::CURRENT_LAYOUT_KEY. This data is sent by the Canvas UI. We should provide fixtures for different layouts in the canvas_ai_agents_tests module to use in the tests. Created #3591591 </li>
<li>Create an agentic skill to generate these tests with the help of AI</li>
<li>Create the tests</li>
</ul>
<p>These could be broken down to sub issues. Ideally this should be completed by the time <span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/canvas/-/work_items/3545816" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/canvas/-/work_items/3545816</a></span> lands</p>
<h3 id="proposed-resolution">Proposed resolution</h3>
<h3 id="ui-changes">User interface changes</h3>
> Related issue: [Issue #3579471](https://www.drupal.org/node/3579471)
issue