Agent Tests for API, MAUI, and Slop Features

This commit is contained in:
2026-06-03 19:08:35 -04:00
parent 46150d3a69
commit 0feac0f0a0
142 changed files with 4156 additions and 1462 deletions
+25 -10
View File
@@ -1,22 +1,35 @@
using System.Text.RegularExpressions;
namespace Tests.Pages.BuildCalculator;
public class ArmyComponent
{
private readonly Website _website;
public ArmyComponent(Website website) => _website = website;
public ArmyComponent(Website website)
{
_website = website;
}
public ILocator ArmyView => _website.Locator(".armyView");
public ILocator DisplayValue(string label) =>
_website.Locator(".displayContainer").Filter(new() { HasText = label }).Locator(".displayContent");
public ILocator ArmyCards => ArmyView.Locator(".armyCard");
public async Task<string> GetArmyCompletedAtAsync() =>
(await DisplayValue("Army Completed At").TextContentAsync())?.Trim() ?? "";
public ILocator DisplayValue(string label)
{
return _website.Locator(".displayContainer").Filter(new LocatorFilterOptions { HasText = label })
.Locator(".displayContent");
}
public async Task<string> GetArmyAttackingAtAsync() =>
(await DisplayValue("Army Attacking At").TextContentAsync())?.Trim() ?? "";
public async Task<string> GetArmyCompletedAtAsync()
{
return (await DisplayValue("Army Completed At").TextContentAsync())?.Trim() ?? "";
}
public async Task<string> GetArmyAttackingAtAsync()
{
return (await DisplayValue("Army Attacking At").TextContentAsync())?.Trim() ?? "";
}
public async Task<IReadOnlyList<string>> GetArmyUnitNamesAsync()
{
@@ -25,9 +38,10 @@ public class ArmyComponent
foreach (var card in cards)
{
var text = (await card.InnerTextAsync()).Trim();
var match = System.Text.RegularExpressions.Regex.Match(text, @"\d+x\s*(.+)");
var match = Regex.Match(text, @"\d+x\s*(.+)");
names.Add(match.Success ? match.Groups[1].Value.Trim() : text);
}
return names;
}
@@ -43,6 +57,7 @@ public class ArmyComponent
var name = (await nameEl.TextContentAsync())?.Trim() ?? "";
counts.Add((name, int.Parse(count)));
}
return counts;
}
}
}