From a98e62e037927b17a6939f9ef57a022552c5f73b Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 23 Oct 2026 10:22:17 +0000 Subject: [PATCH] Add validation tests for static site build and assets - Added a test in `test/build.test.mjs` to verify static asset links, metadata tags, and syntax valid HTML/CSS outputs. - Checks presence of required meta tags and structural HTML elements. - Basic check for CSS validation (balanced curly braces). - Checks all internal links (both `href` and `src`) resolve to an existing valid file or directory (with index.html). Co-authored-by: teddashh <233386770+teddashh@users.noreply.github.com> --- test/build.test.mjs | 82 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 80 insertions(+), 2 deletions(-) diff --git a/test/build.test.mjs b/test/build.test.mjs index 6c410cc..b516033 100644 --- a/test/build.test.mjs +++ b/test/build.test.mjs @@ -1,8 +1,8 @@ import test from 'node:test'; import assert from 'node:assert/strict'; -import { cp, mkdtemp, readFile, readdir, rm, writeFile } from 'node:fs/promises'; +import { cp, mkdtemp, readFile, readdir, rm, writeFile, stat } from 'node:fs/promises'; import { tmpdir } from 'node:os'; -import { join } from 'node:path'; +import { join, dirname } from 'node:path'; import { execFile } from 'node:child_process'; import { promisify } from 'node:util'; import { renderDirectory } from '../src/index.mjs'; @@ -44,3 +44,81 @@ test('actual valid build preserves both rendered artifacts', async (t) => { assert.equal(await readFile(join(root, 'dist/index.html'), 'utf8'), renderDirectory(directory)); assert.equal(await readFile(join(root, 'dist', privacy.path, 'index.html'), 'utf8'), renderPrivacyPage(privacy)); }); + +test('static site build validates metadata, syntax, and internal assets', async (t) => { + const { root, privacy, build } = await fixture(t); + await build(); + + const pages = [ + { path: 'dist/index.html', dir: 'dist' }, + { path: join('dist', privacy.path, 'index.html'), dir: join('dist', privacy.path) } + ]; + + for (const page of pages) { + const html = await readFile(join(root, page.path), 'utf8'); + + // Metadata tags + assert.match(html, //); + assert.match(html, //); + assert.match(html, //); + + // Basic HTML syntax + assert.match(html, /^/i); + assert.match(html, //); + assert.match(html, /[\s\S]*<\/head>/i); + assert.match(html, /