import assert from 'node:assert/strict'; import { readFile, access } from 'node:fs/promises'; import test from 'node:test'; test('the production package does not contain runtime data or authentication secrets', async () => { await assert.rejects(access('.next/standalone/data/auth-secret')); await assert.rejects(access('.next/standalone/data/portfolio.sqlite')); await assert.rejects(access('.next/standalone/.env')); }); test('Next runs as a standalone server with the image optimizer enabled', async () => { const [config, packageJson] = await Promise.all([ readFile('next.config.mjs', 'utf8'), readFile('package.json', 'utf8').then(JSON.parse), ]); assert.match(config, /output:\s*['"]standalone['"]/); assert.doesNotMatch(config, /unoptimized:\s*true/); assert.match(config, /formats:\s*\[['"]image\/webp['"]\]/); assert.match(config, /qualities:\s*\[60,\s*75,\s*85\]/); assert.ok(packageJson.dependencies.sharp, 'sharp must be a direct production dependency'); }); test('the blocking loader and eager preload manifest are removed', async () => { const [root, page] = await Promise.all([ readFile('src/app/SiteRoot.tsx', 'utf8'), readFile('src/app/PortfolioPage.tsx', 'utf8'), ]); assert.doesNotMatch(root, /siteLoading|site-loader/); assert.doesNotMatch(page, /SiteLoader/); }); test('Three.js is only imported by the deferred scene implementation', async () => { const [boundary, scene] = await Promise.all([ readFile('src/components/scenes/DeferredAboutRiverScene.tsx', 'utf8'), readFile('src/components/scenes/AboutRiverScene.tsx', 'utf8'), ]); assert.doesNotMatch(boundary, /from ['"]three['"]/); assert.match(boundary, /import\(['"].\/AboutRiverScene['"]\)/); assert.match(boundary, /rootMargin:\s*['"]600px/); assert.match(scene, /from ['"]three['"]/); }); test('local font loading replaces remote CSS imports and TTF delivery', async () => { const [root, css] = await Promise.all([ readFile('src/app/SiteRoot.tsx', 'utf8'), readFile('src/styles/globals.css', 'utf8'), ]); assert.match(root, /localFont/); assert.doesNotMatch(css, /fonts\.googleapis\.com|@font-face|IRANYekanXVF\.ttf/); });