using GmRelay.Bot.Features.Sessions.ListSessions;
using GmRelay.Shared.Domain;
using GmRelay.Shared.Features.Sessions.ListSessions;

namespace GmRelay.Bot.Tests.Features.Sessions.ListSessions;

public sealed class SessionListMessageRendererTests
{
    [Fact]
    public void Render_ShouldIncludeManagerActions_WhenUserCanManage()
    {
        var sessionId = Guid.NewGuid();
        var sessions = new[]
        {
            new SessionListItemDto(
                sessionId,
                "Ravenloft",
                new DateTime(2026, 5, 7, 16, 30, 0, DateTimeKind.Utc),
                SessionStatus.Planned,
                4,
                3,
                1,
                true)
        };

        var text = SessionListMessageRenderer.RenderText(sessions);
        var actions = SessionListMessageRenderer.RenderActions(sessions);

        Assert.Contains("Ravenloft", text);
        Assert.Equal(4, actions.Count);
        Assert.Contains(actions, a => a.Payload == $"cancel_session:{sessionId}");
        Assert.Contains(actions, a => a.Payload == $"reschedule_session:{sessionId}");
        Assert.Contains(actions, a => a.Payload == $"promote_waitlist:{sessionId}");
        Assert.Contains(actions, a => a.Payload == $"delete_session:{sessionId}");
    }

    [Fact]
    public void Render_ShouldHideManagerActions_WhenUserCannotManage()
    {
        var sessions = new[]
        {
            new SessionListItemDto(
                Guid.NewGuid(),
                "Ravenloft",
                new DateTime(2026, 5, 7, 16, 30, 0, DateTimeKind.Utc),
                SessionStatus.Planned,
                4,
                3,
                1,
                false)
        };

        var actions = SessionListMessageRenderer.RenderActions(sessions);
        Assert.Empty(actions);
    }
}
