Skip to content

Add SwiftUI hosting smoke tests for field-level Observation - #22

Merged
sonmbol merged 2 commits into
sonmbol:mainfrom
thliu21:agent/kmpobservablebridge-18
Aug 5, 2026
Merged

Add SwiftUI hosting smoke tests for field-level Observation#22
sonmbol merged 2 commits into
sonmbol:mainfrom
thliu21:agent/kmpobservablebridge-18

Conversation

@thliu21

@thliu21 thliu21 commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add Apple-platform SwiftUI hosting smoke tests for two independent projected fields
  • verify a field B emission does not reevaluate the field A-only subtree on Observation-capable systems
  • verify global invalidation and the ObservableObject fallback both invalidate the expected hosted subtrees
  • make view identity, shared observation setup, and teardown cancellation explicit
  • document supported Xcode versions and simulator destinations

Fixes #18

Harness

Each projected field is rendered by a separate SwiftUI View identity. The
runtime path uses KMPObservedObject, while a test-only configuration forces
the same production store through its ObservableObject fallback.

The source emits dependency notifications synchronously. Tests wait for
positive body-render and cancellation signals; timeouts are failure bounds
only. The field-isolation assertion is made after the B subtree has rendered,
without an inverted expectation or sleep.

The suite also includes a runtime-gated iOS 15/16 fallback test. A forced
fallback test keeps that contract covered on current runtimes when an older
simulator is unavailable.

Validation

  • SwiftUI hosting suite: 3 passed, 1 expected runtime skip, 0 failures
  • repeated hosting run: 3 passed, 1 expected runtime skip, 0 failures
  • complete strict-concurrency compilation
  • API compatibility: no breaking changes in all three products
  • package manifest consistency
  • whitespace validation

The repository-wide -warnings-as-errors command currently stops on three
pre-existing Swift 6.3 WeakMutability diagnostics in
KMPObservableBridgeTests.swift; the new hosting test file compiles without
diagnostics.

Verified locally with Xcode 26.5 on macOS 26.5.2. An iOS 15/16 runtime was not
installed locally, so that runtime-specific case remains explicitly
unverified rather than being reported as passed.

@sonmbol sonmbol left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thank you for identifying and covering this important gap. Exercising field-level dependency behavior through a real SwiftUI hosting graph adds valuable protection beyond the existing registrar-level tests. The direction is strong, and the production code remains untouched.

I found a few test-correctness and organization details that should be addressed before merge. They are noted inline below.

Comment thread Tests/KMPObservableBridgeTests/KMPObservableBridgeSwiftUIHostingTests.swift Outdated
Comment thread Tests/KMPObservableBridgeTests/KMPObservableBridgeSwiftUIHostingTests.swift Outdated

@sonmbol sonmbol left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thank you again for adding this important SwiftUI hosting coverage. All requested changes are now addressed: teardown is verified before skips, field isolation uses a deterministic render fence, the test support is separated by responsibility, and teardown callbacks are consumed once.

Validated with 45 tests under strict concurrency and warnings as errors, public API compatibility for all products, package-manifest consistency, and whitespace checks.

@sonmbol
sonmbol merged commit 6a41168 into sonmbol:main Aug 5, 2026
4 checks passed
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.

Add SwiftUI hosting smoke tests for field-level Observation

2 participants