feat: save next_steps on session completion and update

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Michael Chihlas
2026-02-13 08:42:19 -05:00
parent ec5c91c8e4
commit ae701ef066
2 changed files with 49 additions and 0 deletions

View File

@@ -236,6 +236,7 @@ async def complete_session(
session.completed_at = datetime.now(timezone.utc)
session.outcome = completion_data.outcome
session.outcome_notes = completion_data.outcome_notes
session.next_steps = completion_data.next_steps
await db.commit()
await db.refresh(session)
return session

View File

@@ -1010,3 +1010,51 @@ class TestSessions:
data = response.json()
assert isinstance(data, list)
assert len(data) == 0
@pytest.mark.asyncio
async def test_complete_session_with_next_steps(
self, client: AsyncClient, auth_headers: dict, test_tree: dict
):
"""Test completing session saves next_steps."""
create_response = await client.post(
"/api/v1/sessions",
json={"tree_id": test_tree["id"]},
headers=auth_headers
)
session_id = create_response.json()["id"]
response = await client.post(
f"/api/v1/sessions/{session_id}/complete",
json={
"outcome": "resolved",
"outcome_notes": "Fixed the issue",
"next_steps": "Monitor for 48 hours"
},
headers=auth_headers
)
assert response.status_code == 200
data = response.json()
assert data["next_steps"] == "Monitor for 48 hours"
assert data["outcome_notes"] == "Fixed the issue"
@pytest.mark.asyncio
async def test_update_session_next_steps(
self, client: AsyncClient, auth_headers: dict, test_tree: dict
):
"""Test updating next_steps via session update."""
create_response = await client.post(
"/api/v1/sessions",
json={"tree_id": test_tree["id"]},
headers=auth_headers
)
session_id = create_response.json()["id"]
response = await client.put(
f"/api/v1/sessions/{session_id}",
json={"next_steps": "Schedule follow-up call"},
headers=auth_headers
)
assert response.status_code == 200
assert response.json()["next_steps"] == "Schedule follow-up call"