fix: stabilize maintenance flow run/resume and procedural scrolling

This commit is contained in:
chihlasm
2026-02-17 20:12:07 -05:00
parent 058e2c5a23
commit db715929e7
10 changed files with 151 additions and 13 deletions

View File

@@ -98,6 +98,23 @@ async def test_get_schedule_not_found(client: AsyncClient, auth_headers: dict):
assert resp.status_code == 404
@pytest.mark.asyncio
async def test_cannot_create_schedule_for_non_maintenance_tree(
client: AsyncClient, auth_headers: dict, test_tree: dict
):
"""Schedules are restricted to maintenance flows."""
resp = await client.post(
"/api/v1/maintenance-schedules",
json={
"tree_id": test_tree["id"],
"cron_expression": "0 0 1 * *",
"timezone": "UTC",
},
headers=auth_headers,
)
assert resp.status_code == 400
@pytest.mark.asyncio
async def test_cannot_schedule_other_teams_tree(client: AsyncClient, auth_headers: dict, test_db):
"""User cannot create a schedule for a tree belonging to another team."""

View File

@@ -882,6 +882,79 @@ class TestSessions:
assert len(data) >= 1
assert test_tree["name"] in data[0]["tree_snapshot"]["name"]
@pytest.mark.asyncio
async def test_filter_sessions_by_tree_id(
self, client: AsyncClient, auth_headers: dict, test_tree: dict
):
"""Test filtering sessions by tree_id."""
other_tree_response = await client.post(
"/api/v1/trees",
json={
"name": "Other Tree",
"description": "Second tree for filter test",
"category": test_tree["category"],
"tree_structure": test_tree["tree_structure"],
},
headers=auth_headers,
)
assert other_tree_response.status_code == 201
other_tree_id = other_tree_response.json()["id"]
await client.post(
"/api/v1/sessions",
json={"tree_id": test_tree["id"], "ticket_number": "TREE-A"},
headers=auth_headers,
)
await client.post(
"/api/v1/sessions",
json={"tree_id": other_tree_id, "ticket_number": "TREE-B"},
headers=auth_headers,
)
response = await client.get(
f"/api/v1/sessions?tree_id={test_tree['id']}",
headers=auth_headers,
)
assert response.status_code == 200
data = response.json()
assert len(data) >= 1
assert all(item["tree_id"] == test_tree["id"] for item in data)
@pytest.mark.asyncio
async def test_list_sessions_supports_size_and_page_params(
self, client: AsyncClient, auth_headers: dict, test_tree: dict
):
"""Test frontend-compatible page/size query params."""
await client.post(
"/api/v1/sessions",
json={"tree_id": test_tree["id"], "ticket_number": "P1"},
headers=auth_headers,
)
await client.post(
"/api/v1/sessions",
json={"tree_id": test_tree["id"], "ticket_number": "P2"},
headers=auth_headers,
)
await client.post(
"/api/v1/sessions",
json={"tree_id": test_tree["id"], "ticket_number": "P3"},
headers=auth_headers,
)
first_page = await client.get("/api/v1/sessions?size=2&page=1", headers=auth_headers)
assert first_page.status_code == 200
first_data = first_page.json()
assert len(first_data) == 2
second_page = await client.get("/api/v1/sessions?size=2&page=2", headers=auth_headers)
assert second_page.status_code == 200
second_data = second_page.json()
assert len(second_data) >= 1
first_ids = {item["id"] for item in first_data}
second_ids = {item["id"] for item in second_data}
assert first_ids.isdisjoint(second_ids)
@pytest.mark.asyncio
async def test_filter_sessions_by_started_date_range(
self, client: AsyncClient, auth_headers: dict, test_tree: dict