support-requests-release.test.mjs 1.2 KB

12345678910111213141516
  1. import {test} from 'node:test';
  2. import assert from 'node:assert/strict';
  3. import {patchSupportRequests} from '../deploy-support-requests.mjs';
  4. 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}";
  5. test('scoped patch preserves every byte of the baseline outside the new dispatch/helper',()=>{
  6. const after=patchSupportRequests(before);
  7. assert.ok(after.includes('// online-only fix must remain'));
  8. assert.ok(after.includes("if(operation==='ops/existing') return existing();"));
  9. 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);
  10. assert.equal(patchSupportRequests(after),after);
  11. });
  12. test('refuses missing or ambiguous anchors and conflicting existing implementations',()=>{
  13. assert.throws(()=>patchSupportRequests('async function handler(){}'),/不一致/);
  14. assert.throws(()=>patchSupportRequests(before+before),/不一致/);
  15. assert.throws(()=>patchSupportRequests(before+'\n// ops/support-requests/list'),/不同版本/);
  16. });