exporter: convert NOT_CHANGED_SINCE epoch to ISO on passthrough; set to now on re-serialize

This commit is contained in:
c0dev0id
2026-07-13 20:36:47 +02:00
parent d79599ede1
commit d8e6e7a02c
2 changed files with 38 additions and 1 deletions

View File

@@ -542,6 +542,23 @@ ok('new bar has _meta with BPM', newBarPatched.includes('beats_per_minute: 120')
ok('new bar appended as extra document', (newBarPatched.match(/\n---\n/g) ?? []).length === 3);
ok('new bar logged as changed', newBarLog.some(e => e.level === 'changed' && e.path === 'bar / 001P1L1M3'));
// ── NOT_CHANGED_SINCE epoch → ISO conversion ──────────────────────────────
section('NOT_CHANGED_SINCE: epoch converted on passthrough, now on re-serialize');
const ncsScore = `instrument linked/pi:\n NOT_CHANGED_SINCE: 1710000000.0\n character:\n A: "1:0,10;1,0"\n\ninstrument embedded:\n NOT_CHANGED_SINCE: 1710000000.0\n character:\n A: "1:0,5;1,0"\n`;
const ncsList = [
{ name: 'linked/pi', isLinked: true, _modified: false, notChangedSince: 1710000000.0,
variations: [], basicProperties: null, volumes: null, timbre: null, fmModulations: [], amModulations: [] },
{ name: 'embedded', isLinked: false, _modified: true, notChangedSince: 1710000000.0,
variations: [], basicProperties: null, volumes: null, timbre: null, fmModulations: [], amModulations: [] },
];
const { text: ncsPatched } = patchScore(ncsScore, ncsList);
const ISO_RX = /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/;
const ncsLines = ncsPatched.split('\n');
const linkedNCS = ncsLines.find(l => /NOT_CHANGED_SINCE/.test(l) && ncsLines.indexOf(l) < ncsLines.findIndex(l2 => /instrument embedded/.test(l2)));
const embeddedNCS = ncsLines.find((l, i) => /NOT_CHANGED_SINCE/.test(l) && i > ncsLines.findIndex(l2 => /instrument embedded/.test(l2)));
ok('linked passthrough: epoch converted to ISO date', linkedNCS && ISO_RX.test(linkedNCS) && !linkedNCS.includes('1710000000'));
ok('modified instrument: NOT_CHANGED_SINCE set to now', embeddedNCS && ISO_RX.test(embeddedNCS) && !embeddedNCS.includes('1710000000'));
// ── patchScore deleted instrument ─────────────────────────────────────────
section('patchScore deleted instrument');
const delInstrScore = `instrument alpha:\n character:\n A: "1:0,10;1,0"\n\ninstrument ki:\n character:\n A: "1:0,5;1,0"\n`;