Website: host vervangt het productie-basisadres in index.html door Website__PublicBaseUrl op testinstanties (Website:AuthoredBaseUrl)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -78,6 +78,43 @@ public sealed class SpaSeoTests : IDisposable
|
||||
provider.Calls.Should().Be(2);
|
||||
}
|
||||
|
||||
private async Task<string> ServeAuthoredPageAsync(string baseUrl, string? authored)
|
||||
{
|
||||
File.WriteAllText(
|
||||
Path.Combine(_root, "wwwroot", "web", "index.html"),
|
||||
"<head><link rel=\"canonical\" href=\"https://slpsoftware.nl/\"><meta property=\"og:image\" content=\"https://slpsoftware.nl/og.png\"></head><body><!--SLP:TEST--></body>");
|
||||
var settings = Config(noIndex: false, baseUrl: baseUrl);
|
||||
if (authored is not null) settings["Website:AuthoredBaseUrl"] = authored;
|
||||
var client = await StartAsync(settings, services => services.AddSingleton<IIndexHtmlMarkerProvider>(new CountingProvider()));
|
||||
return await client.GetStringAsync("/");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task OnATestInstance_TheAuthoredProductionAddressBecomesTheInstancesOwn()
|
||||
{
|
||||
var html = await ServeAuthoredPageAsync("https://test.slpsoftware.nl", "https://slpsoftware.nl");
|
||||
|
||||
html.Should().Contain("href=\"https://test.slpsoftware.nl/\"")
|
||||
.And.Contain("content=\"https://test.slpsoftware.nl/og.png\"")
|
||||
.And.NotContain("https://slpsoftware.nl");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task OnProduction_TheReplacementIsANoOp()
|
||||
{
|
||||
var html = await ServeAuthoredPageAsync("https://slpsoftware.nl", "https://slpsoftware.nl");
|
||||
|
||||
html.Should().Contain("href=\"https://slpsoftware.nl/\"").And.Contain("https://slpsoftware.nl/og.png");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WithoutAnAuthoredAddress_NothingIsReplaced()
|
||||
{
|
||||
var html = await ServeAuthoredPageAsync("https://test.slpsoftware.nl", null);
|
||||
|
||||
html.Should().Contain("https://slpsoftware.nl/og.png");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task AMatchingETag_Gets304()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user