using System; using System.Threading.Tasks; using Microsoft.Playwright; using static Microsoft.Playwright.Assertions; namespace BTCPayServer.Tests.PMO; public class GlobalSearchPMO(PlaywrightTester tester) { IPage Page => tester.Page; /// /// To use to nagivate to a static search item (such as a page quickly) /// /// public async Task GoToPage(string page) { await Fill(page); await Enter(); } public async Task Fill(string query) { await Page.Keyboard.PressAsync("/"); await Page.Locator("#globalSearchInput").FillAsync(query); await Page.Locator("#globalSearchResults:not([hidden])").WaitForAsync(); } public Task Enter() => Page.Keyboard.PressAsync("Enter"); public ILocator GetResultLocator(string partialText) => Page.Locator("#globalSearchResults .globalSearch-item", new() { HasTextString = partialText }); public async Task AssertShow(string partialText) { var locator = GetResultLocator(partialText); await Expect(GetResultLocator(partialText)).ToBeVisibleAsync(); return locator; } }