const { test } = require('node:test') const assert = require('node:assert/strict') const fs = require('node:fs') const os = require('node:os') const path = require('node:path') const { mergeAssets } = require('./preserve_frontend_assets.cjs') test('keeps old lazy chunks without replacing current build files', () => { const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'assets-test-')) try { const old = path.join(dir, 'old'), current = path.join(dir, 'current') fs.mkdirSync(old); fs.mkdirSync(current) fs.writeFileSync(path.join(old, 'Agent-oldhash.js'), 'old import') fs.writeFileSync(path.join(old, 'shared.css'), 'old style') fs.writeFileSync(path.join(current, 'shared.css'), 'current style') assert.equal(mergeAssets(old, current), 1) assert.equal(fs.readFileSync(path.join(current, 'Agent-oldhash.js'), 'utf8'), 'old import') assert.equal(fs.readFileSync(path.join(current, 'shared.css'), 'utf8'), 'current style') assert.equal(mergeAssets(old, current), 0) } finally { fs.rmSync(dir, { recursive: true, force: true }) } })