Vertaalbestanden 5a/6: karakteriseringstest van de placeholder-pagina
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
<!doctype html>
|
||||
<html lang="nl">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="robots" content="noindex, nofollow">
|
||||
<title>Nog geen website geplaatst</title>
|
||||
<style>
|
||||
:root { color-scheme: light dark; }
|
||||
body {
|
||||
margin: 0;
|
||||
min-height: 100svh;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
padding: 2rem;
|
||||
font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
|
||||
line-height: 1.6;
|
||||
background: #fafafa;
|
||||
color: #1a1a1a;
|
||||
}
|
||||
@media (prefers-color-scheme: dark) {
|
||||
body { background: #141414; color: #ededed; }
|
||||
code { background: #262626; color: #141414; }
|
||||
a { color: #ff6b6b; }
|
||||
}
|
||||
main { max-width: 34rem; }
|
||||
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
|
||||
p { margin: 0 0 1rem; }
|
||||
code {
|
||||
background: #ececec;
|
||||
color: #1a1a1a;
|
||||
padding: 0.15em 0.4em;
|
||||
border-radius: 4px;
|
||||
font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
a { color: #ac0000; }
|
||||
.muted { font-size: 0.9rem; opacity: 0.75; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<h1>Er staat hier nog geen website</h1>
|
||||
<p>
|
||||
Het CMS draait, maar er is nog geen publieke website geplaatst. De website
|
||||
wordt apart aangeleverd en hoort in de map <code>wwwroot/web/</code> te staan,
|
||||
met een <code>index.html</code> in de hoofdmap daarvan.
|
||||
</p>
|
||||
<p>
|
||||
Beheerders kunnen inloggen via <a href="/admin/">/admin/</a>.
|
||||
</p>
|
||||
<p class="muted">
|
||||
Deze pagina wordt automatisch vervangen zodra de website is geplaatst.
|
||||
</p>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,66 @@
|
||||
using System.Net;
|
||||
using FluentAssertions;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.TestHost;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SlpModularCms.Core.Hosting;
|
||||
using SlpModularCms.Core.Texts;
|
||||
using Xunit;
|
||||
|
||||
namespace SlpModularCms.Core.Tests.Hosting;
|
||||
|
||||
/// <summary>
|
||||
/// The page a host shows while no website is deployed. The golden file is the page as it was before its sentences moved
|
||||
/// into the text files (Dutch); the rendered page must stay byte-identical.
|
||||
/// </summary>
|
||||
public sealed class WebsitePlaceholderTests : IDisposable
|
||||
{
|
||||
private readonly string _root = Path.Combine(Path.GetTempPath(), "slp-placeholder-" + Guid.NewGuid().ToString("N"));
|
||||
private WebApplication? _app;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_app?.DisposeAsync().AsTask().GetAwaiter().GetResult();
|
||||
if (Directory.Exists(_root)) Directory.Delete(_root, recursive: true);
|
||||
}
|
||||
|
||||
private async Task<HttpClient> StartAsync(string? language = null)
|
||||
{
|
||||
Directory.CreateDirectory(Path.Combine(_root, "wwwroot"));
|
||||
var builder = WebApplication.CreateBuilder(new WebApplicationOptions
|
||||
{
|
||||
EnvironmentName = Environments.Production,
|
||||
ContentRootPath = _root,
|
||||
WebRootPath = Path.Combine(_root, "wwwroot"),
|
||||
});
|
||||
builder.WebHost.UseTestServer();
|
||||
builder.Logging.ClearProviders();
|
||||
if (language is not null) builder.Configuration.AddInMemoryCollection(new Dictionary<string, string?> { ["Texts:DefaultLanguage"] = language });
|
||||
builder.Services.AddCmsTexts(builder.Configuration);
|
||||
|
||||
_app = builder.Build();
|
||||
_app.UseCmsStaticContent(WebsiteMode.SpaFallback);
|
||||
_app.MapCmsSpaFallbacks(WebsiteMode.SpaFallback);
|
||||
await _app.StartAsync();
|
||||
return _app.GetTestClient();
|
||||
}
|
||||
|
||||
private static string Golden() =>
|
||||
File.ReadAllText(Path.Combine(AppContext.BaseDirectory, "Golden", "host", "WebsitePlaceholder.nl.html")).Replace("\r\n", "\n");
|
||||
|
||||
[Fact]
|
||||
public async Task WithoutAWebsite_TheDutchPlaceholder_IsByteIdenticalToTheOriginalPage()
|
||||
{
|
||||
var client = await StartAsync();
|
||||
|
||||
var response = await client.GetAsync("/");
|
||||
|
||||
response.StatusCode.Should().Be(HttpStatusCode.OK);
|
||||
response.Content.Headers.ContentType!.ToString().Should().Be("text/html; charset=utf-8");
|
||||
(await response.Content.ReadAsStringAsync()).Replace("\r\n", "\n").Should().Be(Golden());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user