| 1234567891011121314151617181920212223242526272829303132 |
- import assert from 'node:assert/strict';
- import fs from 'node:fs';
- import { execFileSync } from 'node:child_process';
- const baseline = 'e84a62e17e2f4cbd985968d716361e3bbd6d0f87';
- const before = JSON.parse(execFileSync('git', ['show', `${baseline}:src/content/blog/articles.json`], { encoding: 'utf8' }));
- const after = JSON.parse(fs.readFileSync('src/content/blog/articles.json', 'utf8'));
- const key = a => `${a.locale}/${a.id}`;
- const links = body => [...body.matchAll(/\]\(([^)\s]+)\)/g)].map(m => m[1]).sort();
- const newDenmarkSource = 'https://visa.vfsglobal.com/one-pager/denmark/Ireland/english/';
- assert.equal(after.length, 21);
- assert.deepEqual(after.map(key).sort(), before.map(key).sort());
- for (const article of after) {
- const original = before.find(a => key(a) === key(article));
- const { body: oldBody, sources: oldSources, ...oldFields } = original;
- const { body, sources, ...fields } = article;
- assert.deepEqual(fields, oldFields, `${key(article)} changed protected metadata`);
- assert.equal((body.match(/^## /gm) || []).length, 7, 'Retain seven main sections');
- const denmark = article.id === 'denmark-appointment-booking';
- assert.deepEqual(links(body), [...links(oldBody), ...(denmark ? [newDenmarkSource] : [])].sort(), `${key(article)} changed unapproved links`);
- if (denmark) {
- assert.deepEqual(sources.slice(0, oldSources.length), oldSources);
- assert.equal(sources.length, oldSources.length + 1);
- assert.equal(sources.at(-1).url, newDenmarkSource);
- assert(sources.at(-1).title.trim());
- } else assert.deepEqual(sources, oldSources);
- const visibleText = body.replace(/\]\([^)]+\)/g, ']');
- assert(!/text\.skin/i.test(visibleText), 'Brand copy must use Strata; URL destinations remain unchanged');
- assert(/\[Strata\b|\bStrata\b/.test(visibleText), 'Missing Strata service invitation');
- assert(!/<\/?(?:script|iframe|html|body)\b/i.test(body), 'Unsafe HTML');
- }
- console.log('PASS: 21 records; exact titles/metadata; seven H2s; existing URLs/sources preserved except the approved added Denmark source; Strata brand copy. Refund meaning, removed recommendations and Denmark sequencing require independent editorial review.');
|