Test the language chooser -> Bloom data mapping - #8236
Conversation
|
(Claude Opus 5 (1M context)) Consulted Devin on 2026-08-26 04:59 UTC up to commit Clean: no bugs, no investigate flags, no informational items. |
|
| Filename | Overview |
|---|---|
| src/BloomBrowserUI/collection/languageData.ts | Extracts the existing language-selection mapping unchanged into a standalone module. |
| src/BloomBrowserUI/collection/languageData.test.ts | Adds focused Vitest coverage for all serialized language-data fields and documented edge cases. |
| src/BloomExe/web/controllers/LanguageChangeEventArgs.cs | Introduces an IsCustomName property equivalent to the previously repeated string comparison. |
| src/BloomExe/Collection/CollectionSettingsDialog.cs | Replaces four equivalent inline custom-name comparisons with the shared property. |
| src/BloomTests/web/controllers/LanguageChangeEventArgsTests.cs | Adds NUnit coverage for custom-name classification and the intentionally distinct PublishApi rule. |
Reviews (2): Last reviewed commit: "Test the language chooser -> Bloom data ..." | Re-trigger Greptile
|
(Claude Opus 5 (1M context)) Consulted Devin on 2026-08-26 up to commit No bugs, no investigate flags. Two informational items, both confirming rather than questioning the change: that the C# Note: |
getLanguageData() is the single point where everything the EthnoLib language chooser knows about a selection crosses into Bloom's C# side: the language tag, the name to display, whether the user renamed it, whether the script reads right-to-left, and the country. Three shipped bugs -- BL-15190, BL-13982 and BL-14426 -- were all defects in this one function, and it had no automated test of any kind. Move getLanguageData() and ILanguageData, unchanged, out of LanguageChooserDialog.tsx into their own collection/languageData.ts, so tests can reach the function without loading the dialog's MUI and bloomApi chain. The interface and the function body are byte-for-byte what they were. Add 16 vitest tests. Twelve cover the five fields the C# side receives -- including the difference between "the script says left-to-right" and "the script didn't say", which is what BL-13982 turned on. The other four pin the corners where this function deliberately differs from EthnoLib's defaultDisplayName(language, script), which is the obvious thing to replace it with: that returns "" for the unlisted language and for manually-entered-tag languages even when a script is supplied. Nothing reachable depends on the difference today, so those tests exist to make folding the two together a deliberate decision rather than a silent behavior change. On the C# side, the rule for "did the user type this name or accept the offered one?" was written out inline, four times over, in CollectionSettingsDialog's handlers for Language 1, 2, 3 and the sign language. It could not be tested as written -- a test could only have re-implemented the comparison and asserted on itself. It now has a name, LanguageChangeEventArgs.IsCustomName, and all four sites call it. Behavior is unchanged; 9 NUnit tests cover it. Also record why the sign-language handler, unlike Language 1-3, does not apply args.IsRtl: a sign language has no text direction. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
a954e61 to
7a195de
Compare
…g-tests Test the language chooser -> Bloom data mapping
Problem
Picking a language in the language chooser hands Bloom five things that cross from TypeScript into C#: the language tag, the name to show, whether the user renamed it, whether the script reads right-to-left, and the country. Neither side of that handoff had a single automated test.
It has not been quiet code. Three shipped bugs were defects in the TypeScript half alone — BL-15190 (choosing a script didn't change the name Bloom stored), BL-13982 (the right-to-left setting stopped surviving a restart) and BL-14426 (the C# side couldn't read the name field at all). A fourth defect of the same shape would have reached users the same way.
What the PR does
The TypeScript half. Moves
getLanguageData()andILanguageData, unchanged, out ofLanguageChooserDialog.tsxinto their ownlanguageData.ts, so tests can reach the function without loading the dialog's MUI andbloomApichain. The function body is byte-for-byte what it was. Adds 12 tests over the five fields — including the difference between "the script says left-to-right" and "the script didn't say", which is what BL-13982 turned on — plus 4 more pinning the corners where this function deliberately differs from EthnoLib'sdefaultDisplayName(language, script), so folding the two together has to be a decision rather than an accident.The C# half. Bloom decides whether a name is the language's own or one the user typed by comparing
DesiredNamewithDefaultName— written out inline, four times over, in the handlers for Language 1, 2, 3 and the sign language. That could not be tested as written; a test could only have re-implemented the comparison and asserted on itself. It now has a name,LanguageChangeEventArgs.IsCustomName, and all four sites call it. Behavior is unchanged, the duplication is gone, and 9 NUnit tests cover it.PublishApihas its own, different rule for the same question, and this PR does not touch it — that divergence is described in the remarks onIsCustomNameand pinned by two tests, so it cannot be unified by accident. Fixing it is BL-16760, in the PR stacked on this one.Also records why the sign-language handler, unlike Language 1-3, does not apply
args.IsRtl: a sign language has no text direction.Every production change here is behavior-preserving.
Devin review
This change is