feature: Phase 23 Track A — env-gated /robots.txt + /sitemap.xml public crawl endpoints

This commit is contained in:
daniel-c-harvey
2026-06-23 07:23:42 -04:00
parent 9a4b79d377
commit 5f4807cc4a
6 changed files with 432 additions and 0 deletions
+62
View File
@@ -0,0 +1,62 @@
using DeepDrftPublic.Seo;
namespace DeepDrftTests;
/// <summary>
/// Unit tests for <see cref="RobotsTxt"/> — the pure environment-branch composition of the robots.txt body
/// (Phase 23 wave 23.1). The gate (Production vs. anything-else) is the load-bearing branch: Production
/// allows + points at the sitemap and disallows the non-page routes; every non-production environment is a
/// closed door with no sitemap pointer (Invariant E1).
/// </summary>
[TestFixture]
public class RobotsTxtTests
{
private const string BaseUrl = "https://deepdrft.com";
[Test]
public void Build_Production_AllowsAndPointsAtSitemap()
{
var body = RobotsTxt.Build(isProduction: true, BaseUrl);
Assert.Multiple(() =>
{
Assert.That(body, Does.Contain("User-agent: *"));
Assert.That(body, Does.Contain("Allow: /"));
Assert.That(body, Does.Contain("Sitemap: https://deepdrft.com/sitemap.xml"));
});
}
[Test]
public void Build_Production_DisallowsFramePlayerAndApi()
{
var body = RobotsTxt.Build(isProduction: true, BaseUrl);
Assert.Multiple(() =>
{
Assert.That(body, Does.Contain("Disallow: /FramePlayer"));
Assert.That(body, Does.Contain("Disallow: /api/"));
});
}
[Test]
public void Build_NonProduction_DisallowsEverythingWithNoSitemapPointer()
{
var body = RobotsTxt.Build(isProduction: false, BaseUrl);
Assert.Multiple(() =>
{
Assert.That(body, Does.Contain("User-agent: *"));
Assert.That(body, Does.Contain("Disallow: /"));
Assert.That(body, Does.Not.Contain("Allow:"));
Assert.That(body, Does.Not.Contain("Sitemap:"));
});
}
[Test]
public void Build_Production_TrimsTrailingSlashOnBaseUrl()
{
var body = RobotsTxt.Build(isProduction: true, "https://deepdrft.com/");
Assert.That(body, Does.Contain("Sitemap: https://deepdrft.com/sitemap.xml"));
}
}