View tests key-echo missing translations; LocalizationStore dispatch fix; multi-bundle store loading - #137
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 —@LocalizedStringresolved to"", SwiftUI collapsed the empty-labeled element to zero surface area, and XCUI could not reach it despite auiTestingIdentifier().feat(FOSTestingUI): view tests key-echo missing translations
ViewModelDisplayTestCase/ViewModelViewTestCasesetUp now wraps the harness store in an internalKeyEchoLocalizationStore: 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 (previouslysetUpthrew).The layering is deliberate:
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.keyExistsstays honest, explicit defaults win, and typed (non-string) misses remain misses via cast self-filtering. Covered by the newFOSTestingUITeststarget.feat(FOSTesting):
loadLocalizationStore(bundles:)LocalizableTestCasesuites can build one mergedLocalizationStorefrom 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):
LocalizationStoreconvenience dispatchSurfaced by this work's tests: the index-less
keyExists(_:locale:)andt()conveniences derived their answers fromvalue()directly, silently bypassing stores that customize thekeyExists/translatewitnesses. Both now dispatch their requirement;LocalizationStoreDispatchTestspins 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 newFOSTestingUITeststests, 3 dispatch tests, and a bundles-form test.