mirror of
https://github.com/nearai/ironclaw.git
synced 2026-09-02 23:56:24 +08:00
test(e2e): harden tab_button selector against strict-mode duplicates (#2656)
Closes #2626.
`tests/e2e/helpers.py` used `.tab-bar button[data-tab="{tab}"]` to locate
every main-nav tab button. Commit 5058a1cf removed the duplicate
right-side `status-logs-btn` Jobs button that was resolving that selector
to two elements on staging, so `test_connection.py` passes again. The
underlying selector is still fragile: any future auxiliary button or
`_addWidgetTab`-injected tab that reuses a built-in `data-tab` id (even
accidentally, as #2353 did) will make the selector resolve to multiple
elements and trip Playwright strict mode the next CI run.
Harden the selector in place — the issue's suggested direction of
scoping to a more specific parent region — so the regression can't
repeat without a test-side opt-in:
- `.tab-bar > button`: direct child, skipping any hypothetical nested
buttons (e.g. menu popovers).
- `:not(.status-logs-btn)`: excludes the right-side logs/docs cluster
that uses the same `data-tab` hook for click routing.
- `:not(.tab-btn)`: excludes widget-injected tabs (see `_addWidgetTab`
in `crates/ironclaw_gateway/static/app.js`), which always carry the
`tab-btn` class and could in principle collide with a built-in id.
Verified against a synthetic DOM with three colliding `data-tab="jobs"`
buttons (original, status-logs-btn duplicate, widget-injected): the old
selector matches 3 and trips strict mode on `.click()`; the new
selector matches 1 and clicks cleanly. No production HTML change is
required — the acceptance criterion explicitly forbids one.
`pytest tests/e2e/scenarios/test_connection.py -v` → 3 passed.
This commit is contained in:
@@ -20,7 +20,12 @@ SEL = {
|
||||
"auth_screen": "#auth-screen",
|
||||
"token_input": "#token-input",
|
||||
# Tabs
|
||||
"tab_button": '.tab-bar button[data-tab="{tab}"]',
|
||||
# Scope to the main tab-bar buttons only. `.status-logs-btn` covers the
|
||||
# right-aligned auxiliary buttons (logs, docs link) and `.tab-btn` covers
|
||||
# widget-injected tabs added by `_addWidgetTab`. Excluding both keeps the
|
||||
# selector a single match under Playwright strict mode even if a widget
|
||||
# or auxiliary button is ever introduced with a colliding `data-tab` id.
|
||||
"tab_button": '.tab-bar > button[data-tab="{tab}"]:not(.status-logs-btn):not(.tab-btn)',
|
||||
"tab_panel": "#tab-{tab}",
|
||||
# Chat
|
||||
"chat_input": "#chat-input",
|
||||
|
||||
Reference in New Issue
Block a user