import {test} from 'node:test'; import assert from 'node:assert/strict'; import {patchSupportRequests} from '../deploy-support-requests.mjs'; const before="// online-only fix must remain\nasync function handler(){\n if(operation==='ops/live/versions') return live();\n if(operation==='ops/existing') return existing();\n}"; test('scoped patch preserves every byte of the baseline outside the new dispatch/helper',()=>{ const after=patchSupportRequests(before); assert.ok(after.includes('// online-only fix must remain')); assert.ok(after.includes("if(operation==='ops/existing') return existing();")); assert.equal(after.replace(" if(operation==='ops/support-requests/list') return response.json({success:true,data:await supportRequestsPage(context,input)});\n",'').split('\n// Both mobile roles')[0],before); assert.equal(patchSupportRequests(after),after); }); test('refuses missing or ambiguous anchors and conflicting existing implementations',()=>{ assert.throws(()=>patchSupportRequests('async function handler(){}'),/不一致/); assert.throws(()=>patchSupportRequests(before+before),/不一致/); assert.throws(()=>patchSupportRequests(before+'\n// ops/support-requests/list'),/不同版本/); });