import assert from 'node:assert/strict'; import { createHash } from 'node:crypto'; import { execFileSync } from 'node:child_process'; import { mkdtempSync, readFileSync, statSync } from 'node:fs'; import { tmpdir } from 'node:os'; import { join, resolve } from 'node:path'; const root = resolve(import.meta.dirname, '../..'); const output = mkdtempSync(join(tmpdir(), 'easyai-reference-images-')); execFileSync('node', [join(root, 'scripts/acceptance/generate-reference-images.mjs'), output]); const hashes = new Set(); for (let index = 1; index <= 3; index += 1) { const path = join(output, `production-acceptance-reference-${index}.png`); const payload = readFileSync(path); assert.deepEqual([...payload.subarray(0, 8)], [137, 80, 78, 71, 13, 10, 26, 10]); assert.equal(payload.readUInt32BE(16), 512); assert.equal(payload.readUInt32BE(20), 512); assert.equal(statSync(path).mode & 0o777, 0o600); hashes.add(createHash('sha256').update(payload).digest('hex')); } assert.equal(hashes.size, 3);