# tests/core/test_protocol.py
from datetime import datetime
from core.protocol import (
    Attachment, IncomingMessage, IncomingCommand, IncomingCallback,
    OutgoingMessage, OutgoingUI, OutgoingTyping, OutgoingNotification,
    UIButton, ChatContext, AuthFlow, ConfirmationRequest, SettingsAction, PaymentRequired,
)


def test_incoming_message_defaults():
    msg = IncomingMessage(user_id="u1", platform="telegram", chat_id="C1", text="hi")
    assert msg.attachments == []
    assert msg.reply_to is None


def test_attachment_audio():
    a = Attachment(type="audio", filename="voice.ogg", mime_type="audio/ogg")
    assert a.type == "audio"
    assert a.url is None


def test_incoming_command_defaults():
    cmd = IncomingCommand(user_id="u1", platform="matrix", chat_id="C1", command="new")
    assert cmd.args == []


def test_outgoing_message_defaults():
    msg = OutgoingMessage(chat_id="C1", text="hello")
    assert msg.parse_mode == "plain"
    assert msg.attachments == []


def test_ui_button_defaults():
    btn = UIButton(label="OK", action="confirm")
    assert btn.style == "secondary"
    assert btn.payload == {}


def test_settings_action():
    action = SettingsAction(action="toggle_skill", payload={"skill": "browser", "enabled": True})
    assert action.action == "toggle_skill"
    assert action.payload["skill"] == "browser"
