Skip to content

test: host view tests in off-screen windows (#364) - #366

Merged
isaaclins merged 1 commit into
mainfrom
fix/364-view-test-host
Sep 3, 2026
Merged

test: host view tests in off-screen windows (#364)#366
isaaclins merged 1 commit into
mainfrom
fix/364-view-test-host

Conversation

@isaaclins

Copy link
Copy Markdown
Owner

Part of #364.

ViewTestHost.host ordered every hosted view on screen as a key window. macOS then attaches out-of-process view services to hosted controls (Safari's SPCompletionListServiceViewController binds to text fields), and when a later test tore its window down while such a service was still bound, the next orderFront raised an NSRemoteView assertion that killed the whole test process. That is why three different unrelated tests failed across four full-suite runs with no code change between them.

The host window is now never ordered on screen. Layout, hit testing, ViewInspector and first responder all work off screen, and the tests that genuinely need key status already ask for it through AppKitTestSupport.makeFirstResponder.

Not verified locally: per the current working agreement I did not run the suite on this machine, only build-for-testing, which succeeded. CI is the verdict.

Left open in #364: the artwork-cache test that fails only in full-suite runs, and the missing per-test watchdog for hangs.

… attaches

Every hosted view was ordered on screen as a key window, so macOS bound out-of-process view services (Safari's completion-list helper) to hosted controls. Tearing one window down while a service was still bound made the next orderFront raise an NSRemoteView assertion that killed the whole test process, failing whichever test came next instead of the code that changed. Nothing in these tests needs to be visible; the ones that need key status still ask for it explicitly.
Copilot AI lite review requested due to automatic review settings September 3, 2026 15:03

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.

🟢 Approval recommended

The functional change is small and localized to test infrastructure, and the only feedback is a minor doc-comment wording clarification.

Pull request overview

Updates the macOS SwiftUI test hosting infrastructure to avoid ordering host windows on screen, preventing intermittent crashes caused by NSRemoteView assertions when out-of-process view services (e.g., Safari completion helper) attach to hosted controls during full-suite runs.

Changes:

  • Stop making every hosted test window key and ordering it on screen in ViewTestHost.host.
  • Add detailed documentation in ViewTestHost explaining the crash mechanism and why off-screen hosting is sufficient for most view tests.
File summaries
File Description
SpotiglassTests/Support/ViewTestHost.swift Removes makeKeyAndOrderFront from the shared view host and documents the rationale to reduce intermittent full-suite crashes.
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.

Comment on lines +69 to +72
/// to be next rather than on the code that changed (#364). Nothing here
/// needs to be visible: layout, hit testing, ViewInspector and first
/// responder all work in an off-screen window. Tests that genuinely need a
/// key window ask for one through `AppKitTestSupport.makeFirstResponder`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants