e0ee8fc962
The /listsessions buttons for owners/co-GMs only showed emoji + date, so it was unclear what each button did. Add explicit verb labels: - ❌ Отменить <date> - ⏰ Перенести <date> - ⬆️ С ожидания <date> - 🗑 Удалить <date> Update the renderer test to assert the new labels.
63 lines
2.2 KiB
C#
63 lines
2.2 KiB
C#
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}");
|
||
|
||
var shortDate = new DateTime(2026, 5, 7, 16, 30, 0, DateTimeKind.Utc).FormatMoscowShort();
|
||
Assert.Contains(actions, a => a.Label == $"❌ Отменить {shortDate}");
|
||
Assert.Contains(actions, a => a.Label == $"⏰ Перенести {shortDate}");
|
||
Assert.Contains(actions, a => a.Label == $"⬆️ С ожидания {shortDate}");
|
||
Assert.Contains(actions, a => a.Label == $"🗑 Удалить {shortDate}");
|
||
}
|
||
|
||
[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);
|
||
}
|
||
}
|