What changed, and why it matters
This commit fixes a flaky automated test for the global search feature. The JavaScript change makes the search run automatically if a query is already present when the search UI opens, and the test code is simplified to remove a special screenshot-on-failure workaround. There is no security issue here.
No security action needed. This is a routine test reliability fix.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change addresses a timing issue in Playwright tests for BTCPay Server’s global search plugin. In global-search.js, after synchronizing the search action state, the code now checks whether the search input already contains a non-empty value and, if so, immediately calls runSearch(). This ensures the results panel becomes visible without relying on an additional input event. The test helper GlobalSearchPMO.cs removes a try/catch block that took a screenshot when waiting for results failed, because the race condition causing the flakiness is now fixed. No security-sensitive code paths are modified.
Changed components
BTCPayServer.Tests/PMO/GlobalSearchPMO.csBTCPayServer/wwwroot/plugins/GlobalSearch/global-search.jsInspect captured patch +3 / −9
diff --git a/BTCPayServer.Tests/PMO/GlobalSearchPMO.cs b/BTCPayServer.Tests/PMO/GlobalSearchPMO.cs
index a4aebc1..4de5278 100644
--- a/BTCPayServer.Tests/PMO/GlobalSearchPMO.cs
+++ b/BTCPayServer.Tests/PMO/GlobalSearchPMO.cs
@@ -22,15 +22,7 @@ public class GlobalSearchPMO(PlaywrightTester tester)
{
await Page.Keyboard.PressAsync("/");
await Page.Locator("#globalSearchInput").FillAsync(query);
- try
- {
- await Page.Locator("#globalSearchResults:not([hidden])").WaitForAsync();
- }
- catch
- {
- await tester.TakeScreenshot("Flaky-GlobalSearch.png");
- throw;
- }
+ await Page.Locator("#globalSearchResults:not([hidden])").WaitForAsync();
}
public Task Enter() => Page.Keyboard.PressAsync("Enter");
diff --git a/BTCPayServer/wwwroot/plugins/GlobalSearch/global-search.js b/BTCPayServer/wwwroot/plugins/GlobalSearch/global-search.js
index 01afe14..9febf43 100644
--- a/BTCPayServer/wwwroot/plugins/GlobalSearch/global-search.js
+++ b/BTCPayServer/wwwroot/plugins/GlobalSearch/global-search.js
@@ -459,6 +459,8 @@
});
syncSearchActionState();
+ if (!!input.value.trim())
+ runSearch();
};
const isEditableElement = element => {
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.