import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import test from 'node:test';
import { expandHtmlPartials, htmlPartialsPlugin } from '../scripts/html-partials-plugin.ts';
const distIndexPath = path.resolve('dist/index.html');
// Why: the plugin only runs at build time, so these assertions must inspect the
// deployable artifact instead of the source document.
const distHtml = fs.readFileSync(distIndexPath, 'utf-8');
function findMetaByProperty(html, property) {
return [...html.matchAll(/]*>/gi)]
.map((match) => match[0])
.find((tag) => tag.toLowerCase().includes(`property="${property}"`));
}
function extractHeaderMarkup(html) {
const headerMarkup = html.match(//i)?.[0];
assert.ok(headerMarkup, 'Built HTML must contain an expanded header partial');
return headerMarkup;
}
function findDisclosureButton(headerMarkup) {
const disclosureButton = [...headerMarkup.matchAll(/