test(admin): pick the role option directly to deflake the allowed-domains dialog test - #2398
Conversation
…ains dialog test Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
There was a problem hiding this comment.
This is a narrowly scoped test-only fix for the flaky AllowedDomainsSettings browser test. The approach is sound: the failing interaction relied on two {ArrowDown} keystrokes to move exactly one step down in a Base UI/Kumo Select, which only works when one keystroke is swallowed by opening the popup and the highlight starts on the selected item. Replacing that with an explicit open + await for the role="option" element + programmatic click removes the ordering and popup-mount races and makes the test independent of ROLE_ENTRIES order. The fallback to programmatic clicks is consistent with sibling tests that already do the same inside modal dialogs (e.g., MenuEditor.test.tsx, delete confirmations in this file), and the PR author’s reasoning for not using userEvent.click (Base UI inert overlay intercepts pointer events) matches the patterns already present in the repo.
Nothing in the change touches runtime code, logged-out routes, content-table queries, localization, SQL, or authorization, so the usual AGENTS.md cross-cutting checks do not apply. The labels used in the test (Default Role, Editor) are the same English-source Lingui strings used in the component and fixtures, so the test is appropriately locale-locked like the other admin tests.
I read the diff, the full test file, the component under test, the roles config hook, and several sibling tests. No AGENTS.md convention violations or correctness issues; this is a clean deflake.
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/auth-atproto
@emdash-cms/blocks
@emdash-cms/cloudflare
@emdash-cms/contentful-to-portable-text
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/plugin-cli
@emdash-cms/plugin-types
@emdash-cms/registry-client
@emdash-cms/registry-lexicons
@emdash-cms/registry-verification
@emdash-cms/sandbox-workerd
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-field-kit
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
What does this PR do?
Closes #2387
AllowedDomainsSettings.test.tsx > updates the default role from the edit dialogis flaky on CI — #2387 has the full analysis and a failing run. In short: the
test drives the
Default Roleselect blind:The option list for this dialog is Subscriber (10) / Contributor (20) /
Author (30) / Editor (40) —
useAllowedDomainsRolesConfigfiltersROLE_ENTRIEStovalue <= MAX_SELF_SIGNUP_DEFAULT_ROLE. The fixture domainstarts at Author (30) and the assertion expects Editor (40), which is exactly
one step down the list. The test sends two
{ArrowDown}s — so itpasses only when exactly one keystroke is absorbed by opening the popup and
the highlight starts on the currently selected item. When that doesn't hold,
{Enter}commits Subscriber (10), the first item in the list — the exactfailure in #2387, and the same flip shows up in the CI history of #2374, where
the admin package is byte-identical across three SHAs yet
Browser Testsgoesfail/pass/fail (details in
#2374 (comment)).
The change: open the select and click the Editor option directly. Kumo's
Select.Optionrenders Base UI's select item withrole="option", so theoption can be addressed by its accessible name. The test awaits the option's
visibility before clicking, which removes the popup-mount race and makes the
test independent of the ordering of
ROLE_ENTRIES.Why not
userEvent.click, as suggested in #2387The issue suggests the pattern from
Settings.test.tsx—userEvent.clickonthe combobox, then on the option. That pattern works there because the language
combobox sits on the settings page; inside this modal dialog it times out on
the very first click, on the trigger, because Base UI's inert overlay
intercepts the pointer events:
The clicks are therefore programmatic (
element().click()), following thedelete-confirmation tests in the same file, which already use a programmatic
confirmButton.click()for the same reason. That interception is also thelikely reason this test used blind keyboard navigation in the first place.
On the sweep suggested in #2387: this is the only keyboard-driven
Selectinteraction of this shape in the admin tests. The
{ArrowDown}uses inslash-menu.test.tsxdrive the editor's slash menu, andSortableContentSettingsSections.test.tsxdrives drag-reorder — neither is aSelect.Why there is no failing test in this PR
CONTRIBUTING.mdasks bug fixes to include a failing test. That does not applycleanly here, because the test is the defect: it asserts a correct
expectation through an unreliable interaction, and the race cannot be pinned
deterministically without changing the very timing under test. The evidence is
the failing run linked in #2387 and the fail/pass/fail CI history of #2374
across byte-identical admin sources.
Type of change
Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (or targeted tests for my change) — targeted file plus full admin browser suite, see belowpnpm formathas been runAI-generated code disclosure
Drafted and reviewed with Claude (Opus 5: diagnosis and draft; Fable 5: implementation and review pass, separate sessions).
Screenshots / test output
Targeted file, six consecutive green runs during drafting, re-verified in
review (two further targeted runs plus the full admin browser suite):
The
userEvent.clickvariant from #2387, tried on the same branch, failsdeterministically with the inert-overlay timeout quoted above.