From 68945d931f07c541b4aca0f10aeb4488ddb24fa4 Mon Sep 17 00:00:00 2001 From: Toutsu Date: Mon, 8 Jun 2026 19:11:28 +0300 Subject: [PATCH 1/2] test: cleanup follow-up from PR #124 review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two non-blocking suggestions from the PR #124 code review: 1. Symmetric coverage for the Discord PoolSlotCapacity no-limit button. The Capacity step already had a customId-shape assertion for the '♾ Без лимита' button; PoolSlotCapacity only had a label-presence assertion. If ChoiceButtonCustomId's wire format ever diverged between the two steps, only Capacity would catch it. Convert the single Fact to a Theory with two InlineData rows so a regression in either step produces a targeted test failure. 2. Brittle hard-coded version literal in NavMenu_ShouldExposeCurrent ProjectVersion. The test had to be hand-edited on every version bump (we hit this in PR #124 — bumping 3.9.2 -> 3.9.3 broke CI). Read the version from Directory.Build.props via XDocument instead so the test only fails when the rendered NavMenu actually disagrees with the canonical version, not when someone forgot to update a literal. Tolerant of whitespace, comments and attribute order; the element is a plain string body in the MSBuild schema. No production code changes; production version is bumped in a follow-up commit. Closes #125 --- .../DiscordWizardStepCapacityRenderTests.cs | 10 ++++--- .../Web/CampaignTemplatesNavigationTests.cs | 29 ++++++++++++++++++- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/tests/GmRelay.Bot.Tests/Discord/Wizard/DiscordWizardStepCapacityRenderTests.cs b/tests/GmRelay.Bot.Tests/Discord/Wizard/DiscordWizardStepCapacityRenderTests.cs index bbdd0c2..f5fe3a5 100644 --- a/tests/GmRelay.Bot.Tests/Discord/Wizard/DiscordWizardStepCapacityRenderTests.cs +++ b/tests/GmRelay.Bot.Tests/Discord/Wizard/DiscordWizardStepCapacityRenderTests.cs @@ -33,16 +33,18 @@ public sealed class DiscordWizardStepCapacityRenderTests Assert.Contains(labels, l => l.Contains("Без лимита", System.StringComparison.Ordinal)); } - [Fact] - public void RenderCapacity_NoLimitButton_HasChoiceCustomIdForNoLimit() + [Theory] + [InlineData(WizardStepNames.Capacity, "wizard:btn:choice:Capacity:no_limit")] + [InlineData(WizardStepNames.PoolSlotCapacity, "wizard:btn:choice:PoolSlotCapacity:no_limit")] + public void Render_NoLimitButton_HasChoiceCustomIdForNoLimit(string step, string expectedCustomIdPrefix) { - var draft = new WizardDraft { Step = WizardStepNames.Capacity }; + var draft = new WizardDraft { Step = step }; var render = DiscordWizardStep.Render(draft, new WizardPayload()); var buttons = ExtractButtons(render); var noLimit = buttons.SingleOrDefault(b => b.Label?.Contains("Без лимита", System.StringComparison.Ordinal) == true); Assert.NotNull(noLimit); - Assert.StartsWith("wizard:btn:choice:Capacity:no_limit", noLimit!.CustomId); + Assert.StartsWith(expectedCustomIdPrefix, noLimit!.CustomId); } private static System.Collections.Generic.List ExtractButtonLabels( diff --git a/tests/GmRelay.Bot.Tests/Web/CampaignTemplatesNavigationTests.cs b/tests/GmRelay.Bot.Tests/Web/CampaignTemplatesNavigationTests.cs index 9018686..7581e23 100644 --- a/tests/GmRelay.Bot.Tests/Web/CampaignTemplatesNavigationTests.cs +++ b/tests/GmRelay.Bot.Tests/Web/CampaignTemplatesNavigationTests.cs @@ -14,8 +14,16 @@ public sealed class CampaignTemplatesNavigationTests [Fact] public async Task NavMenu_ShouldExposeCurrentProjectVersion() { + // Read the version from Directory.Build.props (the canonical source of + // truth) so the test doesn't need to be hand-edited on every version + // bump. Asserting the rendered NavMenu matches the canonical version + // catches real bugs (e.g. someone bumps Directory.Build.props but + // forgets to update NavMenu.razor) without false alarms from a stale + // hard-coded literal. + var propsPath = FindRepositoryFile("Directory.Build.props"); + var version = ReadVersionFromProps(propsPath); var navMenu = await File.ReadAllTextAsync(FindRepositoryFile("src/GmRelay.Web/Components/Layout/NavMenu.razor")); - Assert.Contains("v3.9.3", navMenu, StringComparison.Ordinal); + Assert.Contains($"v{version}", navMenu, StringComparison.Ordinal); } [Fact] @@ -68,4 +76,23 @@ public sealed class CampaignTemplatesNavigationTests throw new FileNotFoundException($"Could not locate repository file '{relativePath}'."); } + + /// + /// Parse the <Version>...</Version> element from + /// Directory.Build.props. Tolerant of whitespace, comments and + /// attribute shuffling — the MSBuild schema for Version is just + /// a plain element with a string body. + /// + private static string ReadVersionFromProps(string propsPath) + { + var doc = System.Xml.Linq.XDocument.Load(propsPath); + var versionElement = doc.Descendants() + .FirstOrDefault(e => e.Name.LocalName == "Version"); + Assert.NotNull(versionElement); + var version = versionElement!.Value.Trim(); + Assert.False( + string.IsNullOrEmpty(version), + $" in {propsPath} is empty"); + return version; + } } From aee0ac1e6c12a38dfc82497955542b0fe4b5025f Mon Sep 17 00:00:00 2001 From: Toutsu Date: Mon, 8 Jun 2026 19:11:31 +0300 Subject: [PATCH 2/2] chore: bump version 3.9.3 -> 3.9.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test-only patch release. Sync the four canonical version sources: - Directory.Build.props - compose.yaml (bot, discord, web image tags) - .gitea/workflows/deploy.yml (VERSION env) - src/GmRelay.Web/Components/Layout/NavMenu.razor (visible nav-version) The new NavMenu_ShouldExposeCurrentProjectVersion test reads the version from Directory.Build.props, so this bump does NOT need a hand-edited test literal — verified locally that the test passes on 3.9.4 with no manual changes. --- .gitea/workflows/deploy.yml | 2 +- Directory.Build.props | 2 +- compose.yaml | 6 +++--- src/GmRelay.Web/Components/Layout/NavMenu.razor | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 60991b7..c3cbeb0 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -6,7 +6,7 @@ on: - main env: - VERSION: 3.9.3 + VERSION: 3.9.4 jobs: # ЧАСТЬ 1: Собираем образы и кладем в Gitea (чтобы делиться с ребятами) diff --git a/Directory.Build.props b/Directory.Build.props index e5db704..3d01b11 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,6 +1,6 @@ - 3.9.3 + 3.9.4 net10.0 preview enable diff --git a/compose.yaml b/compose.yaml index c8b359d..e98ed76 100644 --- a/compose.yaml +++ b/compose.yaml @@ -49,7 +49,7 @@ services: crond -f bot: - image: git.codeanddice.ru/toutsu/gmrelay-bot:3.9.3 + image: git.codeanddice.ru/toutsu/gmrelay-bot:3.9.4 restart: always depends_on: db: @@ -67,7 +67,7 @@ services: retries: 3 discord: - image: git.codeanddice.ru/toutsu/gmrelay-discord-bot:3.9.3 + image: git.codeanddice.ru/toutsu/gmrelay-discord-bot:3.9.4 restart: always depends_on: db: @@ -86,7 +86,7 @@ services: retries: 3 web: - image: git.codeanddice.ru/toutsu/gmrelay-web:3.9.3 + image: git.codeanddice.ru/toutsu/gmrelay-web:3.9.4 restart: always depends_on: db: diff --git a/src/GmRelay.Web/Components/Layout/NavMenu.razor b/src/GmRelay.Web/Components/Layout/NavMenu.razor index 2bcfee1..bb8c9b0 100644 --- a/src/GmRelay.Web/Components/Layout/NavMenu.razor +++ b/src/GmRelay.Web/Components/Layout/NavMenu.razor @@ -82,7 +82,7 @@ - +