Repository navigation
test(l10n): pin the metadata editor's IME next-action in zh - #314
Merged
Merged
Conversation
_buildField chose its keyboard action by comparing the label text:
textInputAction: label == 'Title' ? TextInputAction.next : null,
Callers pass l10n.title in, so this was right in English and broken in every
other locale -- the label became 标题, the comparison failed, and the Title
field lost its "next" key. That shipped once and was fixed in d6a6975 (moss-apps#297).
It is a class A trap, but source_guard_test.dart cannot see it: the localized
string reaches _buildField through a parameter, so the evidence sits at the
call site and no single-file data-flow rule reaches it. Confirmed by restoring
the buggy line and watching source_guard stay green. Only a rendered widget
catches this, so the test pins the behaviour, not the source text.
Three cases: the field labelled l10n.title carries TextInputAction.next in zh
and in en, and the Artist field does not claim it. Labels come from
AppLocalizations rather than hardcoded strings; the zh case also asserts
l10n.title != 'Title' so it cannot pass vacuously.
Verified red on the historical bug, and red when the bug is injected into the
bottom sheet alone -- the deprecated MetadataEditorScreen is referenced nowhere
in lib/ or test/, so the sheet is the only live path.
flutter analyze: 29 issues, the main baseline. test/l10n/ plus this file: 10/10.
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.
Summary
Adds the one regression test the source guard cannot express: the metadata
editor's IME next-action must survive localization.
_buildFieldused to pick the keyboard action by comparing the label text:Callers pass
l10n.titlein, so this was correct in English and silently brokenin every other locale — the label became 标题, the comparison failed, and the
Title field lost its "next" key, so the IME could no longer advance from Title to
Artist. That shipped once and was fixed in d6a6975 (#297).
This is a class A trap (a localized value used as a key), but
test/l10n/source_guard_test.dartcannot see it: the localized string reaches_buildFieldthrough a parameter, so the evidence is at the call site and nosingle-file data-flow rule reaches it. I confirmed that by restoring the exact
buggy line and watching
source_guard_test.dartstay green. Only a renderedwidget catches it, so this file pins the behaviour instead of the source text.
test/features/songs/metadata_editor_ime_test.dart(3 cases):l10n.titlehastextInputAction == TextInputAction.nextnext, or the chain Title promises is a lieLabels are read from
AppLocalizationsrather than hardcoded, so the test doesnot need editing when a translation changes. The zh case asserts
l10n.title != 'Title'first, so it cannot pass vacuously if the locale wiring ever breaks.Related issue
none
Checklist
flutter analyzepassesflutter testpassescargo test --manifest-path rust/Cargo.tomlpassesflutter run --flavor full)CHANGELOG.mdupdated for user-facing changesNotes on the unchecked boxes:
diff is one new test file plus nothing else.
added — this test reads existing keys.
Verification
flutter analyze: 29 issues, the same baseline asmain(all pre-existing infos).flutter test: the new file passes 3/3, andtest/l10n/plus this file pass 10/10together.
Per the rule that a new test has to fail on the code it guards, I restored the
historical bug and confirmed the new test goes red — and only on the zh case:
It reports the localized failure, exactly the shipped symptom. Restoring the fix
turns it green again, and injecting the bug into the bottom sheet alone still
turns it red, so it really does pin the live path: the deprecated
MetadataEditorScreenis referenced nowhere inlib/ortest/.Local note, not a property of this PR: this machine's
TEMPpoints into anothercheckout's
build/tmp, so ~43 unrelated tests fail here on a file-locking errorand on Windows-vs-POSIX path separators. That is pre-existing on unmodified
main; none of it is intest/l10n/or this file, and CI runs on Ubuntu.