Add Zola templates and browser-tested site scaffold

This commit is contained in:
ms2k 2026-09-15 19:30:08 +09:00
commit a33673243e
5 changed files with 2114 additions and 0 deletions

8
tests/listing.md Normal file
View file

@ -0,0 +1,8 @@
+++
title = "Lorem ipsum"
description = "A list entry with a thumbnail."
date = 2026-09-14
[extra]
thumbnail = "/thumbnail.jpg"
+++
Lorem ipsum dolor sit amet.

172
tests/pages.cjs Normal file
View file

@ -0,0 +1,172 @@
const assert = require("node:assert/strict");
const { Buffer } = require("node:buffer");
const { encode } = require("@msgpack/msgpack");
const { chromium } = require(process.env.PLAYWRIGHT_PATH || "playwright");
const base = process.env.SITE_URL || "http://127.0.0.1:18790";
const endpoint = "https://health.quorate.dev/health";
const paths = ["/", "/about/", "/blog/", "/404.html", "/blog/specimen/"];
const days = Array(30).fill(1);
days[1] = null;
days[2] = 23 / 24;
days[3] = 0;
const snapshot = [
1786838400,
[
["Nodes", [{ node: "one" }, { node: "two" }], [days, days]],
["Public services", [{ service: "code" }], [days]],
],
];
function mockHealth(route, mode) {
if (mode === "connectionrefused") {
return route.abort("connectionrefused");
}
return route.fulfill({
status: mode === "503" ? 503 : 200,
contentType: "application/msgpack",
body: Buffer.from(encode(snapshot)),
});
}
async function checkWidth(page) {
assert.equal(
await page.evaluate(
() => document.documentElement.scrollWidth <= innerWidth,
),
true,
);
}
async function checkHealth(page, width, mode) {
await page.route(endpoint, (route) => mockHealth(route, mode));
await page.goto(`${base}/up/`);
await page.waitForFunction(
() => document.documentElement.dataset.ready === "true",
);
const healthy = mode === "healthy";
assert.equal(await page.locator(".bar").count(), healthy ? 90 : 0);
assert.equal(
await page.locator(".controls").isVisible(),
healthy && width <= 600,
);
if (healthy) {
assert.match(
await page.locator(".health-group h2").first().textContent(),
/Public services/,
);
await page.locator(".bar").nth(2).click();
assert.match(await page.locator("#detail").textContent(), /95\.83%/);
} else {
assert.equal(await page.locator("#observed").textContent(), "No data");
}
await checkWidth(page);
await page.unroute(endpoint);
}
async function checkLayout(page) {
assert.equal(await page.locator("header nav a").count(), 4);
assert.equal(await page.locator("h1").count(), 1);
assert.equal(
await page
.locator("body")
.evaluate((node) => getComputedStyle(node).fontSize),
"16px",
);
assert.equal(
await page
.locator("h1")
.evaluate((node) => getComputedStyle(node).fontSize),
"24px",
);
assert.equal(
await page
.locator(".shell")
.evaluate((node) => getComputedStyle(node).maxWidth),
"704px",
);
await checkWidth(page);
}
async function checkBlog(page) {
assert.equal(await page.locator(".posts li").count(), 2);
assert.equal(await page.locator(".posts h2").count(), 2);
assert.equal(await page.locator(".posts p").count(), 2);
assert.equal(await page.locator(".posts img").count(), 1);
}
async function checkPost(page) {
await page.locator(".mermaid svg").waitFor();
await page.locator("mjx-container").waitFor();
assert.equal(await page.locator("blockquote").count(), 1);
assert.equal(await page.locator("table").count(), 1);
}
async function checkPage(page, path) {
await page.goto(`${base}${path}`);
await checkLayout(page);
switch (path) {
case "/about/":
assert.equal(await page.locator("article p").textContent(), "WIP");
break;
case "/blog/":
await checkBlog(page);
break;
case "/blog/specimen/":
await checkPost(page);
break;
}
}
async function main() {
const browser = await chromium.launch({
executablePath: process.env.CHROME_PATH,
headless: true,
});
let cases = 0;
try {
for (const width of [320, 390, 768, 1280]) {
for (const colorScheme of ["light", "dark"]) {
const page = await browser.newPage({
viewport: { width, height: 844 },
colorScheme,
});
const errors = [];
page.on("pageerror", (error) => errors.push(error.message));
for (const mode of ["healthy", "503", "connectionrefused"]) {
await checkHealth(page, width, mode);
cases++;
}
for (const path of paths) {
await checkPage(page, path);
cases++;
}
assert.deepEqual(errors, []);
await page.close();
}
}
console.log(`PASS: ${cases} page and health cases`);
} finally {
await browser.close();
}
}
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});

11
tests/render.sh Normal file
View file

@ -0,0 +1,11 @@
#!/usr/bin/env bash
set -euo pipefail
site_root=$(cd "$(dirname "$0")/.." && pwd)
fixture=$(mktemp -d /tmp/home-check.XXXXXX)
cp -a "$site_root/zola.toml" "$site_root/templates" "$site_root/content" "$site_root/static" "$fixture/"
cp "$site_root/tests/specimen.md" "$fixture/content/blog/specimen.md"
cp "$site_root/tests/listing.md" "$fixture/content/blog/listing.md"
cp "$site_root/tests/thumbnail.jpg" "$fixture/static/thumbnail.jpg"
zola --root "$fixture" build
printf '%s\n' "$fixture/public"

33
tests/specimen.md Normal file
View file

@ -0,0 +1,33 @@
+++
title = "Typography specimen"
description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
date = 2026-09-15
+++
A paragraph with **bold**, *emphasis*, [a link](/about/), and `inline code`.
## Lists
- One
- Two
1. First
1. Second
> A quoted paragraph.
| Column | Value |
| ------- | ----- |
| Example | 23/24 |
```rust
fn main() {
println!("Hello, Quorate.");
}
```
```mermaid
flowchart LR
Page --> API --> Metrics
```
\\[h = 1 - \\frac{1}{24}\\]

BIN
tests/thumbnail.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB