From aa8d92646c6b7e8e0abde85111efac6fef75a140 Mon Sep 17 00:00:00 2001 From: Do Siki Date: Wed, 19 Aug 2026 14:30:58 +0200 Subject: [PATCH] test(cms): run-unique markers so a crashed run cannot poison the next The versions integration test asserted against fixed marker strings; if a run crashed before restoring contact.json, the next run read the polluted file as its baseline and its expectations collapsed. Markers now carry a per-run timestamp. --- scripts/test-content-editor-versions.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/test-content-editor-versions.js b/scripts/test-content-editor-versions.js index 9f09feb..54c0a88 100644 --- a/scripts/test-content-editor-versions.js +++ b/scripts/test-content-editor-versions.js @@ -75,10 +75,11 @@ async function main() { try { // Create two saves → two backups of intermediate states + const runId = Date.now(); const v1 = JSON.parse(original); - v1.hero.subtitle = 'Verzió teszt #1'; + v1.hero.subtitle = 'Verzió teszt #1 ' + runId; const v2 = JSON.parse(original); - v2.hero.subtitle = 'Verzió teszt #2'; + v2.hero.subtitle = 'Verzió teszt #2 ' + runId; for (const variant of [v1, v2]) { const res = await fetch(`${BASE}/save?file=contact`, { @@ -120,7 +121,7 @@ async function main() { const backupHoldingV1 = fs.readdirSync(backupDir) .filter(name => name.startsWith('contact.')) .filter(name => fs.statSync(path.join(backupDir, name)).mtimeMs >= testStartedAt) - .find(name => fs.readFileSync(path.join(backupDir, name), 'utf8').includes('Verzió teszt #1')); + .find(name => fs.readFileSync(path.join(backupDir, name), 'utf8').includes('Verzió teszt #1 ' + runId)); assert.ok(backupHoldingV1, 'seeded backup holding v1 must exist'); const diffPage = await (await fetch(`${BASE}/versions?file=contact&show=${backupHoldingV1}`, { headers: { Cookie: cookie } })).text(); @@ -134,7 +135,7 @@ async function main() { headers: { Cookie: cookie, 'X-CSRF-Token': csrf }, }); assert.equal(restore.status, 200); - assert.ok(fs.readFileSync(contentFile, 'utf8').includes('Verzió teszt #1')); + assert.ok(fs.readFileSync(contentFile, 'utf8').includes('Verzió teszt #1 ' + runId)); // restore created a new backup of the pre-restore state (reversibility) const afterPage = await (await fetch(`${BASE}/versions?file=contact`, { headers: { Cookie: cookie } })).text();