Add MSW coverage for Duo chat additional context

What

Final leaf MR in the Duo Agentic Chat MSW migration. Covers repository-rule and page-context injection in jsdom, ahead of removing the Capybara example 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

The injects additional context example of 'user can use agentic chat', which was the longest of the nine and did three chats' worth of work in one example.

Kept as its own MR because it is the only consumer of the get_rule_content fixture, and its four tests trace a stateful lifecycle that is its own review context:

  1. page context + AGENTS.md + chat-rules.md injected with the first message
  2. those items render as expandable tokens on the user message
  3. not re-injected on the second message, because the page and project haven't changed
  4. injected again after starting a new chat

Why the fixture is generated rather than hand-written

PageContextProvider and RuleContextProvider are pure client code, so the only server dependency is the getRuleContent query. It is served from a fixture generated against a real project with AGENTS.md and .gitlab/duo/chat-rules.md committed, because RuleContextProvider.fetchProjectRules switches on blob.name — the resolver returning the basename rather than the full nested path is load-bearing, and a hand-written mock would fake exactly that away. The generator asserts it explicitly.

Verification

yarn jest:msw-integration ee/spec/frontend/msw_integration/duo_agentic_chat/ — green.

Notes

Test-only, so no changelog entry.

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 (merged) Covers agent and model selection Open
6 !248791 Covers additional context Open — this MR
7 !244590 (merged) Removes the replaced Capybara specs Draft

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.

Edited by Enrique Alcántara

Merge request reports

Loading
Loading