Add MSW coverage for Duo chat agent and model selection
What
Leaf MR in the Duo Agentic Chat MSW migration. Covers agent and model selection in jsdom, ahead of removing the Capybara examples it replaces.
Independent of the other MRs in this series; see the table at the end.
Replaces
The last MR in the series
!244590 (merged) will remove these Capybara specs once we can ensure equivalent coverage using MSW integration specs
| Capybara example | Replaced by |
|---|---|
allows user to select a custom agent |
agent_selection_spec.js |
allows user to select a model |
model_selection_spec.js |
Grouped because they are structurally identical: mount the full panel, open a dropdown, pick an item, assert the choice reached the websocket URL. Same mountAgenticChatPanel + buildChatConfiguration shape, same lastWebsocketParams() assertion.
Both are stronger than the originals
Agent selection. The Capybara version asserted Ai::DuoWorkflows::Workflow.last.workflow_definition through the browser. The server side of that contract is already covered by ee/spec/requests/api/graphql/mutations/ai/duo_workflows/create_spec.rb, so nothing is lost by asserting the client side instead: that the agent's referenceWithVersion lands on both the createAiDuoWorkflow variables and the workflow_definition websocket param. Also adds two things the original didn't check — the dropdown closing after selection (a past regression), and the agent surviving a history round trip.
Model selection. The Capybara version only asserted that a reply came back after switching models, which does not prove the selection reached the wire. This asserts user_selected_model_identifier on the connect URL. It also covers the administrator-pinned case (dropdown disabled), which the original never touched.
Notes
model_selection_spec.js consumes get_ai_chat_available_models_unpinned, generated in the harness MR — the pre-existing models fixture pins a model, which makes isModelSelectionDisabled return true and renders the dropdown disabled.
Test-only, so no changelog entry.
Verification
yarn jest:msw-integration ee/spec/frontend/msw_integration/duo_agentic_chat/ — green.
Part of #603605 (closed)
The MR series
| # | MR | What it does | Status |
|---|---|---|---|
| 1 | !248777 (merged) | Sets up MSW test foundations | Merged |
| 2 | !248782 (merged) | Covers the AI panel shell | Merged |
| 3 | !248783 (merged) | Covers the chat conversation lifecycle | Merged |
| 4 | !248785 (merged) | Covers chat tool calls | Merged |
| 5 | !248787 | Covers agent and model selection | this MR |
| 6 | !248791 (merged) | Covers additional context | Merged |
| 7 | !244590 (merged) | Removes the replaced Capybara specs | Open |
Related issue: #603605 (closed)
The four spec MRs (3-6) are independent and can be reviewed and merged in parallel, in any order. Several add helpers to the same two shared test files, so whichever merges first leaves the others a trivial rebase: inserts in the same place, never disagreements. !244590 (merged) merges last, since it deletes the Capybara coverage the others replace.