import test from 'node:test'; import assert from 'node:assert/strict'; import { mkdtemp, cp, readFile, writeFile, rm } from 'node:fs/promises'; import { tmpdir } from 'node:os'; import { join } from 'node:path'; import { execFileSync } from 'node:child_process'; // Exercise the real renderer and both supported templates in an isolated project. test('image opening is opt-in per carousel and survives ordinary model rendering', async t => { const root = await mkdtemp(join(tmpdir(), 'nodedc-carousel-')); t.after(() => rm(root, { recursive: true, force: true })); for (const path of ['tools', 'templates', 'content', 'assets/uploads/optimized']) await cp(new URL('../'+path, import.meta.url), join(root,path), {recursive:true}); const modelPath = join(root, 'content/pages/home.json'); const page = JSON.parse(await readFile(modelPath, 'utf8')); const galleries = page.regions.flatMap(r=>r.blocks).filter(b=>b.content?.sliderItems); assert.equal(galleries.length, 4); const render = async () => { await writeFile(modelPath, JSON.stringify(page)); execFileSync(process.execPath, ['tools/render-home.mjs'], {cwd:root}); return await readFile(join(root, 'index.html'),'utf8'); }; const count = (html, pattern) => [...html.matchAll(pattern)].length; const baseline = await render(); assert.equal(count(baseline, /— открыть изображение/g), 0); const mediaCount = count(baseline, /class="carousel-media"/g); const videoCount = count(baseline, /