Files
ai_academy/website-docs/homepage/scripts/sync-product-screenshots.test.mjs
T
runny 7ec21f35b0 chore: 初始化仓库,导入项目基线代码
Academy v0.8.3 完整代码基线:Go 后端(internal/cmd/cli/mcp-server/docreader)、
Vue 前端(frontend)、数据库迁移(migrations)、部署编排(docker/helm/deploy)与文档。
今日开发的培训推送管理改动随后单独提交。
2026-11-16 18:12:23 +08:00

28 lines
1.6 KiB
JavaScript

import assert from 'node:assert/strict';
import { mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { test } from 'node:test';
import { syncProductScreenshots } from './sync-product-screenshots.mjs';
test('refreshes changed source images and aliases without replacing homepage-only assets', t => {
const root = mkdtempSync(join(tmpdir(), 'academy-shots-'));
t.after(() => rmSync(root, { recursive: true, force: true }));
const source = join(root, 'source');
const destination = join(root, 'product');
mkdirSync(source);
mkdirSync(destination);
writeFileSync(join(source, 'wiki-graph-groups.png'), 'new graph');
writeFileSync(join(source, 'sandbox-panel-terminal.png'), 'new terminal');
writeFileSync(join(destination, 'wiki-graph-groups.png'), 'old graph');
writeFileSync(join(destination, 'sandbox-terminal.png'), 'old terminal');
writeFileSync(join(destination, 'homepage-only.png'), 'keep this');
assert.equal(syncProductScreenshots(source, destination), 2);
assert.equal(readFileSync(join(destination, 'wiki-graph-groups.png'), 'utf8'), 'new graph');
assert.equal(readFileSync(join(destination, 'sandbox-terminal.png'), 'utf8'), 'new terminal');
assert.equal(readFileSync(join(destination, 'homepage-only.png'), 'utf8'), 'keep this');
writeFileSync(join(source, 'wiki-graph-groups.png'), 'updated graph again');
syncProductScreenshots(source, destination);
assert.equal(readFileSync(join(destination, 'wiki-graph-groups.png'), 'utf8'), 'updated graph again');
});