/** * Smoke test verification for index.astro * Checks that the built HTML contains expected elements for the foundation smoke test page. */ import { readFileSync } from 'fs'; import { resolve, dirname } from 'path'; import { fileURLToPath } from 'url'; const __dirname = dirname(fileURLToPath(import.meta.url)); const distPath = resolve(__dirname, '../dist/index.html'); let html; try { html = readFileSync(distPath, 'utf-8'); } catch (e) { console.error('FAIL: dist/index.html not found. Run `npm run build` first.'); process.exit(1); } let passed = 0; let failed = 0; function assert(condition, description) { if (condition) { console.log(` PASS: ${description}`); passed++; } else { console.error(` FAIL: ${description}`); failed++; } } console.log('Verifying smoke test page (dist/index.html):\n'); // 1. Imports: BaseLayout structure present assert(html.includes(''), 'BaseLayout renders DOCTYPE'); assert(html.includes(''), 'BaseLayout renders html lang=en'); assert(html.includes('Skip to content'), 'BaseLayout includes skip link'); // 2. NavBar rendered assert(html.includes('aria-label="Site navigation"'), 'NavBar is rendered'); assert(html.includes('Crash Test Dev'), 'NavBar shows site name'); assert(html.includes('Posts'), 'NavBar shows Posts link'); // 3. PostHeader with correct props assert(html.includes('Speeding Up Webpack Typescript Incremental Builds by 7x'), 'PostHeader title present'); assert(html.includes('August 16, 2019'), 'PostHeader formatted date present'); assert(html.includes('12 min read'), 'PostHeader reading time present'); assert(html.includes('post') || html.includes('POST'), 'PostHeader badge type present'); // 4. Three typography voices in body // Prose voice: Source Serif 4 / font-prose, 18px assert( html.includes('font-prose') || html.includes('Source Serif'), 'Prose voice paragraph uses font-prose (Source Serif 4)' ); // Structure voice: Inter / font-structure, 14px, secondary color assert( html.includes('font-structure') || html.includes('Inter'), 'Structure voice paragraph uses font-structure (Inter)' ); // Evidence voice: JetBrains Mono / font-evidence, code-text color, surface-code bg assert( html.includes('font-evidence') || html.includes('JetBrains Mono'), 'Evidence voice uses font-evidence (JetBrains Mono)' ); // 5. Evidence voice styling details assert( html.includes('code-text') || html.includes('--code-text'), 'Evidence voice uses code-text color' ); assert( html.includes('surface-code') || html.includes('--surface-code'), 'Evidence voice uses surface-code background' ); assert( html.includes('accent-primary') || html.includes('--accent-primary'), 'Evidence voice has accent-primary left border' ); assert( html.includes('rounded-md') || html.includes('--rounded-md'), 'Evidence voice has rounded-md border radius' ); console.log(`\nResults: ${passed} passed, ${failed} failed out of ${passed + failed}`); if (failed > 0) { process.exit(1); } console.log('\nAll smoke test verifications passed!');