feat: improve telegram session posts
This commit is contained in:
+38
@@ -1,4 +1,5 @@
|
||||
using GmRelay.Bot.Features.Sessions.CreateSession;
|
||||
using Telegram.Bot.Types;
|
||||
|
||||
namespace GmRelay.Bot.Tests.Features.Sessions.CreateSession;
|
||||
|
||||
@@ -33,6 +34,43 @@ public sealed class NewSessionCommandParserTests
|
||||
Assert.Empty(result.InvalidTimeInputs);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Parse_ShouldExtractOptionalImageUrl()
|
||||
{
|
||||
var nowUtc = new DateTimeOffset(2026, 4, 23, 12, 0, 0, TimeSpan.Zero);
|
||||
var text = """
|
||||
/newsession
|
||||
Название: Curse of Strahd
|
||||
Время: 24.04.2026 19:30
|
||||
Ссылка: https://example.test/room
|
||||
Картинка: https://example.test/strahd.jpg
|
||||
""";
|
||||
|
||||
var result = NewSessionCommandParser.Parse(text, nowUtc);
|
||||
|
||||
Assert.True(result.IsValid);
|
||||
Assert.Equal("https://example.test/strahd.jpg", result.ImageUrl);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetBatchImageReference_ShouldPreferAttachedPhotoOverParsedUrl()
|
||||
{
|
||||
var message = new Message
|
||||
{
|
||||
Photo =
|
||||
[
|
||||
new PhotoSize { FileId = "small-photo", Width = 320, Height = 180, FileSize = 10 },
|
||||
new PhotoSize { FileId = "large-photo", Width = 1280, Height = 720, FileSize = 20 }
|
||||
]
|
||||
};
|
||||
|
||||
var imageReference = CreateSessionHandler.GetBatchImageReference(
|
||||
message,
|
||||
"https://example.test/cover.jpg");
|
||||
|
||||
Assert.Equal("large-photo", imageReference);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Parse_ShouldExpandRecurringSchedule_WhenRepeatCountAndIntervalProvided()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user