/** * Intégration : sync-portal sur un dépôt minimal (TALKS_ROOT) sans toucher au vrai portail. */ import { test } from 'node:test' import assert from 'node:assert' import fs from 'node:fs' import os from 'node:os' import path from 'node:path' import { fileURLToPath } from 'node:url' import { spawnSync } from 'node:child_process' const __dirname = path.dirname(fileURLToPath(import.meta.url)) const repoRoot = path.resolve(__dirname, '..') test('sync sur dépôt temporaire (TALKS_ROOT)', () => { const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'talks-tmp-')) fs.mkdirSync(path.join(tmp, 'portal'), { recursive: true }) fs.writeFileSync( path.join(tmp, 'portal', 'index.md'), ['---', 'layout: doc', '---', '', '', '', ''].join('\n'), ) const hello = path.join(tmp, 'slides', 'hello-world') fs.mkdirSync(hello, { recursive: true }) fs.writeFileSync( path.join(hello, 'meta.json'), JSON.stringify({ title: 'Hello World', description: 'Test tmp', order: 1, featured: true, }), ) fs.writeFileSync(path.join(hello, 'slides.md'), '---\n---\n\n# Slide\n') const r = spawnSync(process.execPath, [path.join(repoRoot, 'tools', 'sync-portal.mjs')], { cwd: repoRoot, env: { ...process.env, TALKS_ROOT: tmp }, encoding: 'utf8', }) assert.strictEqual(r.status, 0, r.stderr || r.stdout) const detail = path.join(tmp, 'portal', 'presentations', 'hello-world', 'index.md') assert.ok(fs.existsSync(detail), 'fiche générée') const body = fs.readFileSync(detail, 'utf8') assert.ok(body.includes('Hello World')) assert.ok(body.includes('