Answer both requests the command sends - #5681
Conversation
It calls the service and then reads the state back to describe. Leaving the second unanswered meant the card was never built, so the lines that build it went unexercised while the test still passed.
There was a problem hiding this comment.
🟡 Changes recommended
The test helper currently swallows intent.perform() errors with try?, which can allow false-positive passes even if the intent failed and the intended coverage path still didn’t execute.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR updates the TurnOnOffEntityAppIntent unit tests to properly respond to both network requests triggered by perform() (the service call and the subsequent state readback), ensuring the snippet/card-building code path is exercised and patch coverage reflects the real execution flow.
Changes:
- Adds a decodable mock
HADataentity-state response to support the readback decode used for building the result card. - Updates the helper that drains
HAMockConnection.pendingRequeststo answer two requests in order and still capture the service name for assertions. - Passes the entity id into the helper so the mocked readback aligns with the intent’s target entity.
File summaries
| File | Description |
|---|---|
| Tests/App/Utilities/TurnOnOffEntityAppIntentTests.swift | Updates intent test plumbing to answer both the service request and the follow-up entity state readback so the snippet/card path executes. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| _ = try? await task.value | ||
| return request?.data["service"] as? String | ||
| return first?.data["service"] as? String |
|
Found 6 unused localization strings in the codebase. Click to see detailsTo remove them, run the |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5681 +/- ##
==========================================
- Coverage 38.86% 38.69% -0.18%
==========================================
Files 1069 1069
Lines 75564 75278 -286
==========================================
- Hits 29371 29130 -241
+ Misses 46193 46148 -45 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
AI Policy
Select exactly one option that describes AI usage in this contribution:
Summary
Follows #5677, which landed at 84.61% patch coverage. The two uncovered lines were the ones that build the result card.
The command sends two requests — the service, then the state it reads back to describe — and the test answered only the first. The state read never completed, so the card was never built and the lines that build it never ran, while the assertion on the service still passed. The test now answers both.
Screenshots
Tests only.
Link to pull request in Documentation repository
Documentation: home-assistant/companion.home-assistant#
Any other notes
No behaviour change.