Files
webterm/tests/test_cli_landing.py
T
GitHub Copilot d5343117d3 Filter DA1 responses from replay buffer on WebSocket connect
The replay buffer can contain DA1/DA2 terminal attribute responses
(e.g., \x1b[?1;10;0c) that were captured before filtering was added
to the session classes. These responses appear as visible text like
'1;10;0c' when sent to the client on reconnect.

This adds an additional filter pass when sending the replay buffer,
ensuring no DA1 responses reach the client regardless of when they
were captured.
2026-01-29 19:13:40 +00:00

72 lines
1.8 KiB
Python

import asyncio
from pathlib import Path
from click.testing import CliRunner
from webterm import cli
def test_cli_landing_manifest_runs(monkeypatch, tmp_path: Path):
manifest = tmp_path / "landing.yaml"
manifest.write_text(
"""
- name: One
slug: one
command: echo one
"""
)
called = {}
class FakeServer:
def __init__(self, *_args, **_kwargs):
called["init"] = True
def add_terminal(self, name, command, slug):
called["terminal"] = (name, command, slug)
async def run(self):
called["run"] = True
monkeypatch.setattr(cli, "LocalServer", FakeServer)
monkeypatch.setattr(cli, "asyncio", asyncio)
runner = CliRunner()
result = runner.invoke(cli.app, ["-L", str(manifest)])
assert result.exit_code == 0
assert called.get("terminal") == ("One", "echo one", "one")
assert called.get("run") is True
def test_cli_compose_manifest_runs(monkeypatch, tmp_path: Path):
manifest = tmp_path / "compose.yaml"
manifest.write_text(
"""
services:
svc1:
labels:
webterm-command: echo svc1
"""
)
called = {}
class FakeServer:
def __init__(self, *_args, **_kwargs):
called["init"] = True
def add_terminal(self, name, command, slug):
called["terminal"] = (name, command, slug)
async def run(self):
called["run"] = True
monkeypatch.setattr(cli, "LocalServer", FakeServer)
monkeypatch.setattr(cli, "asyncio", asyncio)
runner = CliRunner()
result = runner.invoke(cli.app, ["-C", str(manifest)])
assert result.exit_code == 0
assert called.get("terminal") == ("svc1", "echo svc1", "svc1")
assert called.get("run") is True