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
+8 -11
View File
@@ -32,18 +32,15 @@ public static class LocalServer
};
var tcs = new TaskCompletionSource<string>();
_process.OutputDataReceived += (s, e) =>
{
if (string.IsNullOrEmpty(e.Data)) return;
Console.WriteLine($"[SERVER] {e.Data}");
var match = Regex.Match(e.Data, @"Now listening on:\s+(http://127.0.0.1:\d+)");
if (match.Success)
{
tcs.TrySetResult(match.Groups[1].Value);
}
if (match.Success) tcs.TrySetResult(match.Groups[1].Value);
};
_process.ErrorDataReceived += (s, e) =>
{
if (!string.IsNullOrEmpty(e.Data))
@@ -55,8 +52,8 @@ public static class LocalServer
_process.BeginErrorReadLine();
// Wait for the URL to be parsed from output
BaseUrl = await Task.WhenAny(tcs.Task, Task.Delay(30000)) == tcs.Task
? tcs.Task.Result
BaseUrl = await Task.WhenAny(tcs.Task, Task.Delay(30000)) == tcs.Task
? tcs.Task.Result
: null;
if (BaseUrl == null)
@@ -64,7 +61,7 @@ public static class LocalServer
Stop();
throw new Exception("Timeout waiting for local server to start and provide a URL.");
}
Console.WriteLine($"[DEBUG_LOG] Local server started at: {BaseUrl}");
}
@@ -88,7 +85,7 @@ public static class LocalServer
if (parent == current) break;
current = parent;
}
if (string.IsNullOrEmpty(current) || !File.Exists(Path.Combine(current, "IGP.sln")))
{
// Fallback to searching up from current directory if BaseDirectory fails
@@ -103,4 +100,4 @@ public static class LocalServer
return current ?? throw new Exception("Could not find project root containing IGP.sln");
}
}
}
+20 -10
View File
@@ -1,4 +1,3 @@
using Microsoft.Playwright;
using Tests.Pages;
using Tests.Shared;
@@ -6,16 +5,12 @@ namespace Tests.Helpers;
public class Website
{
public IPage Page { get; }
public bool RunAgainstProduction { get; }
public string BaseUrl { get; }
public Website(IPage page)
{
Page = page;
RunAgainstProduction = Environment.GetEnvironmentVariable("RUN_AGAINST_PRODUCTION") == "true";
BaseUrl = RunAgainstProduction ? "https://igpfanreference.ca" : (LocalServer.BaseUrl ?? "http://localhost:5234");
BaseUrl = RunAgainstProduction ? "https://igpfanreference.ca" : LocalServer.BaseUrl ?? "http://localhost:5234";
NavigationBar = new NavigationBar(this);
SearchDialog = new SearchDialog(this);
@@ -25,8 +20,10 @@ public class Website
DatabaseSinglePage = new DatabaseSinglePage(this);
}
public ILocator Locator(string selector) => Page.Locator(selector);
public ILocator FindById(string id) => Page.Locator($"#{id}");
public IPage Page { get; }
public bool RunAgainstProduction { get; }
public string BaseUrl { get; }
public NavigationBar NavigationBar { get; }
public SearchDialog SearchDialog { get; }
public BuildCalculatorPage BuildCalculatorPage { get; }
@@ -34,17 +31,30 @@ public class Website
public DatabasePage DatabasePage { get; }
public DatabaseSinglePage DatabaseSinglePage { get; }
public ILocator Locator(string selector)
{
return Page.Locator(selector);
}
public ILocator FindById(string id)
{
return Page.Locator($"#{id}");
}
public async Task GotoAsync(string? path = null)
{
var url = path is null ? BaseUrl : $"{BaseUrl}/{path}";
await Page.GotoAsync(url);
}
public async Task ClickElementAsync(ILocator locator) => await locator.ClickAsync();
public async Task ClickElementAsync(ILocator locator)
{
await locator.ClickAsync();
}
public async Task EnterInputAsync(ILocator locator, string value)
{
await locator.FillAsync(value);
await locator.PressAsync("Enter");
}
}
}