Exact reviewed source / 62 of 64
review/test_csv.mjs
SHA-256 of original bytes
931d1315cf28e5a86a16ac1a46bf1fcaed4604b483314e5cb6ff0ee80f6ca1b7
// Execute the exact shipped CSV exporter with synthetic state and capture the bytes.
// This validates emitted data, not behavior in every spreadsheet application.
import fs from 'node:fs/promises';
import {createHash} from 'node:crypto';
const source=await fs.readFile(new URL('../prototype/public/app.js',import.meta.url),'utf8');
const begin=source.indexOf(' function exportCSV() {'),end=source.indexOf('\n function exportCurrent()',begin);
if(begin<0||end<0)throw new Error('Could not isolate actual CSV exporter.');
const prefixes=['=1+1','+SUM(1,2)','-1+3','@SUM(1,2)','\t=2+2','\r=2+2',' \n =2+2','Ordinary "quoted", text','<img src=x onerror="globalThis.__triage_xss=8">'];
const issues=prefixes.map((title,i)=>({id:i+1,title,body:prefixes[(i+1)%prefixes.length],labels:['existing','a,b','"quoted"']}));
let output;
new Function('state','downloadFile','notify',source.slice(begin,end)+'\nexportCSV();')({busy:false,currentIssues:issues,inputDirty:false},(content,type,filename)=>{output={content,type,filename};},()=>{});
await fs.writeFile(new URL('csv_export_capture.csv',import.meta.url),output.content);
const result={method:'Actual shipped exportCSV function invoked with synthetic state; emitted bytes captured without browser or spreadsheet execution.',uiSourceHash:createHash('sha256').update(source).digest('hex'),input:issues,type:output.type,filename:output.filename};
await fs.writeFile(new URL('csv_export_input.json',import.meta.url),JSON.stringify(result,null,2)+'\n');
console.log(JSON.stringify({filename:output.filename,type:output.type,rows:issues.length,bytes:Buffer.byteLength(output.content)}));