新增回收置换记账及打印,完善订单标志和购料单价
This commit is contained in:
1 parent
844a1fa860
commit
505110ab0e
26 files changed
+1201
-64
No files matched your search
@@ -67,14 +67,21 @@ test('旧中断请求恢复时省略的助理字段原样省略,不被新页
|
||||
assert.equal(h.calls.length,1);assert.equal(JSON.stringify(h.calls[0].data),JSON.stringify(pending.data));assert.equal(h.calls[0].key,pending.key);assert.equal(h.saved.get(h.key),undefined);assert.equal(h.run('__savedDate'),D);
|
||||
});
|
||||
test('每日人数显示逐日总数和昨日变化、期末与本期净增,月快捷不改变订单筛选',async()=>{
|
||||
const h=historyHarness();h.context.__response=history('2026-10-01',NEXT);h.run("orderBookFilters={mode:'date',date:'2026-10-20',q:'原客户',status:'returned'};");const filters=h.json('orderBookFilters');await h.run('openPeopleCountHistory()');assert.equal(h.calls[0].url,'/api/people-count-history');assert.equal(h.calls[0].data,undefined);assert.match(h.historyDialog.innerHTML,/本月|上月/);assert.doesNotMatch(h.historyDialog.innerHTML,/name="count"|people-count-form/);assert.match(h.historyContent.innerHTML,/助理1/);assert.match(h.historyContent.innerHTML,/助理2/);assert.match(h.historyContent.innerHTML,/当日总人数/);assert.match(h.historyContent.innerHTML,/较昨日变化/);assert.match(h.historyContent.innerHTML,/0 人/);assert.match(h.historyContent.innerHTML,/未记录/);assert.match(h.historyContent.innerHTML,/本期净增 \+3 人/);assert.doesNotMatch(h.historyContent.innerHTML,/>合计<|已记录 1 天/);assert.deepEqual(h.json('orderBookFilters'),filters);
|
||||
const h=historyHarness();h.context.__response=history('2026-10-01',NEXT);h.run("orderBookFilters={mode:'date',date:'2026-10-20',q:'原客户',status:'returned'};");const filters=h.json('orderBookFilters');await h.run('openPeopleCountHistory()');assert.equal(h.calls[0].url,'/api/people-count-history');assert.equal(h.calls[0].data,undefined);assert.match(h.historyDialog.innerHTML,/本月|上月/);assert.doesNotMatch(h.historyDialog.innerHTML,/name="count"|people-count-form/);assert.match(h.historyContent.innerHTML,/助理1/);assert.match(h.historyContent.innerHTML,/助理2/);assert.match(h.historyContent.innerHTML,/当日总人数/);assert.match(h.historyContent.innerHTML,/较昨日变化/);assert.match(h.historyContent.innerHTML,/0 人/);assert.match(h.historyContent.innerHTML,/未记录/);assert.match(h.historyContent.innerHTML,/本期净增 \+3 人/);assert.match(h.historyContent.innerHTML,/已记录 2 天/);assert.equal((h.historyContent.innerHTML.match(/<tr><td>\d{4}-\d{2}-\d{2}<\/td>/g)||[]).length,2);assert.doesNotMatch(h.historyContent.innerHTML,/>合计</);assert.deepEqual(h.json('orderBookFilters'),filters);
|
||||
h.context.__response=history('2026-09-01','2026-09-30');await h.run('peopleCountHistoryMonth(true)');assert.equal(h.historyForm.elements.from.value,'2026-09-01');assert.equal(h.historyForm.elements.date.value,'2026-09-30');assert.equal(h.calls[1].url,'/api/people-count-history?from=2026-09-01&date=2026-09-30');assert.deepEqual(h.json('orderBookFilters'),filters);assert.ok(h.calls.every(call=>call.data===undefined));
|
||||
});
|
||||
test('历史按自然昨日处理断档,端点齐全仍可算本期净增,不累加每日变化或总数',()=>{
|
||||
const h=historyHarness(),from='2026-10-20',date=D,rows=[record(from,0,0,103,null,100,10),record('2026-10-21',0,0,null,null,103,null),record(date,0,0,108,8,null,null)],result={from,date,today:NEXT,baselineDate:'2026-10-19',mode:'daily-total',rows,summary:{assistant1:period(108,100,2),assistant2:period(8,10,1)}};h.context.__history=result;
|
||||
assert.doesNotThrow(()=>h.run('validatePeopleCountHistory(__history)'));const html=h.run('peopleCountHistoryHTML(__history)');assert.match(html,/本期净增 \+8 人/);assert.match(html,/本期净增 -2 人/);assert.match(html,/昨日未记录/);assert.doesNotMatch(html,/211 人|>合计</);
|
||||
assert.doesNotThrow(()=>h.run('validatePeopleCountHistory(__history)'));const html=h.run('peopleCountHistoryHTML(__history)');assert.match(html,/本期净增 \+8 人/);assert.match(html,/本期净增 -2 人/);assert.match(html,/昨日未记录/);assert.match(html,/已记录 2 天/);assert.doesNotMatch(html,/<tr><td>2026-10-21<\/td>|211 人|>合计</);
|
||||
result.rows[2].assistant1Change=8;assert.throws(()=>h.run('validatePeopleCountHistory(__history)'),/不完整/);result.rows[2].assistant1Change=null;result.summary.assistant1.endTotal=null;assert.throws(()=>h.run('validatePeopleCountHistory(__history)'),/不完整/);
|
||||
});
|
||||
test('人数历史保留0记录,全空提示无记录,助理仅按本人记录筛日期',()=>{
|
||||
const h=historyHarness(),result=history('2026-10-20',D);h.context.__history=result;
|
||||
let html=h.run('peopleCountHistoryHTML(__history)');assert.match(html,/已记录 2 天/);assert.match(html,/<tr><td>2026-10-20<\/td><td class="number">0 人/);assert.match(html,/未记录/);
|
||||
h.run("state.user={...state.user,role:'assistant',member:'assistant2'};");html=h.run('peopleCountHistoryHTML(__history)');assert.match(html,/已记录 1 天/);assert.match(html,/<tr><td>2026-10-22<\/td>/);assert.doesNotMatch(html,/<tr><td>2026-10-20<\/td>|助理1/);
|
||||
result.rows[2].assistant2Count=undefined;html=h.run('peopleCountHistoryHTML(__history)');assert.match(html,/已记录 0 天/);assert.match(html,/所选日期暂无人数记录/);assert.doesNotMatch(html,/<tr><td>\d{4}-\d{2}-\d{2}<\/td>/);
|
||||
result.rows.forEach(row=>{row.assistant1Count=null;row.assistant2Count=null;});h.run("state.user={...state.user,role:'owner',member:'owner'};");html=h.run('peopleCountHistoryHTML(__history)');assert.match(html,/已记录 0 天/);assert.match(html,/所选日期暂无人数记录/);assert.match(html,/期末/本期变化/);assert.doesNotMatch(html,/<tr><td>\d{4}-\d{2}-\d{2}<\/td>/);
|
||||
});
|
||||
test('每日人数失败清旧结果并可重查,切范围、关闭或换账号均拒绝迟到回包',async()=>{
|
||||
const h=historyHarness();h.historyContent.innerHTML='旧人数';h.run("api=async function(){throw new Error('<断线>');}");await h.run('loadPeopleCountHistory()');assert.match(h.historyContent.innerHTML,/<断线>/);assert.match(h.historyContent.innerHTML,/people-history-retry/);assert.doesNotMatch(h.historyContent.innerHTML,/旧人数/);
|
||||
const pending=[];h.context.__pending=pending;h.run('api=function(){return new Promise(resolve=>__pending.push(resolve));};');const first=h.run('loadPeopleCountHistory()');h.historyForm.elements.from.value=D;h.historyForm.elements.date.value=D;const second=h.run('loadPeopleCountHistory()');pending[1](history(D,D));await second;const latest=h.historyContent.innerHTML;pending[0](history('2026-10-01',NEXT));await first;assert.equal(h.historyContent.innerHTML,latest);
|
||||
|
||||
Reference in new issue
Block a user