Skip to content

chore(language-chooser): cover defaultDisplayName and the bare chooser arrangement - #155

Merged
andrew-polk merged 1 commit into
mainfrom
language-chooser-coverage-gaps
Aug 26, 2026
Merged

chore(language-chooser): cover defaultDisplayName and the bare chooser arrangement#155
andrew-polk merged 1 commit into
mainfrom
language-chooser-coverage-gaps

Conversation

@andrew-polk

@andrew-polk andrew-polk commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Problem

Two gaps turned up while checking Bloom's manual regression cards for the language chooser against what EthnoLib already tests automatically.

defaultDisplayName is public API of the react-mui package — Bloom calls it directly to decide what to name a chosen language — and it had no unit test at all. Its entire job is a precedence rule (a script's own name for the language beats the language's autonym, which is what makes picking a script change the displayed name), plus returning nothing for the unlisted and manually-entered-tag languages, plus stripping the match markers that search results carry. None of that was pinned down, so any of it could have been changed silently.

Separately, nothing asserted on what the chooser tells a host application. Every existing e2e file drives DialogDemo, whose LanguageChooserDialog wrapper supplies its own OK button and so stands in for the host. Bloom instead passes its own actionButtons, no rightPanelComponent, and learns about the selection solely through onSelectionChange. That props arrangement wasn't unprecedented — ThemeDemo has rendered it for over a year, and PageDemo renders the chooser outside a dialog too — but neither observes the callback: ThemeDemo passes no onSelectionChange at all, and PageDemo keeps only the language tag. So the host half of the contract had demos, but no coverage.

What the PR does

  • Adds a defaultDisplayName suite (9 tests) to languageTagUtils.spec.ts, covering the precedence rule, both empty-string cases, and demarcation stripping — using the real demarcateResults rather than hand-faked markers.
  • Adds HostIntegrationDemo, which shows the callback in a panel beside the chooser and covers everything our main client consumes: Bloom's getLanguageData maps a selection onto a tag, a default name, the name to actually use, the script's reading direction and a country, so all five sit next to the raw fields they come from. Three details are deliberate:
    • it shows three names, not one. Showing only customDisplayName is misleading, because the chooser leaves it empty until the user edits the name field, so an ordinary selection looks like it reported nothing.
    • reading direction reads true / false / "not stated". A script can decline to say, Bloom keeps that distinction (its IsRtl is a bool?), and conflating "not stated" with false is what BL-13982 was about.
    • the OK button commits, so clicking it visibly does something.
  • Boxes the chooser at 1000×580 to match the WinForms dialog Bloom hosts it in, which also stops the page growing a scrollbar. The row wraps rather than shrinking that box, so a narrow window stacks instead of scrolling sideways.
  • Adds hostIntegration.e2e.ts (9 tests) asserting on that readout: usable with no right-panel component; what is reported once a language and script are chosen; that a cleared selection is reported rather than leaving the host holding a stale one; that a selection the user did not rename reports a default name but no custom one; the reading direction's three states; the derived country; and that a host-supplied action button both tracks the reports and commits.
  • main.tsx selects the demo with demo=host-integration, alongside the query parameters it already reads for e2e. The default path is untouched, so no existing test changes meaning.
  • Gives the new demo a Storybook story like the other three, so it sits next to them and doesn't rot unnoticed behind a URL parameter only Playwright uses.

This change is Reviewable


Devin review

@vercel

vercel Bot commented Aug 26, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
font-chooser-react-mui Ready Ready Preview Aug 26, 2026 5:48pm

@andrew-polk

Copy link
Copy Markdown
Contributor Author

(Claude Opus 5 (1M context)) Consulted Devin on 2026-08-26 15:18 UTC up to commit fa1c541776ac21325f8820fffb92998f4da69318.

Clean: no bugs, no investigate flags, no informational items.

@andrew-polk

Copy link
Copy Markdown
Contributor Author

(Claude Opus 5 (1M context)) Consulted Devin on 2026-08-26 16:07 UTC up to commit 83c0fe649ba62f0c139aafbd804a90da4244ce64 (the renamed HostIntegrationDemo).

Clean: no bugs, no investigate flags, no informational items.

@andrew-polk

Copy link
Copy Markdown
Contributor Author

(Claude Opus 5 (1M context)) Consulted Devin on 2026-08-26 up to commit 7f419115fc9849cd7aec9910dda90acbb34b0a45 (HostIntegrationDemo now covers all five fields Bloom consumes, in a side panel).

No bugs, no investigate flags. Two informational items, both confirming rather than questioning the change: that the defaultDisplayName assertions agree with the implementation and fixtures, and that the demo's reporting matches the callback contract. Neither mirrored as a review thread (informational items are low signal).

…ation contract

Two gaps turned up when comparing Bloom's regression test cards against
EthnoLib's automated tests.

defaultDisplayName is public API of the react-mui package (Bloom calls it
directly to name a language) and had no unit test at all. Its whole point is the
precedence rule -- a script's languageNameInScript wins over the autonym, which
is what makes picking a script change the displayed name -- plus the
empty-string cases for the unlisted and manually-entered-tag languages and the
stripping of search-result match markers. None of that was pinned down, so any
of it could have been changed silently.

Separately, nothing asserted on what the chooser tells a host application. Every
existing e2e file drives DialogDemo, whose LanguageChooserDialog wrapper supplies
its own OK button and stands in for the host. Bloom instead passes its own
actionButtons, no rightPanelComponent, and learns about the selection solely
through onSelectionChange. That props arrangement was not unprecedented --
ThemeDemo has rendered it for over a year, and PageDemo renders the chooser
outside a dialog too -- but neither observes the callback: ThemeDemo passes no
onSelectionChange at all and PageDemo keeps only the language tag. So the host
half of the contract had demos but no coverage.

HostIntegrationDemo shows that callback in a panel beside the chooser, covering
everything our main client consumes: Bloom's getLanguageData maps a selection
onto a tag, a default name, the name to actually use, the script's reading
direction and a country, so all five are shown next to the raw fields they come
from. Three details are deliberate:

- it shows three names, not one. Showing only customDisplayName is misleading,
  because the chooser leaves it empty until the user edits the name field, so an
  ordinary selection looks like it reported nothing.
- reading direction is spelled out as true / false / "not stated". A script can
  decline to say, Bloom keeps that distinction (its IsRtl is a bool?), and
  conflating "not stated" with false is what BL-13982 was about.
- the OK button commits, so clicking it visibly does something.

The chooser is boxed at 1000x580 to match the WinForms dialog Bloom hosts it in,
which also stops the page growing a scrollbar; the row wraps rather than
shrinking that box, so a narrow window stacks instead of scrolling sideways.

main.tsx selects the demo with demo=host-integration alongside the query params
it already reads for e2e; the default path is untouched. It also gets a Storybook
story like the other demos, so it is visible next to them and does not rot
unnoticed behind a URL parameter only Playwright uses.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@andrew-polk

Copy link
Copy Markdown
Contributor Author

(Claude Opus 5 (1M context)) Consulted Devin on 2026-08-26 up to commit f789dde7aaaab0c6a83e9f4c7a08b514d84f302e (panel spacing and width).

No bugs, no investigate flags. Two informational items, both confirming rather than questioning the change. Re-run because the previous consultation covered 7f41911, and amending the panel CSS changed the SHA.

@andrew-polk
andrew-polk marked this pull request as ready for review August 26, 2026 17:57
@andrew-polk
andrew-polk merged commit 038f953 into main Aug 26, 2026
4 checks passed
@andrew-polk
andrew-polk deleted the language-chooser-coverage-gaps branch August 26, 2026 18:01
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