Skip to content

View tests key-echo missing translations; LocalizationStore dispatch fix; multi-bundle store loading - #137

Merged
foscomputerservices merged 4 commits into
mainfrom
feat/view-test-key-echo
Aug 21, 2026
Merged

View tests key-echo missing translations; LocalizationStore dispatch fix; multi-bundle store loading#137
foscomputerservices merged 4 commits into
mainfrom
feat/view-test-key-echo

Conversation

@foscomputerservices

Copy link
Copy Markdown
Owner

What

Three related changes rooted in one field report: UI tests against views whose server-based ViewModels are populated via .stub() failed with element not found, because the harness had no YAML for those ViewModels — @LocalizedString resolved to "", SwiftUI collapsed the empty-labeled element to zero surface area, and XCUI could not reach it despite a uiTestingIdentifier().

feat(FOSTestingUI): view tests key-echo missing translations

ViewModelDisplayTestCase / ViewModelViewTestCase setUp now wraps the harness store in an internal KeyEchoLocalizationStore: a localized string with no translation resolves to visible placeholder text derived from its key, so every element keeps its surface area and stays drivable. A harness with no YAML at all is now supported (previously setUp threw).

The layering is deliberate:

  • View tests assert view behavior only — never string content. They no longer depend on YAML availability or copy stability.
  • Localization completeness stays LocalizableTestCase.expectTranslations()'s job, which continues to see the honest empty string.

The echo goes through the one existing seam (the store consulted by the localizing encoder) — no injection path into @LocalizedString. keyExists stays honest, explicit defaults win, and typed (non-string) misses remain misses via cast self-filtering. Covered by the new FOSTestingUITests target.

feat(FOSTesting): loadLocalizationStore(bundles:)

LocalizableTestCase suites can build one merged LocalizationStore from several bundles — the test bundle's client-hosted localizations plus a server target's resources — so server-based ViewModels verify against the same YAML the server serves.

fix(FOSMVVM): LocalizationStore convenience dispatch

Surfaced by this work's tests: the index-less keyExists(_:locale:) and t() conveniences derived their answers from value() directly, silently bypassing stores that customize the keyExists / translate witnesses. Both now dispatch their requirement; LocalizationStoreDispatchTests pins the dispatch.

Compatibility

No source-breaking changes: additions and same-signature resolution throughout. Behavior changes are the documented view-test placeholder contract and the dispatch fixes (observable only to stores whose custom witnesses disagreed with value() — previously silently ignored).

Testing

Full suite passes (swift test), including 7 new FOSTestingUITests tests, 3 dispatch tests, and a bundles-form test.

keyExists(_:locale:) and t() derived their answers from value() directly,
bypassing stores that customize the keyExists/translate witnesses. The
index-less keyExists is now a separate convenience that dispatches the
requirement, and t() forwards to translate(). Dispatch is pinned by
LocalizationStoreDispatchTests.
… YAML

LocalizableTestCase suites can now build one LocalizationStore from several
bundles — the test bundle's client-hosted localizations plus a server
target's resources — so server-based ViewModels verify against the same
YAML the server serves.
ViewModelDisplayTestCase/ViewModelViewTestCase setUp wraps the harness
store in KeyEchoLocalizationStore: a localized string with no translation
resolves to placeholder text derived from its key instead of the empty
string, which SwiftUI collapses to zero surface area, leaving elements
unreachable by XCUI despite a uiTestingIdentifier. keyExists stays honest,
explicit defaults win, typed (non-string) misses remain misses, and a
harness with no YAML at all is now supported. Localization completeness
remains LocalizableTestCase's job. New FOSTestingUITests target covers
the store.
@foscomputerservices
foscomputerservices merged commit 39536cb into main Aug 21, 2026
13 checks passed
@foscomputerservices
foscomputerservices deleted the feat/view-test-key-echo branch August 21, 2026 11:14
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.

1 participant