fix(bot): skip join-link reminders without links
PR Checks / test-and-build (pull_request) Failing after 20m55s
PR Checks / test-and-build (pull_request) Failing after 20m55s
Prevent offline sessions with empty join links from entering the 5-minute join-link notification flow, omit blank link lines from direct reminders, and add offline persistence/reminder regression coverage.
This commit is contained in:
@@ -2,6 +2,7 @@ using GmRelay.Bot.Infrastructure.Telegram;
|
||||
using GmRelay.Shared.Platform;
|
||||
using GmRelay.Shared.Rendering;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
using System.Reflection;
|
||||
|
||||
namespace GmRelay.Bot.Tests.Infrastructure.Telegram;
|
||||
|
||||
@@ -36,9 +37,35 @@ public sealed class TelegramPlatformMessengerTests
|
||||
Assert.Contains("Existing schedule message reference must match the schedule group.", exception.Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BuildDirectNotificationText_OneHourReminderWithoutJoinLink_ShouldNotRenderBlankLinkLine()
|
||||
{
|
||||
var notification = new PlatformDirectSessionNotification(
|
||||
PlatformDirectSessionNotificationKind.OneHourReminder,
|
||||
new PlatformUser(PlatformKind.Telegram, "123", "Player", "player"),
|
||||
Guid.NewGuid(),
|
||||
"Offline Game",
|
||||
DateTime.UtcNow,
|
||||
JoinLink: string.Empty);
|
||||
|
||||
var text = InvokeBuildDirectNotificationText(notification);
|
||||
|
||||
Assert.DoesNotContain("🔗", text);
|
||||
}
|
||||
|
||||
private static TelegramPlatformMessenger CreateMessenger() =>
|
||||
new(null!, NullLogger<TelegramPlatformMessenger>.Instance);
|
||||
|
||||
private static string InvokeBuildDirectNotificationText(PlatformDirectSessionNotification notification)
|
||||
{
|
||||
var method = typeof(TelegramPlatformMessenger).GetMethod(
|
||||
"BuildDirectNotificationText",
|
||||
BindingFlags.NonPublic | BindingFlags.Static);
|
||||
|
||||
Assert.NotNull(method);
|
||||
return Assert.IsType<string>(method.Invoke(null, new object[] { notification }));
|
||||
}
|
||||
|
||||
private static SessionBatchViewModel CreateView() =>
|
||||
new("Test batch", []);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user