fix(discord): update sessions via interactions
This commit is contained in:
@@ -47,6 +47,17 @@ public sealed class DiscordListSessionsHandlerTests
|
||||
Assert.DoesNotContain("telegram_id", handler, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Handler_ShouldExposeDeleteActionForManagers()
|
||||
{
|
||||
var repoRoot = GetRepoRoot();
|
||||
var handlerPath = Path.Combine(repoRoot, "src", "GmRelay.DiscordBot", "Features", "Sessions", "DiscordListSessionsHandler.cs");
|
||||
var handler = File.ReadAllText(handlerPath);
|
||||
|
||||
Assert.Contains("delete_session", handler, StringComparison.Ordinal);
|
||||
Assert.Contains("CanManageSchedule", handler, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Command_ShouldExist()
|
||||
{
|
||||
@@ -66,4 +77,18 @@ public sealed class DiscordListSessionsHandlerTests
|
||||
Assert.Contains("SlashCommand", command, StringComparison.Ordinal);
|
||||
Assert.Contains("listsessions", command, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DeleteHandler_ShouldDeleteOnlySessionsFromTheInteractionGuild()
|
||||
{
|
||||
var repoRoot = GetRepoRoot();
|
||||
var handlerPath = Path.Combine(repoRoot, "src", "GmRelay.DiscordBot", "Features", "Sessions", "DiscordDeleteSessionHandler.cs");
|
||||
|
||||
Assert.True(File.Exists(handlerPath), "DiscordDeleteSessionHandler should exist.");
|
||||
|
||||
var handler = File.ReadAllText(handlerPath);
|
||||
Assert.Contains("DELETE FROM sessions", handler, StringComparison.Ordinal);
|
||||
Assert.Contains("external_group_id = @GuildId", handler, StringComparison.Ordinal);
|
||||
Assert.Contains("CanManageSchedule", handler, StringComparison.Ordinal);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,26 @@ public sealed class DiscordSessionInteractionModuleSourceTests
|
||||
Assert.Contains("MessageFlags.Ephemeral", source, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Module_ShouldUpdateSourceScheduleMessageThroughComponentInteraction()
|
||||
{
|
||||
var source = await ReadRepositoryFileAsync("src/GmRelay.DiscordBot/Features/Sessions/DiscordSessionInteractionModule.cs");
|
||||
|
||||
Assert.Contains("InteractionCallback.DeferredModifyMessage", source, StringComparison.Ordinal);
|
||||
Assert.Contains("DiscordSessionBatchRenderer.Render", source, StringComparison.Ordinal);
|
||||
Assert.Contains("FollowupAsync", source, StringComparison.Ordinal);
|
||||
Assert.Contains("CompleteScheduleUpdateResponseAsync", source, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Module_ShouldRouteDeleteSessionButtons()
|
||||
{
|
||||
var source = await ReadRepositoryFileAsync("src/GmRelay.DiscordBot/Features/Sessions/DiscordSessionInteractionModule.cs");
|
||||
|
||||
Assert.Contains("[ComponentInteraction(\"delete_session\")]", source, StringComparison.Ordinal);
|
||||
Assert.Contains("DiscordDeleteSessionHandler", source, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Module_ShouldRouteRsvpButtonsToNeutralHandler()
|
||||
{
|
||||
|
||||
+19
-1
@@ -13,6 +13,7 @@ public sealed class PlatformNeutralSessionInteractionCommandTests
|
||||
AssertProperty<JoinSessionCommand>("InteractionId", typeof(string));
|
||||
AssertProperty<JoinSessionCommand>("Group", typeof(PlatformGroup));
|
||||
AssertProperty<JoinSessionCommand>("ScheduleMessage", typeof(PlatformMessageRef));
|
||||
AssertProperty<JoinSessionCommand>("DeferScheduleUpdate", typeof(bool));
|
||||
AssertNoTelegramSpecificProperties<JoinSessionCommand>();
|
||||
}
|
||||
|
||||
@@ -24,12 +25,29 @@ public sealed class PlatformNeutralSessionInteractionCommandTests
|
||||
AssertProperty<LeaveSessionCommand>("InteractionId", typeof(string));
|
||||
AssertProperty<LeaveSessionCommand>("Group", typeof(PlatformGroup));
|
||||
AssertProperty<LeaveSessionCommand>("ScheduleMessage", typeof(PlatformMessageRef));
|
||||
AssertProperty<LeaveSessionCommand>("DeferScheduleUpdate", typeof(bool));
|
||||
AssertNoTelegramSpecificProperties<LeaveSessionCommand>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SessionInteractionResult_ShouldExposeReplyTextAndUpdatedView()
|
||||
{
|
||||
var resultType = typeof(JoinSessionCommand).Assembly.GetType(
|
||||
"GmRelay.Shared.Features.Sessions.CreateSession.SessionInteractionResult");
|
||||
|
||||
Assert.NotNull(resultType);
|
||||
AssertProperty(resultType, "ReplyText", typeof(string));
|
||||
AssertProperty(resultType, "UpdatedView", typeof(GmRelay.Shared.Rendering.SessionBatchViewModel));
|
||||
}
|
||||
|
||||
private static void AssertProperty<T>(string name, Type expectedType)
|
||||
{
|
||||
var property = Assert.Single(typeof(T).GetProperties(), property => property.Name == name);
|
||||
AssertProperty(typeof(T), name, expectedType);
|
||||
}
|
||||
|
||||
private static void AssertProperty(Type type, string name, Type expectedType)
|
||||
{
|
||||
var property = Assert.Single(type.GetProperties(), property => property.Name == name);
|
||||
|
||||
Assert.Equal(expectedType, property.PropertyType);
|
||||
}
|
||||
|
||||
@@ -91,6 +91,15 @@ public sealed class PlatformIdentityMigrationTests
|
||||
Assert.Contains("platform", service, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WebSessionService_ShouldAuthorizeGroupsAcrossLinkedIdentities()
|
||||
{
|
||||
var service = await ReadRepositoryFileAsync("src/GmRelay.Web/Services/SessionService.cs");
|
||||
|
||||
Assert.Contains("_ResolveLinkedPlayerIdsAsync", service, StringComparison.Ordinal);
|
||||
Assert.Contains("player_id = ANY(@PlayerIds)", service, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task AttendanceStatsFunction_ShouldReferenceExternalUsername()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user