codeflash-agent/packages/blackbox/tests/e2e/test_session_list.py
Kevin Turcios 0ad5e60523
Add blackbox package: session flight recorder with HTMX dashboard (#39)
* feat(blackbox): add package with models, CLI, and HTMX dashboard

* test(blackbox): add comprehensive test coverage for dashboard

* feat(blackbox): cache session scanning via watcher invalidation

* docs(blackbox): add README and use fastapi[standard] for dev server

* refactor(blackbox): extract presentation logic into formatter classes

* refactor(blackbox): extract classify_error helpers

* feat(blackbox): wire analytics into session detail view

Show token usage, tool breakdowns, and session stats in a
collapsible panel when viewing a session.

* feat(blackbox): add codeflash plugin detection

Detect codeflash agent names, skills, and commands in transcripts.
Surface language, optimization domain, and capability badges in
the analytics panel.

* refactor(blackbox): remove underscore prefixes from internal functions

* chore: add ty python-version to root pyproject.toml

* chore(blackbox): fix lint errors in test files

* style(blackbox): apply ruff formatting to analytics

* feat(blackbox): add Playwright E2E tests for dashboard

Refactor app.py to expose create_app() factory accepting a projects_dir
override, enabling tests to run against fixture data instead of the real
~/.claude/projects/ directory. Routes now read projects_dir from
app.state instead of the module-level constant.

Add 26 Playwright tests across 5 files covering dashboard loading,
session list, session detail with filters and analytics, sidebar
collapse/localStorage persistence, and SSE log streaming. All tests
pass on chromium, firefox, and webkit (78 total).

CI gets a new e2e-blackbox job with a browser matrix strategy running
all three engines in parallel, conditional on blackbox path changes,
with trace upload on failure.

* fix(ci): sync only blackbox package in e2e job

* fix(ci): exclude e2e tests from unit test job

The test job doesn't install Playwright browsers, so e2e tests error
when pytest collects them. Ignore tests/e2e/ directories in the test
job — those are handled by the dedicated e2e-blackbox job.
2026-04-28 19:58:43 -05:00

42 lines
1.6 KiB
Python

"""Tests for the session list sidebar."""
from __future__ import annotations
from typing import TYPE_CHECKING
import pytest
from playwright.sync_api import expect
if TYPE_CHECKING:
from playwright.sync_api import Page
pytestmark = pytest.mark.e2e
class TestSessionList:
"""Session list sidebar displays session metadata correctly."""
def test_project_names_visible(self, dashboard: Page) -> None:
"""Project names from fixture data appear in the session list."""
expect(dashboard.get_by_text("work/myapp")).to_be_visible()
expect(dashboard.get_by_text("code/webapp")).to_be_visible()
def test_first_prompt_shown(self, dashboard: Page) -> None:
"""First user prompt is displayed in the session item."""
expect(dashboard.get_by_text("Help me optimize this function")).to_be_visible()
def test_session_id_prefix_shown(self, dashboard: Page) -> None:
"""The 8-char session ID prefix is visible."""
expect(dashboard.get_by_text("sess-aaa")).to_be_visible()
expect(dashboard.get_by_text("sess-bbb")).to_be_visible()
def test_message_count_shown(self, dashboard: Page) -> None:
"""Message count badge is visible for sessions with messages."""
expect(dashboard.get_by_text("4 msgs")).to_be_visible()
def test_session_list_refreshes_on_poll(self, dashboard: Page) -> None:
"""The HTMX poll fires and the list remains populated."""
with dashboard.expect_response("**/sessions*"):
dashboard.wait_for_timeout(5500)
items = dashboard.locator("#session-list-container > div")
assert items.count() >= 2