Giving up at UI testing

This commit is contained in:
Paul Schneider 2026-06-15 00:00:39 +01:00
commit 69e81b9fd4
5 changed files with 23 additions and 17 deletions

View file

@ -8,7 +8,7 @@ namespace Yavsc.Tests
readonly WebServerFixture _server; readonly WebServerFixture _server;
public DumpHtml(WebServerFixture server) { _server = server; } public DumpHtml(WebServerFixture server) { _server = server; }
[Fact] // FIXME [Fact]
[Trait("debug", "html")] [Trait("debug", "html")]
public void DumpHomePageHtml() public void DumpHomePageHtml()
{ {
@ -19,6 +19,7 @@ namespace Yavsc.Tests
}; };
var httpsUrl = _server.Addresses.FirstOrDefault(u => u.StartsWith("https:")) var httpsUrl = _server.Addresses.FirstOrDefault(u => u.StartsWith("https:"))
?? _server.Addresses.FirstOrDefault() ?? ""; ?? _server.Addresses.FirstOrDefault() ?? "";
// var httpsUrl = "https://localhost:5001" ;
using var client = new HttpClient(handler) { BaseAddress = new Uri(httpsUrl) }; using var client = new HttpClient(handler) { BaseAddress = new Uri(httpsUrl) };
var paths = new[] { "/Home/About", "/css/site.css", "/lib/bootstrap.quartz.min.css", "/nonexistent" }; var paths = new[] { "/Home/About", "/css/site.css", "/lib/bootstrap.quartz.min.css", "/nonexistent" };

View file

@ -1,6 +1,7 @@
using OpenQA.Selenium; using OpenQA.Selenium;
using OpenQA.Selenium.Chrome; using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Firefox;
using Xunit.Abstractions; using Xunit.Abstractions;
using Yavsc.Tests; using Yavsc.Tests;
@ -22,19 +23,22 @@ public class FirstScript : BaseTestContext
} }
[Fact] // FIXME [Fact]
public async Task DoTestYavscSite() public async Task DoTestYavscSite()
{ {
var chromeOptions = new ChromeOptions
var firefoxOptions = new FirefoxOptions
{ {
AcceptInsecureCertificates = true AcceptInsecureCertificates = true
}; };
var driver = new ChromeDriver(chromeOptions); var driver = new FirefoxDriver(firefoxOptions);
var url = _serverFixture.Addresses.FirstOrDefault(u => u.StartsWith("https:"));
Assert.NotNull(url);
driver.Navigate().GoToUrl(url);
var url = _serverFixture.Addresses.FirstOrDefault(u => u.StartsWith("http:"));
Assert.NotNull(url);
//driver.Navigate().GoToUrl(url);
driver.Navigate().GoToUrl("http://localhost:5000/Home/About");
var title = driver.Title; var title = driver.Title;
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromMilliseconds(500); driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromMilliseconds(500);

View file

@ -115,17 +115,16 @@ namespace Yavsc.Tests
public async Task SetupHost() public async Task SetupHost()
{ {
Environment.SetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", "Development");
// Set ContentRoot to the Yavsc.Org project directory so WebRootPath resolves correctly
var cwd = System.IO.Directory.GetCurrentDirectory();
var yavscOrgPath = Path.GetFullPath(
Path.Combine(cwd,
"../../../../../src/Yavsc.Org"));
Environment.CurrentDirectory = yavscOrgPath;
var builder = WebApplication.CreateBuilder();
builder.Environment.EnvironmentName = "Development";
builder.Environment.ContentRootPath = yavscOrgPath; var builder = WebApplication.CreateBuilder();
var slnDir = builder.Configuration.GetValue<string>("SLNDIR");
Assert.NotNull(slnDir);
var yavscOrgPath = Path.GetFullPath(
Path.Combine(slnDir,
"src/Yavsc.Org"));
Environment.CurrentDirectory = yavscOrgPath;
builder.AddConfiguration("org").AddInMemoryCollection(new Dictionary<string, string?> builder.AddConfiguration("org").AddInMemoryCollection(new Dictionary<string, string?>
{ {

View file

@ -63,5 +63,7 @@
"UserName": "fakeuser", "UserName": "fakeuser",
"Password": "f/\\kePassw0rd" "Password": "f/\\kePassw0rd"
} }
} },
"SLNDIR": "your SLNDIR"
} }