Fixes the css

This commit is contained in:
Paul Schneider 2026-06-14 23:04:24 +01:00
commit cba18df870
11 changed files with 124 additions and 77 deletions

2
.gitignore vendored
View file

@ -36,3 +36,5 @@ appsettings.Development.json
contrib/generated/
*.tmp
DataDir/

File diff suppressed because one or more lines are too long

View file

@ -5,7 +5,7 @@ namespace Yavsc.Server.Helpers;
public static class ConfigHelpers
{
public static void AddConfiguration(this WebApplicationBuilder builder, string appName )
public static IConfigurationBuilder AddConfiguration(this WebApplicationBuilder builder, string appName )
{
var rootConfig = builder.Configuration
.AddJsonFile($"appsettings-{appName}.json", optional: false, reloadOnChange: false);
@ -13,6 +13,6 @@ public static class ConfigHelpers
if (!String.IsNullOrWhiteSpace(builder.Environment.EnvironmentName))
rootConfig.AddJsonFile($"appsettings-{appName}.{builder.Environment.EnvironmentName}.json", optional: true, reloadOnChange: false);
;
rootConfig.AddEnvironmentVariables();
return rootConfig.AddEnvironmentVariables();
}
}

View file

@ -0,0 +1,39 @@
using System.Net.Http;
namespace Yavsc.Tests
{
[Collection("Yavsc Server")]
public class DumpHtml : IClassFixture<WebServerFixture>
{
readonly WebServerFixture _server;
public DumpHtml(WebServerFixture server) { _server = server; }
[Fact]
[Trait("debug", "html")]
public void DumpHomePageHtml()
{
var settings = _server.SiteSettings;
var handler = new HttpClientHandler
{
ServerCertificateCustomValidationCallback = (_, _, _, _) => true,
};
var httpsUrl = _server.Addresses.FirstOrDefault(u => u.StartsWith("https:"))
?? _server.Addresses.FirstOrDefault() ?? "";
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 sb = new System.Text.StringBuilder();
sb.AppendLine($"BaseAddress = {httpsUrl}");
foreach (var p in paths)
{
var r = client.GetAsync(p).GetAwaiter().GetResult();
var b = r.Content.ReadAsStringAsync().GetAwaiter().GetResult();
sb.AppendLine($"GET {p} => {r.StatusCode} len={b.Length} ct={r.Content.Headers.ContentType}");
if (b.Length > 0 && b.Length < 500)
sb.AppendLine($" body: {b.Substring(0, Math.Min(300, b.Length))}");
}
Assert.Fail(sb.ToString());
}
}
}

View file

@ -1,24 +1,47 @@
using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using Xunit.Abstractions;
using Yavsc.Tests;
namespace yavscTests.ServerFixtures;
namespace SeleniumDocs.GettingStarted;
[Collection("Yavsc Server")]
[Trait("regression", "oui")]
public static class FirstScript
{
[Fact]
public static void DoTestSeleniumWebSite()
{
IWebDriver driver = new ChromeDriver();
driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/web-form.html");
public class FirstScript : BaseTestContext
{
public readonly WebServerFixture _serverFixture;
readonly ITestOutputHelper _output;
IWebDriver driver = new ChromeDriver();
public FirstScript(ITestOutputHelper output, WebServerFixture fixture) : base(output, fixture)
{
_serverFixture = fixture;
this._output = output;
}
[Fact]
public async Task DoTestYavscSite()
{
var chromeOptions = new ChromeOptions
{
AcceptInsecureCertificates = true
};
var driver = new ChromeDriver(chromeOptions);
var url = _serverFixture.Addresses.FirstOrDefault(u => u.StartsWith("https:"));
Assert.NotNull(url);
driver.Navigate().GoToUrl(url);
var title = driver.Title;
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromMilliseconds(500);
var navbar = driver.FindElement(By.Id("navbar"));
Assert.NotNull(navbar);
/*
var textBox = driver.FindElement(By.Name("my-text"));
var submitButton = driver.FindElement(By.TagName("button"));
@ -27,7 +50,9 @@ public static class FirstScript
var message = driver.FindElement(By.Id("message"));
var value = message.Text;
*/
driver.Quit();
}
}

View file

@ -4,7 +4,7 @@ using Yavsc.Models;
using Xunit.Abstractions;
using Yavsc.Server.Models.IT.SourceCode;
using Microsoft.EntityFrameworkCore;
using isnd.tests;
using Yavsc.Tests;
using Yavsc.Server.Models.IT;
namespace yavscTests

View file

@ -1,6 +1,6 @@
using System.Security.Cryptography.X509Certificates;
using System.Net.Security;
using isnd.tests;
using Yavsc.Tests;
using Xunit.Abstractions;
using IdentityModel.Client;

View file

@ -1,4 +1,4 @@
using isnd.tests;
using Yavsc.Tests;
using Xunit.Abstractions;
namespace yavscTests.Mandatory;

View file

@ -1,4 +1,4 @@
using isnd.tests;
using Yavsc.Tests;
using Xunit.Abstractions;
namespace yavscTests.Mandatory

View file

@ -1,4 +1,4 @@
using isnd.tests;
using Yavsc.Tests;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Xunit.Abstractions;

View file

@ -6,7 +6,6 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Hosting.Server;
using Microsoft.AspNetCore.Hosting.Server.Features;
using Microsoft.AspNetCore.Identity;
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
@ -15,15 +14,15 @@ using Microsoft.Extensions.Options;
using System.Net;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using Yavsc;
using Yavsc.Extensions;
using Yavsc.Models;
using Yavsc.Server.Helpers;
using Client = IdentityServer8.EntityFramework.Entities.Client;
namespace isnd.tests
namespace Yavsc.Tests
{
[CollectionDefinition("Web server collection")]
[CollectionDefinition("Yavsc Server")]
public class WebServerFixture : IDisposable
{
private static readonly Lazy<X509Certificate2> _selfSignedCertificate = new Lazy<X509Certificate2>(CreateSelfSignedCertificate);
@ -116,33 +115,19 @@ namespace isnd.tests
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";
// Set ContentRoot to the Yavsc.Org project directory so WebRootPath resolves correctly.
// Walk up from BaseDir until we find a directory that contains src/Yavsc.Org. This is
// robust against the test runner changing the current working directory.
var testAssemblyLocation = AppDomain.CurrentDomain.BaseDirectory;
string yavscOrgPath = "";
for (var d = new DirectoryInfo(testAssemblyLocation); d != null; d = d.Parent)
{
var candidate = Path.Combine(d.FullName, "src/Yavsc.Org");
if (Directory.Exists(candidate))
{
yavscOrgPath = candidate;
break;
}
}
if (string.IsNullOrEmpty(yavscOrgPath))
throw new InvalidOperationException(
$"Could not locate src/Yavsc.Org by walking up from {testAssemblyLocation}");
builder.Environment.ContentRootPath = yavscOrgPath;
builder.Configuration
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: false)
.AddJsonFile($"appsettings.{builder.Environment.EnvironmentName}.json", optional: false, reloadOnChange: false)
.AddEnvironmentVariables()
.AddInMemoryCollection(new Dictionary<string, string?>
builder.AddConfiguration("org").AddInMemoryCollection(new Dictionary<string, string?>
{
[$"ConnectionStrings:{YavscConstants.YavscConnectionStringName}"] = "InMemory"
});
@ -176,23 +161,12 @@ namespace isnd.tests
EnsureUser(TestingUserName, TestingUserPassword, TestingUserEmail, migrationScope);
AddAuthorizedClient(migrationScope, TestClientId, TestClientSecret);
TestingUser = await db.Users.FirstOrDefaultAsync(u => u.UserName == TestingUserName);
}
// Seed IdentityServer ConfigurationDbContext with API resources and scopes
using (var configScope = _app.Services.CreateScope())
{
try
{
var configDbContext = configScope.ServiceProvider.GetService<IdentityServer8.EntityFramework.DbContexts.ConfigurationDbContext>();
if (configDbContext != null)
{
configDbContext.Database.EnsureCreated();
// Add test API scope if it doesn't exist
var testScope = configDbContext.ApiScopes.FirstOrDefault(s => s.Name == "test");
var testScope = db.ApiScopes.FirstOrDefault(s => s.Name == "test");
if (testScope == null)
{
configDbContext.ApiScopes.Add(new IdentityServer8.EntityFramework.Entities.ApiScope
db.ApiScopes.Add(new IdentityServer8.EntityFramework.Entities.ApiScope
{
Name = "test",
Enabled = true,
@ -219,20 +193,15 @@ namespace isnd.tests
}
}
};
configDbContext.ApiResources.Add(apiResource);
configDbContext.SaveChanges();
}
}
}
catch (Exception ex)
{
_sharedLogger?.LogWarning($"Failed to seed ConfigurationDbContext: {ex.Message}");
// Don't fail the fixture if seeding fails
db.ApiResources.Add(apiResource);
db.SaveChanges();
}
}
await _app!.ConfigurePipeline();
_app.UseSession();
_app = await _app.ConfigurePipeline();
await _app.StartAsync();
_sharedServices = _app.Services;