mirror of
https://github.com/outbackdingo/optimclaw.git
synced 2026-08-25 14:53:34 +00:00
fix: navigate telegram E2E tests to channels subtab (#1408)
* fix: navigate telegram E2E tests to channels subtab wasm_channel extensions (like telegram) are now rendered in the Settings → Channels subtab, not the Extensions subtab. Update test_telegram_hot_activation to navigate there and use the correct card selector. Also mock /api/gateway/status which loadChannelsStatus fetches. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * fix: select telegram card by name, not first card in channels subtab Built-in channel cards (Web Gateway, HTTP, etc.) render first in the channels subtab content, so .first matches them instead of the telegram extension card. Select by has_text="Telegram" to target the correct card. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * refactor: make gateway_status_handler parameterizable in mock helper Address review feedback: extract default gateway status handler and accept an optional gateway_status_handler kwarg in mock_extension_lists for test flexibility. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
b9e5acf66e
commit
07c6ca72e9
@@ -33,18 +33,28 @@ _TELEGRAM_ACTIVE = {
|
||||
}
|
||||
|
||||
|
||||
async def go_to_extensions(page):
|
||||
async def go_to_channels(page):
|
||||
"""Navigate to Settings → Channels subtab (where wasm_channel extensions live)."""
|
||||
await page.locator(SEL["tab_button"].format(tab="settings")).click()
|
||||
await page.locator(SEL["settings_subtab"].format(subtab="extensions")).click()
|
||||
await page.locator(SEL["settings_subpanel"].format(subtab="extensions")).wait_for(
|
||||
await page.locator(SEL["settings_subtab"].format(subtab="channels")).click()
|
||||
await page.locator(SEL["settings_subpanel"].format(subtab="channels")).wait_for(
|
||||
state="visible", timeout=5000
|
||||
)
|
||||
await page.locator(
|
||||
f"{SEL['extensions_list']} .empty-state, {SEL['ext_card_installed']}"
|
||||
).first.wait_for(state="visible", timeout=8000)
|
||||
# Wait for the Telegram card specifically (built-in cards render first)
|
||||
await page.locator(SEL["channels_ext_card"], has_text="Telegram").wait_for(
|
||||
state="visible", timeout=8000
|
||||
)
|
||||
|
||||
|
||||
async def mock_extension_lists(page, ext_handler):
|
||||
async def _default_gateway_status_handler(route):
|
||||
await route.fulfill(
|
||||
status=200,
|
||||
content_type="application/json",
|
||||
body=json.dumps({"enabled_channels": [], "sse_connections": 0, "ws_connections": 0}),
|
||||
)
|
||||
|
||||
|
||||
async def mock_extension_lists(page, ext_handler, *, gateway_status_handler=None):
|
||||
async def handle_ext_list(route):
|
||||
path = route.request.url.split("?")[0]
|
||||
if path.endswith("/api/extensions"):
|
||||
@@ -70,6 +80,10 @@ async def mock_extension_lists(page, ext_handler):
|
||||
await page.route("**/api/extensions*", handle_ext_list)
|
||||
await page.route("**/api/extensions/tools", handle_tools)
|
||||
await page.route("**/api/extensions/registry", handle_registry)
|
||||
await page.route(
|
||||
"**/api/gateway/status",
|
||||
gateway_status_handler or _default_gateway_status_handler,
|
||||
)
|
||||
|
||||
|
||||
async def wait_for_toast(page, text: str, *, timeout: int = 5000):
|
||||
@@ -107,9 +121,9 @@ async def test_telegram_setup_modal_shows_bot_token_field(page):
|
||||
|
||||
await mock_extension_lists(page, handle_ext_list)
|
||||
await page.route("**/api/extensions/telegram/setup", handle_setup)
|
||||
await go_to_extensions(page)
|
||||
await go_to_channels(page)
|
||||
|
||||
card = page.locator(SEL["ext_card_installed"]).first
|
||||
card = page.locator(SEL["channels_ext_card"], has_text="Telegram")
|
||||
await card.locator(SEL["ext_configure_btn"], has_text="Setup").click()
|
||||
|
||||
modal = page.locator(SEL["configure_modal"])
|
||||
@@ -199,9 +213,9 @@ async def test_telegram_hot_activation_transitions_installed_to_active(page):
|
||||
|
||||
await mock_extension_lists(page, handle_ext_list)
|
||||
await page.route("**/api/extensions/telegram/setup", handle_setup)
|
||||
await go_to_extensions(page)
|
||||
await go_to_channels(page)
|
||||
|
||||
card = page.locator(SEL["ext_card_installed"]).first
|
||||
card = page.locator(SEL["channels_ext_card"], has_text="Telegram")
|
||||
await card.locator(SEL["ext_configure_btn"], has_text="Setup").click()
|
||||
|
||||
modal = page.locator(SEL["configure_modal"])
|
||||
|
||||
Reference in New Issue
Block a user