"""
STORY-005: 整合日誌分析到工作流程

Tests for log analysis workflow integration.
"""


class TestStory005WorkflowIntegration:
    """
    STORY-005: 整合日誌分析到工作流程

    As a 系統整合者
    I want to 將 log_node 整合到 LangGraph 工作流程
    So that 使用者執行命令時能正確路由到日誌分析功能
    """

    # AC-01: 在 nodes/__init__.py 中 export log_node
    def test_log_node_exported(self):
        """
        測試 log_node 可從 nodes 模組 import

        Given: nodes/__init__.py 已更新
        When: 從 nodes 模組 import
        Then: 應該成功 import log_node
        """
        from src.fwauto.nodes import log_node

        assert callable(log_node), "log_node should be exported"

    # AC-03 & AC-04: graph.py 註冊與邊緣設定
    def test_workflow_graph_includes_log_analysis(self):
        """
        測試 workflow graph 包含 log_analysis node

        Given: create_firmware_graph 已更新
        When: 建立 workflow graph
        Then: graph 應該包含 log_analysis node
        """
        from src.fwauto.graph import create_firmware_graph

        app = create_firmware_graph()
        nodes = app.get_graph().nodes

        # Check if log_analysis node exists
        assert any("log" in str(node) for node in nodes), "Workflow graph should include log_analysis node"
