feat: add delayed prompt modal
This commit is contained in:
@@ -1050,6 +1050,80 @@ async def test_session_list_renders_harness_name_brackets():
|
||||
assert any("[claude]" in t for t in texts), f"harness name missing: {texts}"
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# SchedulePromptScreen: parse + submit
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def test_parse_delay_accepts_compact_seconds_minutes_hours():
|
||||
from datetime import timedelta
|
||||
|
||||
from hqt.tui.screens.schedule_prompt import parse_delay
|
||||
|
||||
assert parse_delay("90s") == timedelta(seconds=90)
|
||||
assert parse_delay("30m") == timedelta(minutes=30)
|
||||
assert parse_delay("2h") == timedelta(hours=2)
|
||||
assert parse_delay("1h30m") == timedelta(hours=1, minutes=30)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", ["", "0m", "abc", "1d", "1h 30m"])
|
||||
def test_parse_delay_rejects_invalid_values(value):
|
||||
from hqt.tui.screens.schedule_prompt import parse_delay
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
parse_delay(value)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize("submit_action", ["enter", "ok"])
|
||||
async def test_schedule_prompt_screen_submits_prompt_and_delay(submit_action):
|
||||
from datetime import timedelta
|
||||
|
||||
from hqt.tui.screens.schedule_prompt import SchedulePromptScreen
|
||||
from textual.widgets import Button, Input
|
||||
|
||||
app = HqtApp()
|
||||
async with app.run_test(size=(120, 40)) as pilot:
|
||||
results = []
|
||||
app.push_screen(SchedulePromptScreen(), results.append)
|
||||
await pilot.pause()
|
||||
|
||||
prompt = app.screen.query_one("#prompt-input", Input)
|
||||
prompt.value = "continue work"
|
||||
app.screen.query_one("#delay-input", Input).value = "1h30m"
|
||||
prompt.focus()
|
||||
await pilot.pause()
|
||||
if submit_action == "enter":
|
||||
await pilot.press("enter")
|
||||
else:
|
||||
app.screen.query_one("#ok-btn", Button).press()
|
||||
await pilot.pause()
|
||||
|
||||
assert results == [("continue work", timedelta(hours=1, minutes=30))]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_schedule_prompt_screen_invalid_delay_stays_open_with_error():
|
||||
from hqt.tui.screens.schedule_prompt import SchedulePromptScreen
|
||||
from textual.widgets import Button, Input, Label
|
||||
|
||||
app = HqtApp()
|
||||
async with app.run_test(size=(120, 40)) as pilot:
|
||||
results = []
|
||||
app.push_screen(SchedulePromptScreen(), results.append)
|
||||
await pilot.pause()
|
||||
|
||||
app.screen.query_one("#prompt-input", Input).value = "continue work"
|
||||
app.screen.query_one("#delay-input", Input).value = "1h 30m"
|
||||
app.screen.query_one("#ok-btn", Button).press()
|
||||
await pilot.pause()
|
||||
|
||||
assert isinstance(app.screen, SchedulePromptScreen)
|
||||
assert results == []
|
||||
error = app.screen.query_one("#schedule-error", Label)
|
||||
assert "Use a delay like" in str(error.render())
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# RenameSessionScreen: prefill + submit
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user