Tech stack stub page and changing project to be just one Web Assembly project for now

This commit is contained in:
2026-05-27 11:25:04 -04:00
parent 8a20cfec4f
commit dd74f9b69f
140 changed files with 64156 additions and 97 deletions
+36
View File
@@ -0,0 +1,36 @@
using AOW4.SeleniumTests.Driver;
using NUnit.Framework;
using OpenQA.Selenium;
namespace AOW4.SeleniumTests.Tests;
[TestFixture]
public abstract class BaseTest
{
[OneTimeSetUp]
public void GlobalSetup()
{
Driver = DriverFactory.CreateChromeDriver();
Driver.Manage().Window.Maximize();
}
[OneTimeTearDown]
public void GlobalTeardown()
{
try
{
Driver.Quit();
}
catch
{
}
}
protected IWebDriver Driver = null!;
protected string BaseUrl => "http://localhost:5212/";
protected void GoHome()
{
Driver.Navigate().GoToUrl(BaseUrl);
}
}
+62
View File
@@ -0,0 +1,62 @@
using NUnit.Framework;
using OpenQA.Selenium;
namespace AOW4.SeleniumTests.Tests;
[TestFixture]
public class BrokenLinksTest : BaseTest
{
[Test]
public void ScanAndReportBrokenLinks()
{
GoHome();
var anchors = Driver.FindElements(By.CssSelector("a[href]"))
.Select(a => a.GetAttribute("href") ?? string.Empty)
.Where(h => !string.IsNullOrWhiteSpace(h))
.Distinct()
.ToList();
var failures = new List<string>();
using var client = new HttpClient();
foreach (var raw in anchors)
{
if (raw.StartsWith("javascript:", StringComparison.OrdinalIgnoreCase))
continue;
if (raw.StartsWith("mailto:", StringComparison.OrdinalIgnoreCase))
continue;
Uri uri;
try
{
uri = new Uri(raw, UriKind.RelativeOrAbsolute);
if (!uri.IsAbsoluteUri) uri = new Uri(new Uri(BaseUrl), raw);
}
catch
{
failures.Add($"Invalid URI: {raw}");
continue;
}
try
{
using var req = new HttpRequestMessage(HttpMethod.Head, uri);
var resp = client.Send(req);
if (!resp.IsSuccessStatusCode)
{
// try GET as fallback
using var greq = new HttpRequestMessage(HttpMethod.Get, uri);
var gresp = client.Send(greq);
if (!gresp.IsSuccessStatusCode) failures.Add($"{(int)gresp.StatusCode} {uri}");
}
}
catch (Exception ex)
{
failures.Add($"Error checking {uri}: {ex.Message}");
}
}
if (failures.Any()) Assert.Fail("Broken links found:\n" + string.Join("\n", failures));
}
}
+18
View File
@@ -0,0 +1,18 @@
using NUnit.Framework;
namespace AOW4.SeleniumTests.Tests;
[TestFixture]
public class NavigationTests : BaseTest
{
[TestCase("Building Plan Calculator", "/building-calculator")]
public void ClickNavLink_NavigatesToPage(string linkText, string expectedPath)
{
GoHome();
Assert.IsTrue(
Driver.Url.Contains(expectedPath, StringComparison.OrdinalIgnoreCase) ||
Driver.PageSource.Contains(linkText),
$"Expected to be on route containing '{expectedPath}' after clicking '{linkText}', but was '{Driver.Url}'");
}
}