|
|
@@ -46,6 +46,31 @@ class TestMaintenanceTypesAPI:
|
|
|
assert result["name"] == "Custom Test Task"
|
|
|
assert result["is_system"] is False
|
|
|
|
|
|
+ @pytest.mark.asyncio
|
|
|
+ @pytest.mark.integration
|
|
|
+ async def test_create_custom_type_persists_wiki_url(self, async_client: AsyncClient):
|
|
|
+ """#1596: pre-fix, the POST handler hard-coded every constructor field
|
|
|
+ by name and silently dropped `wiki_url`. The schema accepted the value,
|
|
|
+ the response echoed `null`, and the row landed without it. Pin the
|
|
|
+ contract so the constructor doesn't drift again."""
|
|
|
+ data = {
|
|
|
+ "name": "Wiki URL Persistence Test",
|
|
|
+ "default_interval_hours": 50.0,
|
|
|
+ "interval_type": "hours",
|
|
|
+ "wiki_url": "https://wiki.example.com/lubrication",
|
|
|
+ }
|
|
|
+ response = await async_client.post("/api/v1/maintenance/types", json=data)
|
|
|
+ assert response.status_code == 200
|
|
|
+ assert response.json()["wiki_url"] == "https://wiki.example.com/lubrication"
|
|
|
+
|
|
|
+ # Verify it persists through a separate GET round-trip — the POST
|
|
|
+ # response could have echoed the request body without committing.
|
|
|
+ list_response = await async_client.get("/api/v1/maintenance/types")
|
|
|
+ assert list_response.status_code == 200
|
|
|
+ matching = [t for t in list_response.json() if t["name"] == data["name"]]
|
|
|
+ assert len(matching) == 1
|
|
|
+ assert matching[0]["wiki_url"] == "https://wiki.example.com/lubrication"
|
|
|
+
|
|
|
@pytest.mark.asyncio
|
|
|
@pytest.mark.integration
|
|
|
async def test_update_maintenance_type(self, async_client: AsyncClient):
|