demoprep / tests /e2e_chat.py
mikeboone's picture
feat: march sprint β€” logging, run history, chat fixes, deploy sub-stages
2b5a90d
Raw
History Blame Contribute Delete
3.73 kB
"""
Chat interaction tests β€” verify the chat responds correctly to user input.
Tests navigate to the Chat sub-tab before interacting.
Run with: pytest tests/e2e_chat.py -v
"""
import pytest
from playwright.sync_api import Page, expect
from tests.conftest import logged_in_page, get_chat_textarea, wait_for_response # noqa: F401
def go_to_chat(page: Page):
"""Navigate to the Chat sub-tab."""
page.click('button[role=tab]:has-text("Chat")')
page.wait_for_timeout(1000)
expect(page.locator('button:has-text("Send")')).to_be_visible(timeout=15000)
def send_message(page: Page, text: str):
"""Type and send a chat message."""
chat_input = get_chat_textarea(page)
expect(chat_input).to_be_visible(timeout=30000)
chat_input.click()
chat_input.fill(text)
page.click('button:has-text("Send")')
class TestChatBasics:
def test_chat_input_responds(self, logged_in_page: Page):
"""Chat input accepts text and Send works."""
go_to_chat(logged_in_page)
send_message(logged_in_page, "help")
wait_for_response(logged_in_page, timeout_ms=60000)
body_text = logged_in_page.inner_text('body')
assert len(body_text) > 200
def test_message_clears_after_send(self, logged_in_page: Page):
"""Chat input is cleared after sending a message."""
go_to_chat(logged_in_page)
chat_input = get_chat_textarea(logged_in_page)
expect(chat_input).to_be_visible(timeout=30000)
chat_input.click()
chat_input.fill("hello")
logged_in_page.click('button:has-text("Send")')
expect(chat_input).to_have_value("", timeout=10000)
def test_invalid_input_gets_response(self, logged_in_page: Page):
"""Nonsense input still gets a graceful response."""
go_to_chat(logged_in_page)
send_message(logged_in_page, "asdfghjkl zxcvbnm")
wait_for_response(logged_in_page, timeout_ms=30000)
body_text = logged_in_page.inner_text('body')
assert len(body_text) > 200
class TestTabNavigation:
def test_can_switch_to_settings_tab(self, logged_in_page: Page):
"""Settings tab is clickable and shows settings content."""
logged_in_page.click('button[role=tab]:has-text("βš™οΈ Settings")')
logged_in_page.wait_for_timeout(1000)
body_text = logged_in_page.inner_text('body')
assert any(word in body_text.lower() for word in ["settings", "save", "model"])
def test_can_switch_back_to_app(self, logged_in_page: Page):
"""Can navigate away from and back to the App tab."""
logged_in_page.click('button[role=tab]:has-text("βš™οΈ Settings")')
logged_in_page.wait_for_timeout(500)
logged_in_page.click('button[role=tab]:has-text("πŸ“± App")')
logged_in_page.wait_for_timeout(500)
expect(logged_in_page.locator('button:has-text("β†’ GO")')).to_be_visible(timeout=10000)
def test_live_progress_tab_loads(self, logged_in_page: Page):
"""Live Progress tab is accessible and renders."""
logged_in_page.click('button[role=tab]:has-text("Live Progress")')
logged_in_page.wait_for_timeout(1000)
tab = logged_in_page.locator('button[role=tab]:has-text("Live Progress")')
expect(tab).to_have_attribute('aria-selected', 'true', timeout=5000)
def test_demo_assets_tab_loads(self, logged_in_page: Page):
"""Demo Assets tab is accessible."""
logged_in_page.click('button[role=tab]:has-text("🎬 Demo Assets")')
logged_in_page.wait_for_timeout(1000)
tab = logged_in_page.locator('button[role=tab]:has-text("🎬 Demo Assets")')
expect(tab).to_have_attribute('aria-selected', 'true', timeout=5000)