feat: error banners and first-run navigation flow
This commit is contained in:
+35
-4
@@ -20,11 +20,29 @@ def client(tmp_path, monkeypatch):
|
||||
yield c
|
||||
|
||||
|
||||
def _author_bot_and_chat(db_path: Path, bot_id: str = "bot_a") -> None:
|
||||
"""Insert a bot and a chat directly via the event log (skip kickoff route)."""
|
||||
def _author_you(db_path: Path) -> None:
|
||||
"""Author a ``you_entity`` so the first-run middleware doesn't redirect."""
|
||||
from chat.db.connection import open_db
|
||||
|
||||
with open_db(db_path) as conn:
|
||||
append_event(
|
||||
conn,
|
||||
kind="you_authored",
|
||||
payload={"name": "Me", "pronouns": "", "persona": ""},
|
||||
)
|
||||
project(conn)
|
||||
|
||||
|
||||
def _author_bot_and_chat(db_path: Path, bot_id: str = "bot_a") -> None:
|
||||
"""Insert a you_entity, bot, and chat via the event log (skip kickoff route)."""
|
||||
from chat.db.connection import open_db
|
||||
|
||||
with open_db(db_path) as conn:
|
||||
append_event(
|
||||
conn,
|
||||
kind="you_authored",
|
||||
payload={"name": "Me", "pronouns": "", "persona": ""},
|
||||
)
|
||||
append_event(
|
||||
conn,
|
||||
kind="bot_authored",
|
||||
@@ -53,13 +71,26 @@ def _author_bot_and_chat(db_path: Path, bot_id: str = "bot_a") -> None:
|
||||
project(conn)
|
||||
|
||||
|
||||
def test_root_redirects_to_chats(client):
|
||||
def test_root_redirects_to_chats_when_setup_complete(client, tmp_path):
|
||||
# With both you_entity and a bot present, the first-run middleware
|
||||
# passes through and the nav router sends "/" → "/chats".
|
||||
_author_bot_and_chat(tmp_path / "test.db", "bot_a")
|
||||
response = client.get("/", follow_redirects=False)
|
||||
assert response.status_code == 303
|
||||
assert response.headers["location"] == "/chats"
|
||||
|
||||
|
||||
def test_chats_list_empty_state(client):
|
||||
def test_chats_list_empty_state(client, tmp_path):
|
||||
# Author you + a bot but NO chats — should render the empty-state
|
||||
# chats list, not redirect.
|
||||
_author_bot_and_chat(tmp_path / "test.db", "bot_a")
|
||||
# Drop the chat row so we hit the empty-state branch (the helper
|
||||
# creates a chat — undo it via a fresh seed without chat_created).
|
||||
from chat.db.connection import open_db
|
||||
|
||||
with open_db(tmp_path / "test.db") as conn:
|
||||
conn.execute("DELETE FROM chats")
|
||||
conn.commit()
|
||||
response = client.get("/chats")
|
||||
assert response.status_code == 200
|
||||
body = response.text.lower()
|
||||
|
||||
Reference in New Issue
Block a user