Fix targeted activity integration tests - #660
Merged
Merged
Conversation
The same .runsettings ignore fix is being made in another branch. Dropping it here keeps this PR limited to the targeted activity test changes. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: be5db5b3-3376-4b00-8f4d-51d1bf51d101
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes failing targeted-activity integration tests by ensuring the test helper correctly sets a recipient on targeted message activities, and adds a unit test to prevent targeted update requests from inadvertently including a recipient field in the JSON payload.
Changes:
- Fix
CreateMessageActivity(text, recipient)in integration tests to apply the provided recipient as a targeted recipient. - Add a unit test asserting
ConversationClient.UpdateActivityAsync(..., isTargeted: true)does not send a top-levelrecipientproperty in the request body. - Add
System.Text.Jsonusage in unit tests to validate request payload structure.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| test/Microsoft.Teams.Core.UnitTests/ConversationClientTests.cs | Adds a targeted-update regression test by parsing captured request JSON and asserting recipient is omitted. |
| test/IntegrationTests/ApiClientTests.cs | Fixes targeted message test helper to include a targeted recipient so targeted activity integration tests don’t send null recipients. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Mehak Bindra (MehakBindra)
approved these changes
Aug 26, 2026
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.
What changed
Fix
CreateMessageActivity(text, recipient)silently dropping its recipient. The helper inApiClientTests.csaccepted aChannelAccountand then returned the activity without ever applying it, so targeted activities went out with no recipient. The service rejects those with400 BadArgument: Recipient of Targeted Message cannot be null, which failedActivities_CreateTargetedAsync,Activities_UpdateTargetedAsync, andActivities_DeleteTargetedAsync. The helper now callsWithRecipient(..., isTargeted: true).Add a regression test for targeted update payloads.
UpdateActivityAsync_WithIsTargeted_DoesNotSendRecipientasserts that the serialized body omitsrecipient. C# already behaves correctly here, but only by caller convention:ConversationClientserializes the activity verbatim and does no stripping, so nothing was guarding the behavior. This closes a parity gap with the equivalent TypeScript coverage.Testing
Integration suite run against a live canary tenant: the three targeted activity tests now pass, with no change to any other test outcome. The new unit test passes and was mutation-checked by injecting a recipient, which fails it as expected.
No product code changed.