File size: 2,276 Bytes
fc6fc7e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
"""
Mission 28: Reference Data Tests
Tests new catalog entries: template-categories, template-platforms,
and verifies automation-node-types includes required_module field.
"""
import pytest
from httpx import AsyncClient


@pytest.mark.asyncio
async def test_catalog_template_categories(async_client: AsyncClient):
    response = await async_client.get("/api/v1/catalog/template-categories")
    assert response.status_code == 200
    data = response.json()
    assert data["success"] is True
    assert isinstance(data["data"], list)
    assert len(data["data"]) >= 3

    keys = [item["key"] for item in data["data"]]
    assert "lead_generation" in keys
    assert "customer_support" in keys
    assert "sales" in keys

    for item in data["data"]:
        assert "key" in item
        assert "label" in item

    assert "Cache-Control" in response.headers
    assert "max-age=60" in response.headers["Cache-Control"]


@pytest.mark.asyncio
async def test_catalog_template_platforms(async_client: AsyncClient):
    response = await async_client.get("/api/v1/catalog/template-platforms")
    assert response.status_code == 200
    data = response.json()
    assert data["success"] is True
    assert isinstance(data["data"], list)

    keys = [item["key"] for item in data["data"]]
    assert "whatsapp" in keys
    assert "meta" in keys

    for item in data["data"]:
        assert "key" in item
        assert "label" in item


@pytest.mark.asyncio
async def test_node_types_include_required_module(async_client: AsyncClient):
    response = await async_client.get("/api/v1/catalog/automation-node-types")
    assert response.status_code == 200
    data = response.json()
    assert data["success"] is True

    # Find the Zoho node — it should have required_module
    zoho_node = next(
        (n for n in data["data"] if n["key"] == "ZOHO_UPSERT_LEAD"), None
    )
    assert zoho_node is not None, "ZOHO_UPSERT_LEAD node type should exist"
    assert "required_module" in zoho_node
    assert zoho_node["required_module"] == "zoho_sync"

    # Other nodes should NOT have required_module set
    ai_node = next(
        (n for n in data["data"] if n["key"] == "AI_REPLY"), None
    )
    assert ai_node is not None
    assert ai_node.get("required_module") is None