保存同行基础版:店铺配置与员工管理
This commit is contained in:
1 parent
ecb8d6dec0
commit
b7b987064b
84 files changed
+1884
-573
No files matched your search
@@ -19,32 +19,32 @@ function harness(value=page(),role='owner'){
|
||||
test('自动快照只显示系统自动保存,实际保存时间不冒用计划时间或首次保存时间',()=>{
|
||||
const h=harness(page({todaySnapshot:snapshot({actor:'麦麦'}),automaticSnapshot:schedule({status:'saved',lastSuccess:{date:D,scheduledFor:D+'T23:50:00+08:00',savedAt:D+'T15:51:00Z'}})})),html=h.run('stockReviewStatus(__page)');
|
||||
assert.match(html,/系统自动保存/);assert.match(html,/实际保存 [^<]*23:51/);assert.match(html,/北京时间每日 23:50 自动保存/);assert.doesNotMatch(html,/已复核|今天尚未保存|20:00/);
|
||||
assert.doesNotMatch(h.run('stockHeading(__page)'),/麦麦核对后保存/);
|
||||
assert.doesNotMatch(h.run('stockHeading(__page)'),/店主核对后保存/);
|
||||
});
|
||||
|
||||
test('手动复核与旧快照返回兼容,旧接口缺少自动计划时不承诺已启用自动保存',()=>{
|
||||
const manual=snapshot({source:'manual',actor:'合成麦麦'}),h=harness(page({todaySnapshot:manual}));let html=h.run('stockReviewStatus(__page)');
|
||||
assert.match(html,/麦麦复核/);assert.match(html,/合成麦麦/);assert.match(html,/今天已复核/);
|
||||
assert.match(html,/店主复核/);assert.match(html,/合成麦麦/);assert.match(html,/今天已复核/);
|
||||
delete manual.source;delete manual.updated;delete h.context.__page.automaticSnapshot;
|
||||
html=h.run('stockReviewStatus(__page)');assert.match(html,/麦麦复核/);assert.match(html,/今天已复核/);assert.match(html,/实际保存 [^<]*20:00/);assert.doesNotMatch(html,/北京时间每日|系统自动保存/);
|
||||
html=h.run('stockReviewStatus(__page)');assert.match(html,/店主复核/);assert.match(html,/今天已复核/);assert.match(html,/实际保存 [^<]*20:00/);assert.doesNotMatch(html,/北京时间每日|系统自动保存/);
|
||||
});
|
||||
|
||||
test('保存后补记时保留来源与时间,自动和人工快照都不显示当前已复核',()=>{
|
||||
const h=harness(page({todaySnapshot:snapshot({stale:true}),yesterday:snapshot({date:Y,stale:true})}));let html=h.run('stockReviewStatus(__page)');
|
||||
assert.match(html,/系统自动保存/);assert.match(html,/实际保存 [^<]*23:51/);assert.match(html,/保存后有库存变动,保留当时保存值/);assert.match(html,/卡片仍显示昨天当时保存的数量/);assert.doesNotMatch(html,/已复核|需重新复核/);
|
||||
h.context.__page.todaySnapshot.source='manual';html=h.run('stockReviewStatus(__page)');assert.match(html,/麦麦复核/);assert.match(html,/需重新复核/);assert.doesNotMatch(html,/今天已复核/);
|
||||
h.context.__page.todaySnapshot.source='manual';html=h.run('stockReviewStatus(__page)');assert.match(html,/店主复核/);assert.match(html,/需重新复核/);assert.doesNotMatch(html,/今天已复核/);
|
||||
});
|
||||
|
||||
test('昨天卡片保留过期快照数量和零库存,当前数量与保存来源单独展示',()=>{
|
||||
const h=harness(page({yesterday:snapshot({date:Y,stale:true,inventory:inventory(1234)})})),html=h.run('stockCards(__page)');
|
||||
assert.match(html,/当前数量<\/div><strong>9\.876/);assert.match(html,/昨天快照/);assert.match(html,/<b class="">1\.234g<\/b>/);assert.match(html,/<b class="">0\.000g<\/b>/);assert.match(html,/系统自动保存 · 后有补记/);assert.doesNotMatch(html,/昨天复核|麦麦复核|已复核/);
|
||||
assert.match(html,/当前数量<\/div><strong>9\.876/);assert.match(html,/昨天快照/);assert.match(html,/<b class="">1\.234g<\/b>/);assert.match(html,/<b class="">0\.000g<\/b>/);assert.match(html,/系统自动保存 · 后有补记/);assert.doesNotMatch(html,/昨天复核|店主复核|已复核/);
|
||||
h.context.__page.yesterday=null;assert.match(h.run('stockCards(__page)'),/未保存快照/);
|
||||
});
|
||||
|
||||
test('历史表按每个日期一行显示自动、人工和旧快照,使用各自实际保存值及时间',async()=>{
|
||||
const automatic=snapshot({date:Y,stale:true,inventory:[...inventory(1234),{pocket:'历史货盘',mg:100,reserved:0}]}),manual=snapshot({source:'manual',date:D,actor:'<b>合成麦麦</b>',inventory:inventory(2500)}),old=snapshot({date:'2026-10-24',actor:'旧合成麦麦'});delete old.source;delete old.updated;
|
||||
const h=harness(),html=await h.history([manual,automatic,old]);
|
||||
assert.match(html,/保存来源/时间/);assert.equal((html.match(/<tr><td>/g)||[]).length,3);assert.equal(h.nodes.get('#inventory-history-count').textContent,'3 天');assert.match(html,/系统自动保存/);assert.match(html,/麦麦复核/);assert.match(html,/旧合成麦麦/);assert.match(html,/实际保存 [^<]*23:51/);assert.match(html,/实际保存 [^<]*20:00/);assert.match(html,/1\.234/);assert.match(html,/2\.500/);assert.match(html,/保存后有库存补记,保留当时保存值/);assert.match(html,/历史货盘 0\.100g/);assert.doesNotMatch(html,/已复核|<b>合成麦麦<\/b>/);assert.match(html,/<b>合成麦麦<\/b>/);
|
||||
assert.match(html,/保存来源/时间/);assert.equal((html.match(/<tr><td>/g)||[]).length,3);assert.equal(h.nodes.get('#inventory-history-count').textContent,'3 天');assert.match(html,/系统自动保存/);assert.match(html,/店主复核/);assert.match(html,/旧合成麦麦/);assert.match(html,/实际保存 [^<]*23:51/);assert.match(html,/实际保存 [^<]*20:00/);assert.match(html,/1\.234/);assert.match(html,/2\.500/);assert.match(html,/保存后有库存补记,保留当时保存值/);assert.match(html,/历史货盘 0\.100g/);assert.doesNotMatch(html,/已复核|<b>合成麦麦<\/b>/);assert.match(html,/<b>合成麦麦<\/b>/);
|
||||
assert.match(h.run('stockHistoryPanel()'),/每日库存快照/);assert.doesNotMatch(h.run('stockHistoryPanel()'),/每日复核快照/);
|
||||
});
|
||||
|
||||
@@ -59,13 +59,13 @@ test('自动保存失败只显示有界且转义的错误和本日重试时间',
|
||||
h.context.__page.automaticSnapshot=schedule();const waiting=h.run('stockReviewStatus(__page)');assert.match(waiting,/北京时间每日 23:50 自动保存/);assert.doesNotMatch(waiting,/未成功|下次重试|今天已自动保存/);
|
||||
});
|
||||
|
||||
test('未知来源保守显示为已保存,不标成麦麦复核',()=>{
|
||||
const h=harness(page({todaySnapshot:snapshot({source:'unrecognized'})})),html=h.run('stockReviewStatus(__page)');assert.match(html,/>已保存<\/span>/);assert.doesNotMatch(html,/麦麦复核|今天已复核|系统自动保存/);
|
||||
test('未知来源保守显示为已保存,不标成店主复核',()=>{
|
||||
const h=harness(page({todaySnapshot:snapshot({source:'unrecognized'})})),html=h.run('stockReviewStatus(__page)');assert.match(html,/>已保存<\/span>/);assert.doesNotMatch(html,/店主复核|今天已复核|系统自动保存/);
|
||||
});
|
||||
|
||||
test('手动复核仍仅麦麦可操作,自动快照不改变权限与版本提交',async()=>{
|
||||
test('手动复核仍仅店主可操作,自动快照不改变权限与版本提交',async()=>{
|
||||
const h=harness(page({todaySnapshot:snapshot()}));assert.match(h.run('stockHeading(__page)'),/data-action="inventory-review"/);
|
||||
h.run('mutate=async(url,data)=>{__calls.push({url,data});return {};};refresh=async()=>{};');await h.review();assert.equal(h.calls.length,1);assert.equal(h.calls[0].url,'/api/inventory/review');assert.deepEqual(JSON.parse(JSON.stringify(h.calls[0].data)),{date:D,verified:true,revision:'current-revision'});
|
||||
h.context.__page.canReview=false;assert.doesNotMatch(h.run('stockHeading(__page)'),/data-action="inventory-review"/);await h.review();assert.equal(h.calls.length,1);assert.match(h.toasts.at(-1).message,/手动复核库存由麦麦操作/);
|
||||
const assistant=harness(page({canReview:true,todaySnapshot:snapshot()}),'assistant');assistant.run('mutate=async(url,data)=>{__calls.push({url,data});return {};};');assert.doesNotMatch(assistant.run('stockHeading(__page)'),/data-action="inventory-review"/);await assistant.review();assert.equal(assistant.calls.length,0);assert.match(assistant.toasts.at(-1).message,/手动复核库存由麦麦操作/);
|
||||
h.context.__page.canReview=false;assert.doesNotMatch(h.run('stockHeading(__page)'),/data-action="inventory-review"/);await h.review();assert.equal(h.calls.length,1);assert.match(h.toasts.at(-1).message,/手动复核库存由店主操作/);
|
||||
const assistant=harness(page({canReview:true,todaySnapshot:snapshot()}),'assistant');assistant.run('mutate=async(url,data)=>{__calls.push({url,data});return {};};');assert.doesNotMatch(assistant.run('stockHeading(__page)'),/data-action="inventory-review"/);await assistant.review();assert.equal(assistant.calls.length,0);assert.match(assistant.toasts.at(-1).message,/手动复核库存由店主操作/);
|
||||
});
|
||||
Reference in new issue
Block a user