debug(swap)+test: 平仓利息 otcdebug 埋点 + 修复3个前端红测试

1) otcdebug 埋点(unwindSwapTrade.js, 仅 ?otcdebug=1 开启, 生产零噪音):
   - changeClosePercent: 记录实际发给后端的 closePercent
   - getInterestList: 记录 POST closePercent / 返回逐腿 InterestMode·Principal·Amount·Rate
   - 用途: 未来再遇"改比例利息腿不动", 开 ?otcdebug=1 即可定位前端没传对还是后端没缩放

2) 修复分支上既有3个红测试(均为配置/生产已改、测试未跟上或契约过时):
   - swapPrecisionConfig.test.js: quantityIntegerDigits 对齐配置(16→8, Bond等12);
     expectedQuantityPrecisions 对齐配置(Fund=4, ExRate=4), 与同文件 line87/89 一致
   - bondCalc.integration.test.js: 补 require('fs')/require('path'); 事件契约更新为
     ['keydown','input','input','enter'](onKeydown 回车故意幂等重发一次 input, 修 QA 高优 Bug)
   - markClosePnlShortConsistency.test.js: 空头一致性测试由 RED 转 GREEN(income 已补 longRatio);
     CASE deliveryPrice 105→1.05 与 GOLD 的 105*scale(0.01) 单位对齐

引入溯源: 固定值腿缩放缺陷见 d1badfe4; 精度配置 16→8 来自 0672dbbc(张名锐);
红测试为已知缺口记录(用户 hjhan)。
This commit is contained in:
hjhan
2026-08-08 12:18:45 +08:00
parent d1badfe48f
commit 68a3f0b4fa
4 changed files with 47 additions and 27 deletions
@@ -13,6 +13,8 @@
* 运行:cd YLErpWeb/fe-tests && npx jest bondCalc.integration
*/
const fs = require('fs');
const path = require('path');
const { JSDOM } = require('jsdom');
const dom = new JSDOM('<!DOCTYPE html><html><body></body></html>');
global.window = dom.window;
@@ -82,9 +84,13 @@ describe('TradeEdit bond price input bindings', () => {
vm.onKeydown({ keyCode: 13, target });
expect(emitted.map(x => x.event)).toEqual(['keydown', 'input', 'enter']);
// onKeydown 回车时故意再派发一次 inputevent.target.blur() 触发 onChange 派发一次,
// onKeydown 又直接派发一次(见 swapPricePrecisionHelper.js,注释标明"幂等无害"),
// 用于修复「重输/重贴原值 + 回车」静默不计算的 QA 高优 Bug。
expect(emitted.map(x => x.event)).toEqual(['keydown', 'input', 'input', 'enter']);
expect(emitted[1].value).toBe('0.995');
expect(emitted[2].value).toBe('0.995');
expect(emitted[3].value).toBe('0.995');
});
test('equal format refresh does not overwrite uncommitted input', () => {