from core.entities.execution_extra_content import (
    ExecutionExtraContentDomainModel,
    HumanInputContent,
    HumanInputFormDefinition,
    HumanInputFormSubmissionData,
)
from core.workflow.nodes.human_input.entities import ParagraphInputConfig, UserActionConfig
from models.execution_extra_content import ExecutionContentType


def test_human_input_content_defaults_and_domain_alias() -> None:
    # Arrange
    form_definition = HumanInputFormDefinition(
        form_id="form-1",
        node_id="node-1",
        node_title="Human Input",
        form_content="Please confirm",
        inputs=[ParagraphInputConfig(output_variable_name="answer")],
        actions=[UserActionConfig(id="confirm", title="Confirm")],
        resolved_default_values={"answer": "yes"},
        expiration_time=1_700_000_000,
    )
    submission_data = HumanInputFormSubmissionData(
        node_id="node-1",
        node_title="Human Input",
        rendered_content="Please confirm",
        action_id="confirm",
        action_text="Confirm",
        submitted_data={"answer": "yes"},
    )

    # Act
    content = HumanInputContent(
        workflow_run_id="workflow-run-1",
        submitted=True,
        form_definition=form_definition,
        form_submission_data=submission_data,
    )

    # Assert
    assert form_definition.model_config.get("frozen") is True
    assert content.type == ExecutionContentType.HUMAN_INPUT
    assert content.form_definition is form_definition
    assert content.form_submission_data is submission_data
    assert content.form_submission_data.submitted_data == {"answer": "yes"}
    assert ExecutionExtraContentDomainModel is HumanInputContent
