diff --git a/scripts/test-website.py b/scripts/test-website.py
index 96a6346031..778b35bfee 100644
--- a/scripts/test-website.py
+++ b/scripts/test-website.py
@@ -306,8 +306,9 @@ class WebsiteSearchChecks(unittest.TestCase):
},
)
nested.rename(site / "moved.html")
- self.assertIn("https://rea.tools/moved.html", urls())
- self.assertNotIn("https://rea.tools/guides/new/", urls())
+ moved = urls()
+ self.assertIn("https://rea.tools/moved.html", moved)
+ self.assertNotIn("https://rea.tools/guides/new/", moved)
(site / "moved.html").unlink()
self.assertNotIn("https://rea.tools/moved.html", urls())
@@ -319,31 +320,25 @@ class WebsiteSearchChecks(unittest.TestCase):
"index.html",
'rel="canonical" href="https://rea.tools/"',
'rel="canonical" href="https://morluto.github.io/rea/"',
- "head canonical",
+ "needs exactly one head canonical",
),
(
"faq/index.html",
'hreflang="zh-CN" href="https://rea.tools/zh-CN/faq/"',
'hreflang="zh-CN" href="https://[::1/faq/"',
- "invalid URL",
+ "invalid hreflang URL",
),
(
"showcase/aegis/index.html",
'rel="canonical" href="https://rea.tools/showcase/aegis/"',
'rel="canonical" href="https://rea.tools/"',
- "head canonical",
- ),
- (
- "examples/notes-electron/index.html",
- 'content="noindex"',
- 'content="index"',
- "must have a head noindex",
+ "needs exactly one head canonical",
),
(
"sitemap.xml",
"https://rea.tools/faq/",
"https://rea.tools/deleted/",
- "each indexable page once",
+ "must contain each indexable page once",
),
(
"faq/index.html",
@@ -352,25 +347,27 @@ class WebsiteSearchChecks(unittest.TestCase):
"twitter:card",
),
)
- for name, old, new, message in cases:
- with self.subTest(name=name), tempfile.TemporaryDirectory() as directory:
- site = Path(directory) / "public"
- shutil.copytree(ROOT / "website/_site", site)
+ with tempfile.TemporaryDirectory() as directory:
+ site = Path(directory) / "public"
+ shutil.copytree(ROOT / "website/_site", site)
+ for name, old, new, _ in cases:
path = site / name
source = path.read_text()
self.assertIn(old, source)
path.write_text(source.replace(old, new, 1))
- self.assertTrue(
- any(message in error for error in VERIFY.check_site(site)[3])
- )
- with tempfile.TemporaryDirectory() as directory:
- site = Path(directory) / "public"
- shutil.copytree(ROOT / "website/_site", site)
(site / "assets/social-card.png").unlink()
- self.assertIn(
- "Social preview PNG is missing; run scripts/prepare-website.py",
- VERIFY.check_site(site)[3],
- )
+ diagnostics = "\n".join(VERIFY.check_site(site)[3])
+ for name, _, _, message in cases:
+ with self.subTest(name=name, message=message):
+ self.assertIn(f"{name}: {message}", diagnostics)
+ self.assertIn("Social preview PNG is missing", diagnostics)
+
+ # Changing the indexable set would also invalidate the sitemap.
+ example = site / "examples/notes-electron/index.html"
+ source = example.read_text()
+ self.assertIn('content="noindex"', source)
+ example.write_text(source.replace('content="noindex"', 'content="index"', 1))
+ self.assertIn(f"{example.relative_to(site).as_posix()}: example application must have a head noindex directive", VERIFY.check_site(site)[3])
class WebsiteMaintenanceChecks(unittest.TestCase):
@@ -541,16 +538,18 @@ class WebsiteMaintenanceChecks(unittest.TestCase):
page = site / "faq/index.html"
original = page.read_text()
cases = (
- ('Broken', "missing local target"),
- ('https://rea.tools/guides/native/#deleted', "missing HTML fragment"),
- ('https://morluto.github.io/rea/examples/notes-web/', "obsolete website URL"),
- ('', "missing copy target"),
- ('Malformed', "invalid URL"),
+ ('Broken', "missing local target: https://rea.tools/deleted/"),
+ ('https://rea.tools/guides/native/#deleted', "missing HTML fragment: https://rea.tools/guides/native/#deleted"),
+ ('https://morluto.github.io/rea/examples/notes-web/', "obsolete website URL: https://morluto.github.io/rea/examples/notes-web/"),
+ ('', "missing copy target: deleted"),
+ ('Malformed', "invalid URL 'https://[':"),
)
- for inserted, message in cases:
+ inserted = "".join(html for html, _ in cases)
+ page.write_text(original.replace("", inserted + "", 1))
+ diagnostics = "\n".join(VERIFY.check_site(site)[3])
+ for _, message in cases:
with self.subTest(message=message):
- page.write_text(original.replace("", inserted + "", 1))
- self.assertTrue(any(message in error for error in VERIFY.check_site(site)[3]))
+ self.assertIn(f"{page.relative_to(site)}: {message}", diagnostics)
def test_repository_links_preserve_targets_and_containment_through_aliased_roots(self):
with tempfile.TemporaryDirectory() as directory:
diff --git a/website/worker.test.mjs b/website/worker.test.mjs
index 89956bc92e..58337bd02c 100644
--- a/website/worker.test.mjs
+++ b/website/worker.test.mjs
@@ -2,12 +2,11 @@ import assert from "node:assert/strict";
import { test } from "node:test";
import worker from "./worker.mjs";
-function assets({ markdownStatus = 200, requests } = {}) {
+function assets({ markdownStatus = 200 } = {}) {
return {
ASSETS: {
async fetch(request) {
const url = new URL(request.url);
- requests?.push(url.pathname);
const markdown = url.pathname.endsWith("index.md");
if (url.pathname === "/missing/")
return new Response("Missing", { status: 404 });
@@ -106,18 +105,16 @@ await test("HEAD and validators use the selected representation", async () => {
});
await test("missing Markdown keeps HTML, and asset redirects and missing routes survive", async () => {
- const requests = [];
const html = await worker.fetch(
new Request("https://rea.tools/guide/", {
headers: { Accept: "text/markdown" },
}),
- assets({ markdownStatus: 404, requests }),
+ assets({ markdownStatus: 404 }),
);
assert.equal(html.status, 200);
assert.equal(html.headers.get("Content-Type"), "text/html");
assert.equal(html.headers.get("ETag"), '"html"');
assert.equal(await html.text(), "