fix(webui): persist markdown video previews
This commit is contained in:
@@ -155,6 +155,28 @@ def test_local_markdown_image_is_staged_and_rewritten(
|
||||
assert staged[0].read_bytes() == _PNG_BYTES
|
||||
|
||||
|
||||
def test_local_markdown_video_is_staged_and_rewritten(
|
||||
bus: MagicMock,
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
workspace = tmp_path / "workspace"
|
||||
workspace.mkdir()
|
||||
video_bytes = b"fake mp4"
|
||||
(workspace / "nanobot-intro.mp4").write_bytes(video_bytes)
|
||||
media = tmp_path / "media"
|
||||
channel = _ch(bus, workspace_path=workspace, port=0)
|
||||
|
||||
with patch("nanobot.channels.websocket.get_media_dir", side_effect=_fake_media_dir(media)):
|
||||
rewritten = channel._rewrite_local_markdown_images(
|
||||
"The result:\n"
|
||||
)
|
||||
|
||||
assert ".iterdir())
|
||||
assert len(staged) == 1
|
||||
assert staged[0].read_bytes() == video_bytes
|
||||
|
||||
|
||||
def test_local_markdown_image_rejects_workspace_escape(
|
||||
bus: MagicMock,
|
||||
tmp_path: Path,
|
||||
|
||||
@@ -66,6 +66,24 @@ def test_replay_uses_stream_end_final_text() -> None:
|
||||
assert msgs[1]["content"] == ""
|
||||
|
||||
|
||||
def test_replay_infers_video_media_from_attachment_name() -> None:
|
||||
msgs = replay_transcript_to_ui_messages(
|
||||
[
|
||||
{"event": "user", "chat_id": "t-video", "text": "render"},
|
||||
{
|
||||
"event": "message",
|
||||
"chat_id": "t-video",
|
||||
"text": "video ready",
|
||||
"media_urls": [{"url": "/api/media/sig/payload", "name": "intro.mp4"}],
|
||||
},
|
||||
],
|
||||
)
|
||||
|
||||
assert msgs[1]["media"] == [
|
||||
{"kind": "video", "url": "/api/media/sig/payload", "name": "intro.mp4"},
|
||||
]
|
||||
|
||||
|
||||
def test_replay_file_edit_event_creates_file_activity(tmp_path, monkeypatch) -> None:
|
||||
monkeypatch.setattr("nanobot.config.paths.get_data_dir", lambda: tmp_path)
|
||||
key = "websocket:t-file"
|
||||
|
||||
Reference in New Issue
Block a user