feat: Textual TUI app — widget rendering, socket client, user events
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
import asyncio
|
||||
import json
|
||||
|
||||
import pytest
|
||||
from textual.app import App
|
||||
|
||||
from kitty_workbench.tui import KittWorkbenchApp
|
||||
from kitty_workbench.protocol import (
|
||||
encode_message, InitCmd, DisplayCmd, LayoutCmd, LogCmd, ClearCmd, ShutdownCmd,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_app_instantiates():
|
||||
app = KittWorkbenchApp(socket_path="/tmp/nonexistent.sock")
|
||||
assert isinstance(app, App)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_app_handles_markdown_display():
|
||||
app = KittWorkbenchApp(socket_path="/tmp/nonexistent.sock")
|
||||
async with app.run_test(size=(80, 24)) as pilot:
|
||||
app.handle_command(DisplayCmd(
|
||||
widget="markdown",
|
||||
content="# Hello World\n\nThis is a test.",
|
||||
pane="main",
|
||||
))
|
||||
await pilot.pause()
|
||||
assert app.is_running
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_app_handles_layout():
|
||||
app = KittWorkbenchApp(socket_path="/tmp/nonexistent.sock")
|
||||
async with app.run_test(size=(80, 24)) as pilot:
|
||||
app.handle_command(LayoutCmd(panes={
|
||||
"main": {"ratio": 2},
|
||||
"sidebar": {"ratio": 1, "position": "right"},
|
||||
"log": {"ratio": 1, "position": "bottom"},
|
||||
}))
|
||||
await pilot.pause()
|
||||
assert app.query_one("#sidebar") is not None
|
||||
assert app.query_one("#log") is not None
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_app_handles_log():
|
||||
app = KittWorkbenchApp(socket_path="/tmp/nonexistent.sock")
|
||||
async with app.run_test(size=(80, 24)) as pilot:
|
||||
app.handle_command(LayoutCmd(panes={
|
||||
"main": {"ratio": 2},
|
||||
"log": {"ratio": 1, "position": "bottom"},
|
||||
}))
|
||||
await pilot.pause()
|
||||
app.handle_command(LogCmd(entry="R412 measured 1.05M — FAIL", level="warning"))
|
||||
await pilot.pause()
|
||||
assert app.is_running
|
||||
Reference in New Issue
Block a user