Skip to content

Cover the Siri exposure settings edge cases - #5821

Merged
bgoncal merged 2 commits into
mainfrom
bgoncal/siri-exposure-coverage
Sep 16, 2026
Merged

bgoncal merged 2 commits into
mainfrom
bgoncal/siri-exposure-coverage

Conversation

@bgoncal

@bgoncal bgoncal commented Sep 16, 2026

Copy link
Copy Markdown
Member

AI Policy

Select exactly one option that describes AI usage in this contribution:

  • I have not used AI for this contribution.
  • AI assistance was used for this contribution.
  • AI fully generated the code for this contribution, but I've reviewed and understood it before submitting and will respond without AI during review.

Summary

Follow-up to #5819. Adds tests for the lines Codecov reported as uncovered there: the default refresh path through the app database updater, the error branches of the Siri exposure queries, the table's in-place migration, the toolbar's progress state while reloading, and the Siri exposure cleanup on server deletion. The reload button now takes the view model method directly instead of wrapping it in a closure.

Screenshots

Link to pull request in Documentation repository

Documentation: home-assistant/companion.home-assistant#

Any other notes

Copilot AI lite review requested due to automatic review settings September 16, 2026 18:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Several moderate test coverage and UI test isolation issues remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds edge-case coverage for Siri exposure persistence, refresh behavior, migrations, cleanup, and reload UI handling.

Changes:

  • Adds database, migration, and server-deletion cleanup tests.
  • Tests the reload progress state.
  • Simplifies reload button action wiring.
File summaries
File Summary Review notes
Tests/App/Utilities/SiriServerConfigurationViewModelTests.swift Tests refresh and database failure paths. Nit: nest the recording updater helper.
Tests/App/Utilities/SiriEntityExposureTests.swift Tests persistence failures and migrations. Moderate: exercise an actual schema change.
Tests/App/Utilities/ServerDeletionSiriCleanupTests.swift Tests Siri cleanup during server deletion. Moderate: verify rows/defaults are removed directly.
Tests/App/Settings/SiriServerConfigurationView.test.swift Tests reload progress state. Moderate: assert hosted loading UI and avoid replacing the key window.
Sources/App/Settings/Siri/SiriServerConfigurationView.swift Passes the reload method directly. No findings.
Review details

Suppressed comments (3)

Tests/App/Settings/SiriServerConfigurationView.test.swift:76

  • makeKeyAndVisible() steals the process-wide key window, and this suite's serialization does not protect other UI/snapshot suites running in parallel; leaving that replacement window hidden can make those tests flaky. Existing render tests deliberately use a non-key window and clear its root controller (for example Tests/App/Settings/SettingsViewRender.test.swift:29-40), so use that teardown pattern here.
        window.makeKeyAndVisible()

Tests/App/Utilities/ServerDeletionSiriCleanupTests.swift:24

  • Because an absent exposure row is intentionally treated as exposed, these assertions cannot distinguish deletion from a row that remains with isExposed == true; they also would miss stale entity defaults. Query both tables and assert the server and entity rows are absent (or otherwise verify the default is removed), rather than checking only the fail-open read API.
        #expect(SiriServerExposure.isExposed(serverId: serverId))
        #expect(SiriEntityExposure.isExposed(serverId: serverId, entityId: "todo.a"))

Tests/App/Utilities/SiriServerConfigurationViewModelTests.swift:191

  • Please move RecordingSiriAppDatabaseUpdater inside SiriServerConfigurationViewModelTests (or give it its own file). This change adds a second top-level type to the test file, whereas the repository's one-type-per-file convention allows private helper types only when nested.
private final class RecordingSiriAppDatabaseUpdater: AppDatabaseUpdaterProtocol {
    struct Update {
        let serverId: String
        let forceUpdate: Bool
        let showProgress: Bool
  • Files reviewed: 5/5 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread Tests/App/Settings/SiriServerConfigurationView.test.swift
Comment thread Tests/App/Utilities/SiriEntityExposureTests.swift Outdated
@bgoncal
bgoncal enabled auto-merge (squash) September 16, 2026 18:54
@bgoncal
bgoncal merged commit edc7153 into main Sep 16, 2026
15 checks passed
@bgoncal
bgoncal deleted the bgoncal/siri-exposure-coverage branch September 16, 2026 20:04
@codecov

codecov Bot commented Sep 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 48.80%. Comparing base (ecca7aa) to head (ee3cdb3).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5821      +/-   ##
==========================================
+ Coverage   48.51%   48.80%   +0.29%     
==========================================
  Files        1185     1189       +4     
  Lines       78770    79012     +242     
==========================================
+ Hits        38214    38564     +350     
+ Misses      40556    40448     -108     
Files with missing lines Coverage Δ
...pp/Settings/Siri/SiriServerConfigurationView.swift 100.00% <100.00%> (ø)

... and 16 files with indirect coverage changes

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants