Restore CheckDefaultTranslationsUpToDate
What changed, and why it matters
This commit restores a test that checks whether the project's default translation file is up to date before a release. It does not change production code, fix a bug, or alter security behavior. It is purely a quality-assurance test for translation data.
No security action needed. Treat as normal test/CI maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff adds a new xUnit test, CheckDefaultTranslationsUpToDate, in BTCPayServer.Tests/UtilitiesTests.cs. The test runs UpdateDefaultTranslations(), compares the resulting Translations.Default.cs content with the committed version, and fails if they differ. It also includes cleanup to restore the original file content. The change is test-only and has no effect on runtime code paths, authentication, authorization, cryptography, or network handling.
Changed components
BTCPayServer.Tests/UtilitiesTests.csInspect captured patch +33 / −5
diff --git a/BTCPayServer.Tests/UtilitiesTests.cs b/BTCPayServer.Tests/UtilitiesTests.cs
index f3e9e4d..821a161 100644
--- a/BTCPayServer.Tests/UtilitiesTests.cs
+++ b/BTCPayServer.Tests/UtilitiesTests.cs
@@ -211,13 +211,13 @@ namespace BTCPayServer.Tests
var response = await httpClient.GetAsync("https://api.github.com/repos/btcpayserver/btcpayserver-translator/contents/translations");
response.EnsureSuccessStatusCode();
var files = JArray.Parse(await response.Content.ReadAsStringAsync());
-
+
var availableLanguages = files
.Where(f => f["name"].Value<string>().EndsWith(".json"))
.Select(f => System.Globalization.CultureInfo.InvariantCulture.TextInfo.ToTitleCase(f["name"].Value<string>().Replace(".json", "")))
.OrderBy(l => l)
.ToList();
-
+
var soldir = TestUtils.TryGetSolutionDirectoryInfo();
var cshtmlContent = File.ReadAllText(Path.Combine(soldir.FullName, "BTCPayServer/Views/UIServer/ListDictionaries.cshtml"));
var hardcodedLanguages = Regex.Matches(cshtmlContent, @"<option value=""([^""]+)"">")
@@ -226,11 +226,11 @@ namespace BTCPayServer.Tests
.Where(v => v != "")
.OrderBy(l => l)
.ToList();
-
+
var missingLanguages = availableLanguages.Except(hardcodedLanguages).ToList();
var extraLanguages = hardcodedLanguages.Except(availableLanguages).ToList();
-
- Assert.True(!missingLanguages.Any() && !extraLanguages.Any(),
+
+ Assert.True(!missingLanguages.Any() && !extraLanguages.Any(),
$"Language packs list is out of date.\n" +
(missingLanguages.Any() ? $"Missing: {string.Join(", ", missingLanguages)}\n" : "") +
(extraLanguages.Any() ? $"Extra: {string.Join(", ", extraLanguages)}\n" : "") +
@@ -359,6 +359,34 @@ namespace BTCPayServer.Tests
}
}
+
+ /// <summary>
+ /// Pre-release check to ensure UpdateDefaultTranslations has been run
+ /// </summary>
+ [Trait("PreReleaseCheck", "PreReleaseCheck")]
+ [Fact]
+ public async Task CheckDefaultTranslationsUpToDate()
+ {
+ var soldir = TestUtils.TryGetSolutionDirectoryInfo();
+ var path = Path.Combine(soldir.FullName, "BTCPayServer/Services/Translations.Default.cs");
+ var originalContent = await File.ReadAllTextAsync(path);
+
+ try
+ {
+ await UpdateDefaultTranslations();
+
+ // Check if file was modified
+ var newContent = await File.ReadAllTextAsync(path);
+ Assert.True(originalContent == newContent,
+ "Default translations are out of date. Please run the UpdateDefaultTranslations test before building docker images.\n" +
+ "You can run it with: dotnet test --filter \"FullyQualifiedName~UpdateDefaultTranslations\"");
+ }
+ finally
+ {
+ await File.WriteAllTextAsync(path, originalContent);
+ }
+ }
+
/// <summary>
/// This utility will make sure that permission documentation is properly written in swagger.template.json
/// </summary>
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.