Skip to content

Turn any idea, plan, or codebase into a beautiful interactive diagram. An agent skill for Claude Code, Codex, and more.

test(website): keep Cloudflare fixtures aligned with published routes

tt-a1i95e44ce4143f
diff --git a/test/cloudflare-output.test.mjs b/test/cloudflare-output.test.mjs
index 8f933b1c..71109a1b 100644
--- a/test/cloudflare-output.test.mjs
+++ b/test/cloudflare-output.test.mjs
@@ -3,12 +3,13 @@ import assert from 'node:assert/strict';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
+import { canonicalPath, sitePages } from '../website/src/data/site-urls.mjs';
import { checkCloudflareOutput } from '../website/scripts/check-cloudflare-output.mjs';
function fixture(t) {
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-cloudflare-output-'));
t.after(() => fs.rmSync(root, { recursive: true, force: true }));
- const names = ['index', 'gallery', 'guide', 'start', 'community', 'zh', 'zh/gallery', 'zh/guide', 'zh/start', 'zh/community'];
+ const names = sitePages.flatMap(page => ['en', 'zh'].map(lang => canonicalPath(page, lang).slice(1) || 'index'));
const urls = names.map(name => `https://archify.si/${name === 'index' ? '' : name}`);
for (const [index, name] of names.entries()) {
fs.mkdirSync(path.dirname(path.join(root, `${name}.html`)), { recursive: true });
@@ -27,7 +28,7 @@ function fixture(t) {
}
test('Cloudflare output accepts static files and extensionless canonical routes', t => {
- assert.equal(checkCloudflareOutput(fixture(t)), 11);
+ assert.equal(checkCloudflareOutput(fixture(t)), sitePages.length * 2 + 1);
});
test('Cloudflare output rejects a missing 404 before implicit SPA fallback can ship', t => {
@@ -60,7 +61,19 @@ test('Cloudflare output rejects an asset exceeding the Pages upload limit', t =>
test('Cloudflare output resolves nested-page assets against the HTML base', t => {
const root = fixture(t);
fs.appendFileSync(path.join(root, 'zh/guide.html'), '<base href="../"><link href="site.css" rel="stylesheet">');
- assert.equal(checkCloudflareOutput(root), 11);
+ assert.equal(checkCloudflareOutput(root), sitePages.length * 2 + 1);
fs.rmSync(path.join(root, 'site.css'));
assert.throws(() => checkCloudflareOutput(root), /missing local target site\.css/);
});
+
+for (const route of ['agent-diagrams', 'zh/agent-diagrams']) {
+ test(`Cloudflare output rejects a missing ${route} article`, t => {
+ const root = fixture(t);
+ fs.rmSync(path.join(root, `${route}.html`));
+ assert.throws(() => checkCloudflareOutput(root), error => {
+ assert.equal(error.code, 'ENOENT');
+ assert.equal(error.path, path.join(root, `${route}.html`));
+ return true;
+ });
+ });
+}
diff --git a/website/package.json b/website/package.json
index bdb236e0..f3c6530f 100644
--- a/website/package.json
+++ b/website/package.json
@@ -11,7 +11,7 @@
"build": "node scripts/stage-public.mjs && astro build",
"preview": "astro preview",
"check": "astro check",
- "test": "node --test test/*.test.mjs",
+ "test": "node --test test/*.test.mjs ../test/cloudflare-output.test.mjs",
"test:browser": "node --test --test-name-pattern=\"real Chrome\" ../test/site-language-continuity.test.mjs test/community-browser.test.mjs test/homepage-browser.test.mjs test/agent-diagrams-browser.test.mjs"
},
"dependencies": {