fix(react-ui/e2e): scope backendTrigger to <main> so it skips LanguageSwitcher

The LanguageSwitcher added in the i18n PR (#9642) lives in the sidebar
and also uses aria-haspopup="listbox" — same attribute the import-form
SearchableSelect uses. The Batch D / E tests' helper resolved the trigger
with `page.locator('button[aria-haspopup="listbox"]').first()`, which now
returns the language switcher (rendered first in DOM order, in the
sidebar) instead of the backend dropdown.

After clicking the wrong button, getByRole('option', { name: 'llama-cpp' })
naturally never resolves — language options aren't backend names — and
the test times out at 30s.

Scope the locator to the <main className="main-content"> wrapper so only
buttons inside the route's main content area match. The page layout has
the Sidebar outside <main>, so this cleanly excludes it.

Assisted-by: Claude:claude-opus-4-7[1m] [Claude Code]
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
Ettore Di Giacinto
2026-05-04 08:58:25 +00:00
parent ade5fd4b97
commit a271c72931
2 changed files with 7 additions and 4 deletions

View File

@@ -52,10 +52,10 @@ async function enterPowerPreferences(page) {
}
// Backend dropdown trigger — the SearchableSelect button has
// `aria-haspopup="listbox"`. There's exactly one on the Power/Preferences
// page so the first match is stable.
// `aria-haspopup="listbox"`. The LanguageSwitcher in the sidebar uses the
// same attribute, so scope to the <main> content area to skip it.
function backendTrigger(page) {
return page.locator('button[aria-haspopup="listbox"]').first()
return page.locator('main button[aria-haspopup="listbox"]').first()
}
async function selectBackend(page, name) {

View File

@@ -59,7 +59,10 @@ function chip(page, key) {
}
function backendTrigger(page) {
return page.locator('button[aria-haspopup="listbox"]').first()
// Scope to <main>: the LanguageSwitcher in the sidebar also uses
// aria-haspopup="listbox", so an unscoped .first() selector picks it
// instead of the backend dropdown.
return page.locator('main button[aria-haspopup="listbox"]').first()
}
test.describe('Import form UX — Batch E (modality chip row)', () => {