feat: bound restricted stability testing to five days
This commit is contained in:
1 parent
4d8f393895
commit
f7426c937c
10 files changed
+125
-7
No files matched your search
@@ -1,5 +1,11 @@
|
||||
# 开发交接(2026-10-23)
|
||||
|
||||
## 2026-10-26 五天受限稳定性测试
|
||||
|
||||
- 用户授权清空旧订单中心显示后开始连续五天受限测试。旧订单、任务软移除,任务保留防重,原PDF/归档/邮件回执不删;原异常留档。仅新基线后的真实匹配通知参与,固定测试QQ、空Cc、无附件、桌面归档及BPM只读保持。
|
||||
- stability-test/main持久保存实际开始及结束时间(120小时);到期有效settings和restricted-state暂停,采集/归档/发送前及SMTP验证后均复核期限。重启或启停开关不能绕过到期,不退出受限模式。测试设置显示结束时间。
|
||||
- 实际起止、软移除数量、备份及核对回执在忽略的output/business-flow-test/five-day-run-20261026.json;不能拿代码实现时间替代实际启用时间。定期巡检不重发邮件,不替代应用到期保护。
|
||||
|
||||
## 2026-10-26 发送前五分钟到达截止
|
||||
|
||||
- 用户确认:11:00批次接收10:55前到达的订单,10:55起归17:00;16:55起归下一工作日首批。相邻到达区间连续,含起点、不含终点。保留原始接收时间和模板日期。
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
# 五天受限稳定性测试
|
||||
|
||||
用户要求移除旧订单中心记录,从当前时点开始连续五天测试。
|
||||
|
||||
- 旧订单及执行任务仅软移出中心,保留PDF、归档意图、规则快照、发送回执、任务去重证据和旧异常。执行中、冻结待发任务存在时拒绝重置。
|
||||
- 受限测试继续固定QQ2639266652@qq.com、空Cc、无附件、桌面归档,BPM只读;只接收新基线之后的匹配通知,不补旧单。
|
||||
- 新增持久测试期限,精确120小时后有效处理/发信设置均暂停。重启和普通启停不能绕过,SMTP验证后再次检查。到期保留受限身份,不切换正式运行。
|
||||
- 创建本对话的定期只读巡检,异常或到期才通知;不代替应用内期限保护,不手动补发。
|
||||
- 隔离测试覆盖软移除/防重/回执保留、期限边界/重启/结果不明/SMTP跨期限,验证后备份更新本机测试副本并记录实际起止时间。
|
||||
@@ -57,7 +57,7 @@ function orderRow(order,task){
|
||||
function currentTasks(context,user){
|
||||
const tasks=new Map();for(const task of records(context.orderRules).tasks){if(task.supersededBy||!task.orderId||!canReadConnection(context.workspace,user,task.connectionId))continue;const old=tasks.get(task.orderId);if(!old||Number(!!task.conflict)>Number(!!old.conflict)||!!task.conflict===!!old.conflict&&String(task.createdAt||'')>=String(old.createdAt||''))tasks.set(task.orderId,task);}return tasks;
|
||||
}
|
||||
const classified=(order,task)=>!order?.removedAt&&!!(order?.categoryId||order?.ruleSnapshot?.categoryId||order?.ruleSnapshot?.id||task?.categoryIds?.length);
|
||||
const classified=(order,task)=>!order?.removedAt&&!task?.removedAt&&!!(order?.categoryId||order?.ruleSnapshot?.categoryId||order?.ruleSnapshot?.id||task?.categoryIds?.length);
|
||||
function visibleOrders(context,user){
|
||||
const data=records(context.orderRules),tasks=currentTasks(context,user);
|
||||
const rows=data.orders.filter(o=>classified(o,tasks.get(o.id))&&canReadOrder(context.workspace,user,o)).map(o=>orderRow(o,tasks.get(o.id)));
|
||||
|
||||
@@ -5,7 +5,7 @@ const {scopesFor}=require('./scopes.cjs');
|
||||
const taskIdentity=require('./task-identity.cjs');
|
||||
const canonical=v=>Array.isArray(v)?v.map(canonical):v&&typeof v==='object'?Object.fromEntries(Object.keys(v).sort().map(k=>[k,canonical(v[k])])):v;
|
||||
const hash=v=>crypto.createHash('sha256').update(JSON.stringify(canonical(v))).digest('hex');
|
||||
const state=store=>typeof store?.get==='function'?store.get('restricted-test','main')?.value||null:null;
|
||||
const state=store=>{const run=typeof store?.get==='function'?store.get('restricted-test','main')?.value||null:null;return run&&require('./stability-period.cjs').period(store)?.expired?{...run,enabled:false}:run;};
|
||||
function localPath(unc){
|
||||
if(typeof unc!=='string'||/[\x00-\x1f/:]/.test(unc)||!/^\\\\localhost\\[a-z]\$\\/i.test(unc)||unc.split('\\').some(p=>p==='.'||p==='..'||/[. ]$/.test(p)))fail('受限测试仅允许当前用户桌面的localhost共享子目录。',409);
|
||||
return unc[12]+':\\'+unc.slice(15);
|
||||
@@ -31,7 +31,7 @@ function uncoveredFlows(store,run){
|
||||
return [...new Set(processes)].filter(processName=>!adapters.some(a=>a.verified&&!a.reference&&rule.adapterIds.includes(a.id)&&a.processName===processName)).map(processName=>({categoryId:rule.id,processName}));
|
||||
});
|
||||
}
|
||||
function summary(store){const run=state(store);if(!run)return null;return {id:run.id,version:run.version,enabled:run.enabled,recipient:run.recipient,archiveRoot:run.archiveRoot,channelId:run.channelId,since:run.since,ruleCount:run.rules.length,readyCount:run.rules.filter(r=>validRule(store,r,run)).length,uncovered:uncoveredFlows(store,run)};}
|
||||
function summary(store){const run=state(store);if(!run)return null;const period=require('./stability-period.cjs').period(store);return {id:run.id,version:run.version,enabled:run.enabled,recipient:run.recipient,archiveRoot:run.archiveRoot,channelId:run.channelId,since:run.since,ruleCount:run.rules.length,readyCount:run.rules.filter(r=>validRule(store,r,run)).length,uncovered:uncoveredFlows(store,run),...(period?{period}:{})};}
|
||||
function validRule(store,rule,run){return run.enabled&&hash(rule.adapterIds.map(id=>store.adapters().find(a=>a.id===id)))===run.adapterHashes[rule.id];}
|
||||
function executionRule(store,record){
|
||||
const run=state(store);if(!run)return record?.published||null;
|
||||
@@ -111,6 +111,7 @@ function save(store,input,actor){
|
||||
});
|
||||
}
|
||||
function assertRule(store,rule,run=state(store)){
|
||||
require('./stability-period.cjs').assertActive(store);
|
||||
if(!run){if(rule?.testRunId)fail('测试配置不存在,禁止按正式规则继续执行。',409);return;}
|
||||
if(!run.enabled||rule?.testRunId!==run.id||rule.testArchiveRoot!==run.archiveRoot)fail('受限测试已暂停或执行快照不一致。',409);
|
||||
const frozen=run.rules.find(r=>r.id===rule.id);
|
||||
@@ -121,12 +122,13 @@ function assertRule(store,rule,run=state(store)){
|
||||
if(rule.to?.length!==1||rule.to[0]!==run.recipient||rule.cc?.length)fail('受限测试收件人必须为固定QQ且无抄送。',409);
|
||||
assertPath(store,rule.archiveDirectory,run);
|
||||
}
|
||||
function assertEvent(store,sample){const run=state(store);if(!run)return;
|
||||
function assertEvent(store,sample){require('./stability-period.cjs').assertActive(store);const run=state(store);if(!run)return;
|
||||
const at=eventTime(store,sample);
|
||||
if(!run.enabled||sample?.demo||sample?.source!=='todo'||sample.configurationOnly||!Number.isFinite(Date.parse(sample.receivedAt))||Date.parse(at)<Date.parse(run.since)||Date.parse(sample.receivedAt)>Date.parse(store.now())+60000)fail('受限测试只处理启用基线之后或已明确纳入的当前真实待办通知。',409);
|
||||
}
|
||||
function assertOrder(store,order){assertRule(store,order?.ruleSnapshot);if(state(store)||order?.ruleSnapshot?.testRunId){assertEvent(store,order.sample||order.event);assertCurrentPresence(store,order.sample||order.event);for(const file of order.archive?.files||[])assertPath(store,file.path);}}
|
||||
function assertBatch(store,batch,config){
|
||||
require('./stability-period.cjs').assertActive(store);
|
||||
const run=state(store);if(!run&&!batch.ruleSnapshot?.testRunId)return;
|
||||
assertRule(store,batch.ruleSnapshot,run);if(batch.testRunId!==run.id||batch.channelId!==run.channelId||config.channelId!==run.channelId||batch.to?.length!==1||batch.to[0]!==run.recipient||batch.cc?.length)fail('受限测试批次目的地与固定配置不一致。',409);
|
||||
for(const file of batch.attachments||[])assertPath(store,file.path,run);
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
'use strict';
|
||||
function period(store){
|
||||
const saved=typeof store?.get==='function'?store.get('stability-test','main'):null;
|
||||
if(saved?.enabled!==true)return null;
|
||||
const started=typeof saved.startedAt==='string'?Date.parse(saved.startedAt):NaN,end=typeof saved.endsAt==='string'?Date.parse(saved.endsAt):NaN;
|
||||
const now=Date.parse(store.now());
|
||||
return {startedAt:saved.startedAt,endsAt:saved.endsAt,expired:!Number.isFinite(started)||!Number.isFinite(end)||end<=started||!Number.isFinite(now)||now>=end};
|
||||
}
|
||||
function assertActive(store){if(period(store)?.expired)throw Object.assign(Error('五天稳定性测试已到期或期限配置无效,自动处理和发信已暂停。'),{status:409,code:'STABILITY_TEST_EXPIRED'});}
|
||||
module.exports={period,assertActive};
|
||||
@@ -0,0 +1,32 @@
|
||||
'use strict';
|
||||
const fail=message=>{throw Object.assign(new Error(message),{status:409});};
|
||||
function resetForStabilityTest(store,{startedAt,endsAt},actor){
|
||||
if(actor?.role!=='admin'||!actor.username)fail('仅管理员可以重新开始稳定性测试。');
|
||||
if(!Number.isFinite(Date.parse(startedAt))||Date.parse(endsAt)-Date.parse(startedAt)!==5*86400000)fail('请提供连续五天的有效测试起止时间。');
|
||||
return store.transaction(()=>{
|
||||
const old=store.get('stability-test','main');if(old?.startedAt===startedAt&&old.endsAt===endsAt)return {...old.result,replayed:true};
|
||||
const current=store.get('restricted-test','main'),run=current?.value;
|
||||
if(!run?.enabled||run.recipient!=='2639266652@qq.com'||!run.rules?.length||run.rules.some(r=>r.to?.length!==1||r.to[0]!==run.recipient||r.cc?.length||r.attachPdf!==false))fail('必须保持固定QQ、无抄送、无附件的受限测试配置。');
|
||||
if(store.all('batches').some(b=>['prepared','sending'].includes(b.status))||store.all('execution-tasks').some(t=>['capturing','archiving','sending'].includes(t.status)))fail('存在执行中或冻结待发任务,须先核验结果再重置测试。');
|
||||
const result={orders:0,tasks:0},ids=new Set(),tasks=new Set();
|
||||
for(const order of store.all('orders')){
|
||||
if(order.removedAt)continue;ids.add(order.id);result.orders++;
|
||||
order.removal={previousStatus:order.status,previousError:order.error,at:startedAt,note:'用户要求清理旧订单中心,开始五天稳定性测试'};order.removedAt=startedAt;
|
||||
if(!['sent','unknown','sending','batched'].includes(order.status)&&!order.batchId&&!store.all('batches').some(b=>b.orderIds?.includes(order.id)))order.status='ignored';
|
||||
store.put('orders',order);
|
||||
}
|
||||
for(const task of store.all('execution-tasks')){
|
||||
if(task.removedAt)continue;tasks.add(task.id);result.tasks++;
|
||||
task.removal={previousStatus:task.status,previousError:task.error,at:startedAt};task.removedAt=startedAt;task.revisionIgnored=true;
|
||||
if(!['sent','unknown','sending','archiving','capturing'].includes(task.status))task.status='ignored';
|
||||
task.version=(task.version||0)+1;store.put('execution-tasks',task);
|
||||
}
|
||||
for(const issue of store.all('business-issues'))if((issue.taskIds||[issue.taskId]).some(id=>tasks.has(id))||(issue.orderIds||[]).some(id=>ids.has(id)))store.put('business-issues',{...issue,previousStatus:issue.status,status:'retired',retiredAt:startedAt});
|
||||
store.put('restricted-test-history',{id:'stability-before:'+startedAt,value:run});
|
||||
const next={...run,since:startedAt,version:run.version+1};delete next.currentBacklog;delete next.enrolledAt;store.put('restricted-test',{...current,value:next});
|
||||
const settings=store.get('settings','main');store.put('settings',{...settings,enabled:true,processingEnabled:true,processingSince:startedAt,version:settings.version+1});
|
||||
store.put('stability-test',{id:'main',enabled:true,startedAt,endsAt,result});store.audit(actor.username,'开始五天稳定性测试',startedAt+' 至 '+endsAt+';旧记录仅移出中心,回执与归档保留。');
|
||||
return result;
|
||||
});
|
||||
}
|
||||
module.exports={resetForStabilityTest};
|
||||
@@ -69,7 +69,7 @@ class RuleStore{
|
||||
all(kind){return this.db.prepare('SELECT id,payload FROM records WHERE kind=? ORDER BY rowid').all(kind).map(r=>this.vault.decode(kind+':'+r.id,r.payload));}
|
||||
put(kind,value){this.db.prepare('INSERT INTO records VALUES(?,?,?) ON CONFLICT(kind,id) DO UPDATE SET payload=excluded.payload').run(kind,value.id,this.vault.encode(kind+':'+value.id,value));return value;}
|
||||
audit(actor,action,detail){this.put('audit',{id:crypto.randomUUID(),at:this.now(),actor:String(actor||'系统'),action,detail});}
|
||||
settings(){const {id,...settings}=this.get('settings','main');return {...settings,processingEnabled:settings.processingEnabled??settings.enabled,processingSince:settings.processingSince??null};}
|
||||
settings(){const {id,...settings}=this.get('settings','main'),expired=require('./stability-period.cjs').period(this)?.expired;return {...settings,enabled:expired?false:settings.enabled,processingEnabled:expired?false:settings.processingEnabled??settings.enabled,processingSince:settings.processingSince??null};}
|
||||
saveSettings(input,actor){return this.transaction(()=>{
|
||||
const old=this.settings();
|
||||
const testing=this.restrictedTest();if(testing&&input?.channelId!==testing.channelId)fail('受限测试发件通道已固定。',409);
|
||||
@@ -223,7 +223,7 @@ class RuleStore{
|
||||
return blockers;
|
||||
}
|
||||
categoryIncomplete(categoryId,window){
|
||||
return this.all('execution-tasks').some(task=>task.categoryIds?.includes(categoryId)&&(!Number.isFinite(Date.parse(eligibility.eventTime(this,task.row)))||eligibility.eventInWindow(this,task.row,window))&&(task.conflict||['identified','blocked','failed','capturing','archiving'].includes(task.status)||task.status==='unknown'&&task.step!=='complete'||task.runtimeCheck?.status==='blocked'));
|
||||
return this.all('execution-tasks').some(task=>!task.removedAt&&task.categoryIds?.includes(categoryId)&&(!Number.isFinite(Date.parse(eligibility.eventTime(this,task.row)))||eligibility.eventInWindow(this,task.row,window))&&(task.conflict||['identified','blocked','failed','capturing','archiving'].includes(task.status)||task.status==='unknown'&&task.step!=='complete'||task.runtimeCheck?.status==='blocked'));
|
||||
}
|
||||
batchIncomplete(batch){
|
||||
return this.all('execution-tasks').some(task=>batch.orderIds.includes(task.orderId)&&(task.conflict||task.runtimeCheck?.status==='blocked'||['failed','capturing','archiving'].includes(task.status)||task.status==='unknown'&&task.step!=='complete'));
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
const test=require('node:test'),assert=require('node:assert/strict'),fs=require('node:fs'),os=require('node:os'),path=require('node:path');
|
||||
const {RuleStore}=require('../../src/modules/order-rules/store.cjs'),restricted=require('../../src/modules/order-rules/restricted-test.cjs');
|
||||
function fixture(t){const dir=fs.mkdtempSync(path.join(os.tmpdir(),'stability-expiry-'));let now=new Date('2026-10-26T03:00:00Z'),store=new RuleStore(dir,{clock:()=>now});store.put('settings',{...store.get('settings','main'),enabled:true,processingEnabled:true});t.after(()=>{store.close();fs.rmSync(dir,{recursive:true,force:true});});return {get store(){return store;},setNow:value=>{now=new Date(value);},restart:()=>{store.close();store=new RuleStore(dir,{clock:()=>now});}};}
|
||||
const period={id:'main',enabled:true,startedAt:'2026-10-26T03:00:00.000Z',endsAt:'2026-10-31T03:00:00.000Z'};
|
||||
test('five-day period stops processing and sending exactly at expiry and remains stopped after restart or settings toggle',t=>{
|
||||
const f=fixture(t);f.store.put('stability-test',period);f.setNow('2026-10-31T02:59:59.999Z');assert.equal(f.store.settings().enabled,true);assert.equal(f.store.settings().processingEnabled,true);
|
||||
f.setNow(period.endsAt);assert.equal(f.store.settings().enabled,false);assert.equal(f.store.settings().processingEnabled,false);assert.equal(f.store.get('settings','main').enabled,true);
|
||||
f.restart();assert.equal(f.store.settings().enabled,false);f.store.put('settings',{...f.store.get('settings','main'),enabled:true,processingEnabled:true});assert.equal(f.store.settings().enabled,false);
|
||||
assert.equal(Object.hasOwn(f.store.settings(),'testEndsAt'),false);
|
||||
});
|
||||
test('expired restricted run stays present but disabled and blocks event rule and batch paths',t=>{
|
||||
const f=fixture(t),run={id:'restricted',enabled:true,version:1,rules:[],adapterHashes:{},since:period.startedAt};f.store.put('restricted-test',{id:'main',value:run});f.store.put('stability-test',period);f.setNow(period.endsAt);
|
||||
assert.deepEqual(restricted.state(f.store),{...run,enabled:false});assert.equal(f.store.get('restricted-test','main').value.enabled,true);
|
||||
assert.throws(()=>restricted.assertEvent(f.store,{source:'todo',receivedAt:period.startedAt}),{status:409});assert.throws(()=>restricted.assertRule(f.store,{}),{status:409});assert.throws(()=>restricted.assertBatch(f.store,{ruleSnapshot:{}},{}),{status:409});
|
||||
assert.deepEqual(f.store.restrictedTest().period,{startedAt:period.startedAt,endsAt:period.endsAt,expired:true});
|
||||
});
|
||||
for(const malformed of ['',null,'invalid','2026-10-25T03:00:00.000Z'])test(`invalid enabled period fails closed (${malformed})`,t=>{const f=fixture(t);f.store.put('stability-test',{...period,endsAt:malformed});assert.equal(f.store.settings().enabled,false);assert.equal(f.store.settings().processingEnabled,false);});
|
||||
test('missing or disabled period preserves existing behavior',t=>{const f=fixture(t);assert.equal(f.store.settings().enabled,true);f.store.put('stability-test',{...period,enabled:false});f.setNow('2027-01-01T00:00:00Z');assert.equal(f.store.settings().enabled,true);});
|
||||
test('expiry during SMTP verification prevents even manual send before message submission',async t=>{
|
||||
const f=fixture(t);f.store.put('stability-test',period);let verified=0,sent=0,begun=0;const finished=[];
|
||||
f.store.capabilities={liveTodo:true,pdfExport:true,automaticArchive:true};f.store.beginSending=()=>{begun++;};f.store.finishSending=(id,status)=>finished.push(status);
|
||||
const mail={store:{channelSecret:()=>({id:'mail',version:1,email:'isolated@example.test',smtp:{}}),guard:()=>{}},smtpFactory:()=>({verify:async()=>{verified++;f.setNow(period.endsAt);},sendMail:async()=>{sent++;return {accepted:['2639266652@qq.com']};},close:()=>{}})};
|
||||
const {OrderRuleDispatcher}=require('../../src/modules/order-rules/dispatcher.cjs');
|
||||
const dispatcher=new OrderRuleDispatcher({store:f.store,mail,clock:()=>new Date(f.store.now()),providersReady:()=>true});
|
||||
await dispatcher.dispatch({id:'isolated',status:'prepared',channelId:'mail',to:['2639266652@qq.com'],cc:[],attachments:[],ruleSnapshot:{},orderIds:[]},{enabled:true,channelId:'mail'},{manual:true});
|
||||
assert.equal(verified,1);assert.equal(sent,0);assert.equal(begun,0);assert.deepEqual(finished,['failed']);
|
||||
});
|
||||
@@ -0,0 +1,31 @@
|
||||
'use strict';
|
||||
const test=require('node:test'),assert=require('node:assert/strict');
|
||||
const {resetForStabilityTest}=require('../../src/modules/order-rules/stability-test.cjs');
|
||||
const {queryOrders}=require('../../src/modules/order-rules/query.cjs');
|
||||
function fixture(){
|
||||
const records={orders:[{id:'o',categoryId:'cat',status:'pending',archive:{files:[{path:'retained.pdf'}]},sample:{connectionId:'c'}},{id:'unknown',categoryId:'cat',status:'unknown',batchId:'b',sample:{connectionId:'c'}}],'execution-tasks':[{id:'t',connectionId:'c',categoryIds:['cat'],status:'blocked',step:'capture',row:{taskId:'old'}},{id:'sent-task',connectionId:'c',categoryIds:['cat'],status:'sent',orderId:'unknown',row:{taskId:'sent'}}],batches:[{id:'b',status:'unknown',orderIds:['unknown']}],'processed-task-receipts':[{id:'receipt'}],'archive-intents':[{id:'intent'}],'business-issues':[{id:'issue',status:'open',taskIds:['t']}],settings:[{id:'main',version:1,enabled:true,processingEnabled:true,channelId:'channel'}],'restricted-test':[{id:'main',value:{id:'run',version:1,enabled:true,since:'2026-10-23T00:00:00Z',recipient:'2639266652@qq.com',currentBacklog:[{snapshot:{taskId:'old'}}],rules:[{id:'cat',to:['2639266652@qq.com'],cc:[],attachPdf:false}]}}]};
|
||||
const s={all:k=>structuredClone(records[k]||[]),get:(k,id)=>structuredClone(records[k]?.find(r=>r.id===id)),put(k,r){records[k]||=[];const i=records[k].findIndex(x=>x.id===r.id);if(i<0)records[k].push(structuredClone(r));else records[k][i]=structuredClone(r);},transaction:work=>work(),audit(){},snapshot:()=>({rules:[]})};
|
||||
return s;
|
||||
}
|
||||
const input={startedAt:'2026-10-26T06:00:00.000Z',endsAt:'2026-10-31T06:00:00.000Z'};
|
||||
test('reset hides old tasks and orders but retains PDF receipts frozen outcomes and sets future-only baseline',()=>{
|
||||
const s=fixture(),before=['batches','archive-intents','processed-task-receipts'].map(k=>s.all(k));
|
||||
const result=resetForStabilityTest(s,input,{username:'admin',role:'admin'});assert.equal(result.orders,2);assert.equal(result.tasks,2);
|
||||
assert.equal(queryOrders({orderRules:s}, {}, {username:'admin',role:'admin'}).total,0);
|
||||
assert.equal(s.get('orders','o').archive.files[0].path,'retained.pdf');assert.equal(s.get('orders','unknown').status,'unknown');assert.equal(s.get('execution-tasks','sent-task').status,'sent');
|
||||
assert.deepEqual(['batches','archive-intents','processed-task-receipts'].map(k=>s.all(k)),before);
|
||||
assert.equal(s.get('settings','main').processingSince,input.startedAt);assert.equal(s.get('restricted-test','main').value.since,input.startedAt);assert.equal(s.get('restricted-test','main').value.currentBacklog,undefined);
|
||||
assert.equal(s.get('stability-test','main').endsAt,input.endsAt);assert.equal(s.get('business-issues','issue').status,'retired');
|
||||
assert.equal(resetForStabilityTest(s,input,{username:'admin',role:'admin'}).replayed,true);
|
||||
});
|
||||
test('reset rejects other roles, invalid duration and unfixed recipients before any mutation',()=>{
|
||||
for(const variant of ['role','duration','recipient']){const s=fixture();if(variant==='recipient'){const r=s.get('restricted-test','main');r.value.recipient='other@example.com';s.put('restricted-test',r);}const before=s.all('orders');assert.throws(()=>resetForStabilityTest(s,variant==='duration'?{...input,endsAt:input.startedAt}:input,{username:'x',role:variant==='role'?'operator':'admin'}));assert.deepEqual(s.all('orders'),before);}
|
||||
});
|
||||
test('reset refuses a prepared batch rather than allowing old queued mail into the new test',()=>{
|
||||
const s=fixture();s.put('batches',{id:'queued',status:'prepared',orderIds:['o']});const before=s.all('orders');assert.throws(()=>resetForStabilityTest(s,input,{username:'admin',role:'admin'}),/冻结|执行中/);assert.deepEqual(s.all('orders'),before);
|
||||
});
|
||||
test('removed historical conflicts cannot block a new category batch',()=>{
|
||||
const {RuleStore}=require('../../src/modules/order-rules/store.cjs');
|
||||
const store={get:()=>null,all:()=>[{id:'old-conflict',removedAt:input.startedAt,categoryIds:['cat'],conflict:true,status:'ignored',row:{}}]};
|
||||
assert.equal(RuleStore.prototype.categoryIncomplete.call(store,'cat'),false);
|
||||
});
|
||||
@@ -23,7 +23,7 @@ window.OrderNotificationViews=(()=>{
|
||||
const card=document.createElement('section');card.className='card settings-width mb-3';container.prepend(card);
|
||||
let run=data.restrictedTest;
|
||||
function drawTest(){
|
||||
card.innerHTML=`<div class="card-header"><h2 class="card-title">受限稳定性测试</h2><span class="badge bg-yellow-lt ms-auto">${run.enabled?'测试运行中':'测试已暂停'}</span></div><div class="card-body"><p>覆盖 ${Number(run.ruleCount)} 类,当前可用 ${Number(run.readyCount)} 类。正式投产须重新检查并发布。</p><dl><dt>固定收件箱</dt><dd class="text-break">${esc(run.recipient)}</dd><dt>桌面归档目录</dt><dd class="text-break">${esc(run.archiveRoot)}</dd><dt>测试接收基线</dt><dd>${esc(formatDate(run.since))}</dd></dl><p class="small text-secondary">仅处理基线后的真实通知;暂停保留测试模式,不切换为正式发送。收件箱、目录与发件通道已固定。</p>${run.uncovered?.length?`<p class="text-warning small">${run.uncovered.length} 个流程尚无可用字段版本,继续阻塞。</p><ul class="small text-warning">${run.uncovered.map(item=>`<li><span>${esc(item.processName)}</span>${item.categoryId?` <span class="text-secondary">(分类:${esc(item.categoryId)})</span>`:''}</li>`).join('')}</ul>`:''}<div role="alert"></div></div>${admin?`<div class="card-footer"><button type="button" class="btn ${run.enabled?'btn-outline-warning':'btn-primary'}">${run.enabled?'暂停测试':'恢复测试'}</button></div>`:''}`;
|
||||
card.innerHTML=`<div class="card-header"><h2 class="card-title">受限稳定性测试</h2><span class="badge bg-yellow-lt ms-auto">${run.enabled?'测试运行中':'测试已暂停'}</span></div><div class="card-body"><p>覆盖 ${Number(run.ruleCount)} 类,当前可用 ${Number(run.readyCount)} 类。正式投产须重新检查并发布。</p><dl><dt>固定收件箱</dt><dd class="text-break">${esc(run.recipient)}</dd><dt>桌面归档目录</dt><dd class="text-break">${esc(run.archiveRoot)}</dd><dt>测试接收基线</dt><dd>${esc(formatDate(run.since))}</dd>${run.period?'<dt>测试结束(自动暂停)</dt><dd>'+esc(formatDate(run.period.endsAt))+(run.period.expired?' · 已到期':'')+'</dd>':''}</dl><p class="small text-secondary">仅处理基线后的真实通知;暂停保留测试模式,不切换为正式发送。收件箱、目录与发件通道已固定。</p>${run.uncovered?.length?`<p class="text-warning small">${run.uncovered.length} 个流程尚无可用字段版本,继续阻塞。</p><ul class="small text-warning">${run.uncovered.map(item=>`<li><span>${esc(item.processName)}</span>${item.categoryId?` <span class="text-secondary">(分类:${esc(item.categoryId)})</span>`:''}</li>`).join('')}</ul>`:''}<div role="alert"></div></div>${admin?`<div class="card-footer"><button type="button" class="btn ${run.enabled?'btn-outline-warning':'btn-primary'}">${run.enabled?'暂停测试':'恢复测试'}</button></div>`:''}`;
|
||||
const button=card.querySelector('button');if(button)button.onclick=async()=>{if(button.disabled)return;button.disabled=true;try{const saved=await api('/order-rules/restricted-test',{version:run.version,enabled:!run.enabled});if(isActive()&&card.isConnected){run=saved;drawTest();}}catch(error){if(isActive()&&card.isConnected)card.querySelector('[role=alert]').textContent=error.message;}finally{if(button.isConnected)button.disabled=false;}};
|
||||
}
|
||||
drawTest();
|
||||
|
||||
Reference in new issue
Block a user