logicsrc/apps/pwa/test/seo.test.mjs
Anthony Ettinger d3e07430b4 app.logicsrc.com: sitemap.xml + robots Sitemap line (public pages only)
The credentials app answered 404 for both. robots.txt and sitemap.xml now come
from the request host, list only the sign-in and sign-up pages, and disallow the
session-only areas.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 16:00:54 +00:00

26 lines
1.2 KiB
JavaScript

import assert from "node:assert/strict";
import test from "node:test";
import { robotsTxt, siteOrigin, sitemapXml } from "../src/lib/seo.mjs";
const req = (host, protocol = "http") => ({ protocol, headers: { host }, get: (h) => (h.toLowerCase() === "host" ? host : undefined) });
test("each hostname describes itself over https", () => {
assert.equal(siteOrigin(req("app.logicsrc.com"), "https://x"), "https://app.logicsrc.com");
assert.equal(siteOrigin(req("localhost:8080"), "https://x"), "http://localhost:8080");
});
test("sitemap lists only public pages on this host", () => {
const xml = sitemapXml("https://app.logicsrc.com");
assert.match(xml, /<urlset /);
assert.match(xml, /<loc>https:\/\/app\.logicsrc\.com\/<\/loc>/);
assert.match(xml, /<loc>https:\/\/app\.logicsrc\.com\/\?mode=up<\/loc>/);
assert.doesNotMatch(xml, /dashboard|settings|keyring/);
});
test("robots points at this host's sitemap and keeps it crawlable", () => {
const txt = robotsTxt("https://app.logicsrc.com");
assert.match(txt, /^Sitemap: https:\/\/app\.logicsrc\.com\/sitemap\.xml$/m);
assert.doesNotMatch(txt, /Disallow: \/sitemap/);
assert.match(txt, /Disallow: \/dashboard/);
});