Fix Discord co-GM management
Deploy Telegram Bot / build-and-push (push) Successful in 5m58s
Deploy Telegram Bot / scan-images (push) Successful in 3m39s
Deploy Telegram Bot / deploy (push) Successful in 34s

This commit is contained in:
2026-05-27 16:32:47 +03:00
parent 7a2965b43f
commit fac5d75c7e
5 changed files with 129 additions and 24 deletions
@@ -115,6 +115,18 @@ public sealed class DiscordNewSessionHandlerTests
Assert.Contains("UnauthorizedAccessException", source, StringComparison.Ordinal);
}
[Fact]
public void Handler_ShouldLoadCoGmPermissionsFromDiscordPlayers()
{
var repoRoot = GetRepoRoot();
var handlerPath = Path.Combine(repoRoot, "src", "GmRelay.DiscordBot", "Features", "Sessions", "DiscordNewSessionHandler.cs");
var source = File.ReadAllText(handlerPath);
Assert.Matches(
@"QueryAsync<ulong>[\s\S]*JOIN players p ON p\.id = gm\.player_id[\s\S]*p\.platform = 'Discord'[\s\S]*g\.external_group_id = @GuildId",
source);
}
[Fact]
public void Handler_ShouldBePlatformNeutral()
{
@@ -0,0 +1,35 @@
namespace GmRelay.Bot.Tests.Web;
public sealed class GroupDetailsSourceTests
{
[Fact]
public async Task GroupDetails_ShouldManageCoGmUsingGroupPlatform()
{
var source = await ReadRepositoryFileAsync("src/GmRelay.Web/Components/Pages/GroupDetails.razor");
Assert.Contains("CoGmPlatform", source, StringComparison.Ordinal);
Assert.Contains("@CoGmIdLabel", source, StringComparison.Ordinal);
Assert.Contains("coGmModel.ExternalUserId", source, StringComparison.Ordinal);
Assert.Matches(@"SessionService\.AddCoGmForOwnerAsync\(\s*GroupId,\s*CoGmPlatform,\s*coGmExternalUserId", source);
Assert.Matches(@"SessionService\.RemoveCoGmForOwnerAsync\(GroupId,\s*platform,\s*coGmExternalUserId\)", source);
Assert.DoesNotContain("Telegram ID co-GM", source, StringComparison.Ordinal);
Assert.DoesNotContain("SessionService.RemoveCoGmForOwnerAsync(GroupId, \"Telegram\"", source, StringComparison.Ordinal);
}
private static async Task<string> ReadRepositoryFileAsync(string relativePath)
{
var directory = new DirectoryInfo(AppContext.BaseDirectory);
while (directory is not null)
{
var candidate = Path.Combine(directory.FullName, relativePath);
if (File.Exists(candidate))
{
return await File.ReadAllTextAsync(candidate);
}
directory = directory.Parent;
}
throw new FileNotFoundException($"Could not locate repository file '{relativePath}'.");
}
}