Converting Tests back to C# but still with Playwright

This commit is contained in:
2026-06-03 14:45:18 -04:00
parent 85834466f1
commit 46150d3a69
209 changed files with 1503 additions and 683 deletions
+20
View File
@@ -0,0 +1,20 @@
namespace Tests.Shared;
public class NavigationBar
{
private readonly Website _website;
public NavigationBar(Website website) => _website = website;
public ILocator SearchButton => _website.Locator("#desktop-searchButton");
public async Task ClickHomeLinkAsync()
{
await _website.Locator("a:has-text(\"IGP Fan Reference\")").ClickAsync();
}
public async Task<SearchDialog> ClickSearchButtonAsync()
{
await SearchButton.ClickAsync();
return _website.SearchDialog;
}
}
+26
View File
@@ -0,0 +1,26 @@
namespace Tests.Shared;
public class SearchDialog
{
private readonly Website _website;
public SearchDialog(Website website) => _website = website;
public ILocator SearchBackground => _website.FindById("searchBackground");
public ILocator SearchInput => _website.FindById("searchInput");
public async Task CloseDialogAsync()
{
await _website.ClickElementAsync(SearchBackground);
}
public async Task<SearchDialog> SearchAsync(string text)
{
await _website.EnterInputAsync(SearchInput, text);
return this;
}
public async Task SelectSearchEntityAsync(string label)
{
await _website.ClickElementAsync(_website.Locator($"button[label=\"{label}\"]"));
}
}
+36
View File
@@ -0,0 +1,36 @@
namespace Tests.Shared;
public class ToastComponent
{
private readonly Website _website;
public ToastComponent(Website website) => _website = website;
public ILocator Container => _website.Locator(".toastsContainer");
public ILocator Toasts => _website.Locator(".toastsContainer .toastContainer");
public async Task<IReadOnlyList<string>> GetToastTitlesAsync()
{
var titles = await _website.Locator(".toastsContainer .toastTitle").AllTextContentsAsync();
return titles.Select(t => t.Trim()).Where(t => !string.IsNullOrEmpty(t)).ToList();
}
public async Task<bool> HasToastContainingAsync(string text)
{
try
{
await _website.Page.WaitForFunctionAsync(
@"(expected) => {
const titles = document.querySelectorAll('.toastsContainer .toastTitle');
return Array.from(titles).some(t => t.textContent.trim().includes(expected));
}",
text,
new() { Timeout = 3000 }
);
return true;
}
catch
{
return false;
}
}
}