import test from 'node:test';
import assert from 'node:assert/strict';
import fs from 'node:fs';
import { renderNotFound } from '../src/seo.js';
const template = fs.readFileSync(new URL('../public/404.html', import.meta.url), 'utf8');
const page = renderNotFound({
template,
baseUrl: 'https://memes.example',
pathname: '/missing-node'
});
const styles = fs.readFileSync(new URL('../public/assets/styles.css', import.meta.url), 'utf8');
const artwork = fs.readFileSync(new URL('../public/assets/homo-reseticus-404.png', import.meta.url));
test('404 page is noindexed and links visitors back to the live feed', () => {
assert.match(page, /
404 \| The Meme Protocol<\/title>/);
assert.match(page, //);
assert.match(page, /class="primary-action not-found-action" href="\/"/);
assert.doesNotMatch(page, /PAGE_NOT_FOUND/);
assert.doesNotMatch(page, /THE_REQUESTED_NODE_DOES_NOT_EXIST/);
});
test('404 page carries adjusted site discovery and social metadata', () => {
assert.match(page, //);
assert.match(page, //);
assert.match(page, /]+href="\/openapi\.json">/);
assert.match(page, /]+href="\/meme-api\.skill\.md">/);
assert.match(page, //);
assert.match(page, //);
assert.match(page, //);
assert.doesNotMatch(page, / {
assert.match(page, /class="status-line"/);
assert.match(page, />DOWNLOAD PET<\/a>/);
assert.match(page, />READ LORE<\/a>/);
assert.match(page, /ERROR_404 \/\/ NODE_UNREACHABLE/);
});
test('404 page uses the supplied artwork with a diffused backdrop', () => {
assert.match(page, /src="\/assets\/homo-reseticus-404\.png"/);
assert.match(page, /alt="Homo Reseticus surrounded by an unreachable node pattern"/);
assert.match(styles, /\.not-found-visual::before/);
assert.match(styles, /radial-gradient\(/);
assert.match(styles, /filter: blur\(36px\)/);
assert.match(styles, /transform: scale\(1\.24\)/);
assert.match(styles, /\.not-found-page \.pulse/);
assert.equal(artwork.subarray(1, 4).toString('ascii'), 'PNG');
});