import test from 'node:test'; import assert from 'node:assert/strict'; import {patchAccountBinding} from '../../scripts/deploy-account-binding.mjs'; const base=` function attachWorkshopHandlers(app){const meta={attribution:{participantName:p.participant.name,participantKey:'x'}};} async function runDatabaseFunction(name,request,response,DATA,confirmationHtml){ if(name==='ksfConfirmationPage'){ return response.type('html').send(confirmationHtml); } const actor=await app.authenticate(request.headers); return response.json({result:await app.dispatch(name,{},actor)}); } async function handler(request,response){return runDatabaseFunction("ksfStartWorkshopSession",request,response,{},'');} `; test('补丁保留现网独立包装,只添加账号关联模块;不带入其他bootstrap调用',()=>{ const code=patchAccountBinding(base); assert.ok(code.includes("attachAccountBindingHandlers(app,{store,settings});")); assert.ok(!code.includes('attachBoardActionHandlers(app'));assert.ok(!code.includes('attachMemberGroupHandlers(app')); assert.ok(code.includes("accountProfileKey:p.participant.key"));assert.equal(patchAccountBinding(code),code); new Function(code); }); test('缺少精确补丁锚点时在任何远程写入前停止',()=>{ assert.throws(()=>patchAccountBinding(base.replace("if(name==='ksfConfirmationPage')", "if(name==='another')")),/BASELINE/); });