f796b7d1e4
Production regression in 3.9.0: Telegram bot silently dropped every update. WizardDraftRepository.GetActiveAsync was called on every Telegram update (via UpdateRouter -> TryGetWizardContext) and threw System.PlatformNotSupportedException in NativeAOT, because Dapper.AOT 1.0.48 only generates interceptors for the (sql, object?) extension overloads and NOT for the (CommandDefinition) overload. The runtime then fell back to Dapper.SqlMapper.CreateParamInfoGenerator, which uses Reflection.Emit and fails on AOT. TelegramBotService swallowed the exception, so /newsession appeared to start but no button press reached the wizard and no session was created. Two related changes in WizardDraft: 1. Switched WizardDraftRepository.* from 'new CommandDefinition(sql, params, cancellationToken: ct)' to the direct 'connection.Query*(sql, params)' overload, matching the working pattern in JoinSessionHandler. Dapper.AOT now generates CommandFactory30<WizardDraft> + RowFactory17<WizardDraft> + QuerySingleOrDefaultAsync37<WizardDraft> for all four methods. 2. WizardDraft.CreatedAt/UpdatedAt/ExpiresAt are now DateTime (UTC) instead of DateTimeOffset. AOT RowFactory calls reader.GetDateTime() directly and does not perform DateTime -> DateTimeOffset conversion; the previous type raised InvalidCastException on the very first wizard_drafts query. All 588/590 tests pass (2 pre-existing skipped, +5 new AOT regression tests in WizardDraftRepositoryAotShapeTests). dotnet format clean. Bumps: 3.9.0 -> 3.9.1. Note: GetOwnerClubsAsync (Telegram/Discord), DiscordPermissionLookup, and DiscordWizardInteractionModule.GetOwnerClubsAsync still use CommandDefinition and will hit the same Reflection.Emit AOT failure when the user reaches the PickClub visibility step. Follow-up in 3.9.2.
72 lines
2.8 KiB
C#
72 lines
2.8 KiB
C#
namespace GmRelay.Bot.Tests.Web;
|
|
|
|
public sealed class CampaignTemplatesNavigationTests
|
|
{
|
|
[Fact]
|
|
public async Task NavMenu_ShouldExposeTemplatesTab()
|
|
{
|
|
var navMenu = await File.ReadAllTextAsync(FindRepositoryFile("src/GmRelay.Web/Components/Layout/NavMenu.razor"));
|
|
|
|
Assert.Contains("href=\"templates\"", navMenu, StringComparison.Ordinal);
|
|
Assert.Contains("Шаблоны", navMenu, StringComparison.Ordinal);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task NavMenu_ShouldExposeCurrentProjectVersion()
|
|
{
|
|
var navMenu = await File.ReadAllTextAsync(FindRepositoryFile("src/GmRelay.Web/Components/Layout/NavMenu.razor"));
|
|
Assert.Contains("v3.9.1", navMenu, StringComparison.Ordinal);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task NavMenuStyles_ShouldStyleNavLinkAnchorsAsStackedRows()
|
|
{
|
|
var navCss = await File.ReadAllTextAsync(FindRepositoryFile("src/GmRelay.Web/Components/Layout/NavMenu.razor.css"));
|
|
|
|
Assert.Contains("::deep .nav-item", navCss, StringComparison.Ordinal);
|
|
Assert.Matches(
|
|
@"\.nav-section\s*\{[^}]*display:\s*flex;[^}]*flex-direction:\s*column;[^}]*gap:\s*0\.25rem;",
|
|
navCss);
|
|
Assert.Matches(
|
|
@"::deep\s+\.nav-item\s*\{[^}]*display:\s*flex;[^}]*width:\s*100%;",
|
|
navCss);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task GroupDetails_ShouldApplyTemplatesWithoutManagingThem()
|
|
{
|
|
var groupDetails = await File.ReadAllTextAsync(FindRepositoryFile("src/GmRelay.Web/Components/Pages/GroupDetails.razor"));
|
|
|
|
Assert.Contains("CreateBatchFromTemplate", groupDetails, StringComparison.Ordinal);
|
|
Assert.DoesNotContain("OnValidSubmit=\"CreateCampaignTemplate\"", groupDetails, StringComparison.Ordinal);
|
|
Assert.DoesNotContain("DeleteCampaignTemplate", groupDetails, StringComparison.Ordinal);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task CampaignTemplatesPage_ShouldOwnTemplateManagement()
|
|
{
|
|
var templatesPage = await File.ReadAllTextAsync(FindRepositoryFile("src/GmRelay.Web/Components/Pages/CampaignTemplates.razor"));
|
|
|
|
Assert.Contains("@page \"/templates\"", templatesPage, StringComparison.Ordinal);
|
|
Assert.Contains("OnValidSubmit=\"CreateCampaignTemplate\"", templatesPage, StringComparison.Ordinal);
|
|
Assert.Contains("DeleteCampaignTemplate", templatesPage, StringComparison.Ordinal);
|
|
}
|
|
|
|
private static string FindRepositoryFile(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 candidate;
|
|
}
|
|
|
|
directory = directory.Parent;
|
|
}
|
|
|
|
throw new FileNotFoundException($"Could not locate repository file '{relativePath}'.");
|
|
}
|
|
}
|