feat: complete workflow recovery and safe administration
This commit is contained in:
1 parent
1148aa6f14
commit
69583e8c33
46 files changed
+756
-120
No files matched your search
@@ -25,6 +25,38 @@ async function configure(f){
|
||||
assert.equal(f.store.capturedPreview(captured.id).valid,true);f.store.publish(saved.id,{version:saved.version},'admin');
|
||||
}
|
||||
|
||||
for(const correction of ['migration','recheck'])for(const outcome of ['receipt','failure'])test(`in-flight archive ${outcome} cannot overwrite ${correction} generation or task`,async t=>{
|
||||
const f=fixture(t);await configure(f);
|
||||
let release,started;const gate=new Promise(r=>{release=r;}),begin=new Promise(r=>{started=r;});
|
||||
const archive=f.archive.archive;let original,receipt;
|
||||
f.archive.archive=async input=>{original=structuredClone(input.order);started();await gate;if(outcome==='failure')throw Error('synthetic old archive failure');receipt=await archive(input);return receipt;};
|
||||
const scanning=f.execution.scan({connectionId:'c1',idempotencyKey:'archive-race'},principal);await begin;
|
||||
try{
|
||||
const current=f.store.get('rules','bs-change').draft,saved=f.store.saveRule({...current,archiveDirectory:'\\\\server\\corrected'},'admin');
|
||||
f.store.capturedPreview(f.store.fields().samples[0].id);f.store.publish(saved.id,{version:saved.version},'admin');
|
||||
if(correction==='migration')f.store.applyMigration(saved.id,{version:saved.version,idempotencyKey:'correct-output',note:'修正归档目录并重新处理'},'admin');
|
||||
else f.store.recheck(original.id,{note:'重新识别并应用正确目录'},'admin');
|
||||
const corrected=f.store.get('orders',original.id),correctedTask=f.store.all('execution-tasks')[0];
|
||||
release();await scanning;
|
||||
assert.equal(f.store.get('orders',original.id).archive,null);assert.equal(f.store.get('orders',original.id).archiveGeneration,corrected.archiveGeneration);assert.equal(f.store.get('orders',original.id).status,'identified');
|
||||
assert.deepEqual(f.store.get('execution-tasks',correctedTask.id),correctedTask);
|
||||
if(outcome==='receipt'){
|
||||
const history=f.store.get('orders',original.id).archiveHistory;
|
||||
assert.equal(history.some(item=>item.generation===(original.archiveGeneration||1)&&item.evidence?.files[0].sha256===receipt.files[0].sha256),true);
|
||||
}
|
||||
assert.equal(f.store.prepare('2026-10-19T03:00:00Z','admin').length,0);
|
||||
f.archive.archive=archive;await f.execution.scan({connectionId:'c1',idempotencyKey:'correct-generation'},principal);
|
||||
assert.equal(f.store.get('orders',original.id).status,'pending');
|
||||
}finally{release();await scanning;await f.execution.stop();}
|
||||
});
|
||||
|
||||
test('distribution migration during a real journaled archive remains recoverable without reusing a stale generation',async t=>{
|
||||
const f=fixture(t);await configure(f);const {OrderArchiveProvider}=require('../../src/modules/storage/order-archive.cjs');let release,started;const gate=new Promise(r=>release=r),begin=new Promise(r=>started=r),files=new Map(),bytes=Buffer.from('%PDF-1.7 synthetic journal race'),sha=crypto.createHash('sha256').update(bytes).digest('hex');let rendered=0,sharedWrites=0;
|
||||
const storage={store:{servers:()=>[{id:'s',enabled:true,host:'server',share:'orders',directory:'',state:{readable:true,writable:true}}]},check:async()=>{},run:async(_,fn)=>fn({},null),readFile:async(_,relative)=>({bytes:files.get(relative)}),operation:async(_,action,args)=>{if(action==='archive'){sharedWrites++;if(sharedWrites===1){started();await gate;}const relative=[args[2],args[1]].filter(Boolean).join('/');files.set(relative,bytes);return {filename:args[1],relativePath:relative,sha256:sha,bytes:bytes.length};}return {bytes:files.get(args[0])};}};
|
||||
const archive=new OrderArchiveProvider({storage,journal:f.store,clock:()=>new Date('2026-10-19T03:00:00Z'),outputDir:path.join(f.store.vault.stateDir||f.store.vault.dir||os.tmpdir(),'journal-race-'+crypto.randomUUID()),renderer:async(_,options)=>{await fs.promises.mkdir(options.outputDir,{recursive:true});const file=path.join(options.outputDir,++rendered+'.pdf');await fs.promises.writeFile(file,bytes);return {path:file};}});t.after(()=>fs.promises.rm(path.dirname(archive.outputDir),{recursive:true,force:true}));f.execution.archive=archive;
|
||||
const scanning=f.execution.scan({connectionId:'c1',idempotencyKey:'journal-start'},principal);await begin;try{const original=f.store.all('orders')[0],rule=f.store.get('rules','bs-change').draft,saved=f.store.saveRule({...rule,to:['new-owner@example.test']},'admin');f.store.capturedPreview(f.store.fields().samples[0].id);f.store.publish(saved.id,{version:saved.version},'admin');const result=f.store.applyMigration(saved.id,{version:saved.version,idempotencyKey:'distribution-race',note:'只更换通知收件人规则'},'admin');assert.equal(result.items[0].archiveChanged,false);release();await scanning;await f.execution.scan({connectionId:'c1',idempotencyKey:'journal-retry'},principal);const final=f.store.get('orders',original.id);assert.equal(final.status,'pending',final.error);assert.ok(final.archive);assert.deepEqual(final.ruleSnapshot.to,['new-owner@example.test']);assert.ok(final.archiveGeneration>(original.archiveGeneration||1));assert.equal(f.store.all('archive-intents').length,2);assert.ok(final.archiveHistory.some(item=>item.stale));}finally{release();await scanning;await f.execution.stop();}
|
||||
});
|
||||
|
||||
test('scan prefilter uses complete process-node pairs without crossing their columns',async t=>{
|
||||
const f=fixture(t),rule=f.store.get('rules','bs-change').draft;
|
||||
f.store.saveRule({...rule,scopes:[{processName:f.row.processName,nodeName:'另一个节点'},{processName:'另一个流程',nodeName:f.row.nodeName}]},'admin');
|
||||
|
||||
@@ -88,14 +88,24 @@ test('API recognizes admin mapping and sample actions before generic rules route
|
||||
for(const action of ['list','capture']){assert.equal(await orderExecutionApi({...args,execution,body:{connectionId:'c',idempotencyKey:'k',...(action==='capture'?{listId:'l',rowId:'r'}:{})},route:'/api/order-rules/field-samples/'+action}),true);assert.equal(reply.status,200);}
|
||||
assert.equal(body.connectionId,'c');await assert.rejects(orderExecutionApi({...args,execution,body:{connectionId:'c',idempotencyKey:'k',detailUrl:'http://forged'},route:'/api/order-rules/field-samples/list'}),e=>e.status===400);
|
||||
});
|
||||
test('operator directory hides cross-connection and disabled-connection mapping check evidence',async t=>{
|
||||
test('field APIs authorize directory and advanced evidence while paused owned sources remain readable',async t=>{
|
||||
const f=fixture(t),hiddenId='hidden-sample',ownId='own-sample';f.connection.owner='operator';
|
||||
f.execution.workspace.getConnection=id=>id==='c1'?f.connection:{id:'c2',owner:'other',status:'connected'};
|
||||
const sample=(id,connectionId)=>({id,processName:f.row.processName,processVersion:'1.4',sample:{connectionId},fields:[]});
|
||||
const foreign={id:'c2',owner:'other',status:'connected'};
|
||||
f.execution.workspace.getConnection=id=>id==='c1'?f.connection:foreign;
|
||||
const sample=(id,connectionId)=>({id,processName:f.row.processName,processVersion:'1.4',sample:{connectionId,fields:{value:id==='own-sample'?'OWN FIELD':'SECRET OTHER CONNECTION'}},fields:[{value:id==='own-sample'?'OWN FIELD':'SECRET OTHER CONNECTION'}]});
|
||||
const hidden={id:'hidden-mapping',sampleId:hiddenId,check:{sampleId:hiddenId,result:{fieldTrace:[{value:'SECRET OTHER CONNECTION'}]}}};
|
||||
f.store.fields=()=>({samples:[sample(hiddenId,'c2'),sample(ownId,'c1')],adapters:[{id:'demo',reference:true},{id:'secret-active',sampleId:hiddenId,reference:false}],processes:[{processName:f.row.processName,versions:[{processVersion:'1.4',sampleIds:[hiddenId,ownId],sampleCount:2,draft:hidden,active:{...hidden},reference:{id:'demo'}}]}]});
|
||||
const operator={user:{username:'operator',role:'operator'},sessionId:'operator-session'},visible=f.execution.snapshot(operator).fields;
|
||||
assert.equal(JSON.stringify(visible).includes('SECRET OTHER CONNECTION'),false);assert.equal(visible.processes[0].versions[0].sampleCount,1);assert.deepEqual(visible.processes[0].versions[0].sampleIds,[ownId]);assert.equal(visible.adapters.length,1);
|
||||
f.connection.status='disabled';assert.equal(f.execution.snapshot(operator).fields.samples.length,0);
|
||||
assert.equal(JSON.stringify(f.execution.snapshot(principal).fields).includes('SECRET OTHER CONNECTION'),true);
|
||||
const operator={user:{username:'operator',role:'operator'},sessionId:'operator-session'};
|
||||
async function read(path,who=operator){let value;assert.equal(await orderExecutionApi({execution:f.execution,orderRules:f.store,workspace:f.execution.workspace,...who,url:new URL(path,'http://fixture'),route:path.split('?')[0],method:'GET',reply:(status,result)=>{assert.equal(status,200);value=result;}}),true);return value;}
|
||||
const execution=await read('/api/order-execution');
|
||||
assert.equal(execution.fields.processes,undefined);assert.doesNotMatch(JSON.stringify(execution),/OWN FIELD|SECRET OTHER CONNECTION/);
|
||||
const visible=await read('/api/order-rules/fields?view=directory');
|
||||
assert.doesNotMatch(JSON.stringify(visible),/OWN FIELD|SECRET OTHER CONNECTION/);
|
||||
assert.equal(visible.processes[0].versions[0].sampleCount,1);assert.deepEqual(visible.processes[0].versions[0].sampleIds,[ownId]);assert.equal(visible.processes[0].versions[0].draft,null);assert.equal(visible.processes[0].versions[0].active,null);assert.deepEqual(visible.adapters.map(a=>a.id),['demo']);
|
||||
const advanced=await read('/api/order-rules/fields');assert.match(JSON.stringify(advanced),/OWN FIELD/);assert.doesNotMatch(JSON.stringify(advanced),/SECRET OTHER CONNECTION/);
|
||||
f.connection.status='disabled';foreign.status='disabled';
|
||||
const paused=await read('/api/order-rules/fields');assert.deepEqual(paused.samples.map(s=>s.id),[ownId]);assert.doesNotMatch(JSON.stringify(paused),/SECRET OTHER CONNECTION/);
|
||||
await assert.rejects(f.execution.listFieldSamples({connectionId:'c1',scope:'configuration',idempotencyKey:'paused'},principal),e=>e.status===409);
|
||||
assert.match(JSON.stringify(await read('/api/order-rules/fields',principal)),/SECRET OTHER CONNECTION/);
|
||||
f.connection.owner='new-owner';const transferred=await read('/api/order-rules/fields?view=directory');assert.equal(transferred.samples.length,0);assert.equal(transferred.processes[0].versions[0].sampleCount,0);assert.doesNotMatch(JSON.stringify(transferred),/OWN FIELD|SECRET OTHER CONNECTION/);
|
||||
});
|
||||
@@ -16,24 +16,56 @@ test('category editor saves/reloads drafts, previews readable evidence without i
|
||||
const server=createDashboard({store,outputDir:dir});await new Promise(r=>server.listen(0,'127.0.0.1',r));
|
||||
let browser;t.after(async()=>{await browser?.close();server.closeAllConnections();await new Promise(r=>server.close(r));await fs.rm(dir,{recursive:true,force:true});});
|
||||
const sample={connectionId:'sample',source:'todo',instanceId:'i1',taskId:'t1',revision:'1',processName:'订单流程',nodeName:'通知',fields:{'订单.数量':0}};
|
||||
const data={rules:[{id:'category-1',version:1,status:'draft',name:'示例类别',categoryId:'category-1',processNames:['订单流程'],nodeNames:['通知'],adapterIds:['a1'],archiveDirectory:'',filenameDate:'appDate',subjectPrefix:'通知',intro:'正文',signature:'团队',to:[],cc:[],attachPdf:true}],adapters:[{id:'a1',label:'订单表单',verified:true,processName:'订单流程',fields:{quantity:'订单.数量'},sample}],orders:[],batches:[],settings:{version:1,enabled:false,channelId:'',maxMessageBytes:20971520},audit:[],capabilities:{liveTodo:false,pdfExport:false,automaticArchive:false}};
|
||||
const data={rules:[{id:'category-1',version:1,status:'draft',name:'示例类别',categoryId:'category-1',processNames:['订单流程'],nodeNames:['通知'],adapterIds:['a1'],archiveDirectory:'',filenameDate:'appDate',subjectPrefix:'通知',intro:'正文',signature:'团队',to:[],cc:[],attachPdf:true}],adapters:[{id:'a1',label:'订单表单',verified:true,processName:'订单流程',fields:{quantity:'订单.数量'},sample}],orders:[],batches:[],settings:{version:1,enabled:false,processingEnabled:false,processingSince:null,channelId:'',maxMessageBytes:20971520},audit:[],capabilities:{liveTodo:false,pdfExport:false,automaticArchive:false}};
|
||||
data.window={start:'2026-10-20T00:00:00+08:00',end:'2026-10-20T11:00:00+08:00',label:'工作日第一时段',available:true};
|
||||
const writes=[];browser=await loadPlaywright().chromium.launch(browserOptions());const page=await browser.newPage({viewport:{width:1440,height:1000}});page.setDefaultTimeout(7000);const errors=[];page.on('pageerror',e=>errors.push(e.message));await page.clock.install();
|
||||
await page.route('**/api/order-rules**',async route=>{const req=route.request(),url=new URL(req.url());let result=url.pathname.endsWith('/fields')?{samples:[{id:'real-1',provenance:'server-provider',processName:'订单流程',sample:{...sample,receivedAt:'2026-10-19T09:00:00+08:00'}}]}:data;if(req.method()==='POST'){const body=req.postDataJSON();writes.push({path:url.pathname,body});if(url.pathname.endsWith('/rules')){data.rules[0]={...data.rules[0],...body,version:data.rules[0].version+1};result=data.rules[0];}else if(url.pathname.endsWith('/trial'))result={valid:true,ruleId:'category-1',checks:[{label:'数量',ok:true,detail:'零数量合法'}],issues:[],explanation:'按类别汇总一封邮件',fieldTrace:[{key:'quantity',label:'数量',path:'订单.数量',value:0}],event:{orderNo:'SAMPLE-1',quantity:0}};else if(url.pathname.endsWith('/publish')){await route.fulfill({status:409,json:{error:'实时待办接入待联调,暂不可发布'}});return;}}await route.fulfill({json:result});});
|
||||
await page.route('**/api/mail',route=>route.fulfill({json:{channels:[],templates:[],receipts:[],sends:[]}}));
|
||||
await page.route('**/api/order-rules**',async route=>{
|
||||
const req=route.request(),url=new URL(req.url());let result;
|
||||
if(req.method()==='GET'){
|
||||
if(url.pathname.endsWith('/fields'))result={samples:[{id:'real-1',provenance:'server-provider',processName:'订单流程',sample:{...sample,receivedAt:'2026-10-19T09:00:00+08:00'}}]};
|
||||
else if(['/api/order-rules/orders','/api/order-rules/batches'].includes(url.pathname)){
|
||||
const items=url.pathname.endsWith('/orders')?data.orders:data.batches;
|
||||
result={items,total:items.length,page:1,pageSize:25,totalPages:1,from:items.length?1:0,to:items.length,revision:String(items.length)};
|
||||
}else if(url.pathname==='/api/order-rules'){
|
||||
assert.equal(url.searchParams.get('view'),'summary','business views must request the bounded summary');
|
||||
const {orders,batches,audit,...summary}=data;
|
||||
result={...summary,issues:[],templateUsage:[],counts:{orders:orders.length,blocked:0,unknown:0,activeBatches:batches.length}};
|
||||
}else throw Error('Unexpected fixture GET '+url.pathname);
|
||||
}else{
|
||||
const body=req.postDataJSON();writes.push({path:url.pathname,body});
|
||||
if(url.pathname.endsWith('/rules')){data.rules[0]={...data.rules[0],...body,version:data.rules[0].version+1};result=data.rules[0];}
|
||||
else if(url.pathname.endsWith('/trial'))result={valid:true,ruleId:'category-1',checks:[{label:'数量',ok:true,detail:'零数量合法'}],issues:[],explanation:'按类别汇总一封邮件',fieldTrace:[{key:'quantity',label:'数量',path:'订单.数量',value:0}],event:{orderNo:'SAMPLE-1',quantity:0}};
|
||||
else if(url.pathname.endsWith('/publish'))return route.fulfill({status:409,json:{error:'实时待办接入待联调,暂不可发布'}});
|
||||
else if(url.pathname.endsWith('/settings')){
|
||||
if(body.enabled)return route.fulfill({status:409,json:{error:'隔离校验:邮箱及归档条件未就绪,邮件不能启用'}});
|
||||
data.settings={...data.settings,...body,version:data.settings.version+1,processingSince:body.processingEnabled?'2026-10-20T02:00:00Z':data.settings.processingSince};result=data.settings;
|
||||
}else if(url.pathname.endsWith('/prepare'))result={prepared:true};
|
||||
else throw Error('Unexpected fixture POST '+url.pathname);
|
||||
}
|
||||
await route.fulfill({json:result});
|
||||
});
|
||||
await page.goto('http://127.0.0.1:'+server.address().port+'/#order-rules');await page.getByLabel('账号',{exact:true}).waitFor();assert.equal(await page.getByRole('button',{name:'进入演示空间',exact:true}).count(),0);await page.getByLabel('账号',{exact:true}).fill('admin');await page.getByLabel('密码',{exact:true}).fill('Test-password-123');await page.getByRole('button',{name:'登录',exact:true}).click();
|
||||
await openRuleRoute(page,'order-rules');await page.getByLabel('规则名称',{exact:true}).fill('订单类别更新');await page.getByLabel('收件人',{exact:true}).fill('recipient@example.test');await page.getByRole('button',{name:'保存草稿',exact:true}).click();await page.getByText('规则草稿已保存。',{exact:true}).waitFor();
|
||||
assert.equal(data.rules[0].name,'订单类别更新');assert.deepEqual(data.rules[0].to,['recipient@example.test']);assert.deepEqual(writes.find(w=>w.path.endsWith('/rules')).body.processNames,['订单流程']);
|
||||
await page.reload();await openRuleRoute(page,'order-rules');assert.equal(await page.getByLabel('规则名称',{exact:true}).inputValue(),'订单类别更新');
|
||||
await page.getByRole('button',{name:'检查识别结果',exact:true}).click();await page.locator('#order-rule-preview-result').getByText('识别通过',{exact:true}).waitFor();assert.doesNotMatch(await page.locator('#order-rule-preview-result').innerText(),/订单.数量/);assert.match(await page.locator('#order-rule-preview-result').innerText(),/0/);assert.equal(data.orders.length,0);assert.equal(writes.some(x=>x.path.endsWith('/events')),false);assert.equal(writes.find(x=>x.path.endsWith('/trial')).body.sampleId,'real-1');assert.equal(await page.locator('#order-rule-sample').count(),0);
|
||||
await page.getByRole('button',{name:'发布此版本',exact:true}).click();await page.getByText('实时待办接入待联调,暂不可发布',{exact:true}).waitFor();
|
||||
await openRuleRoute(page,'notification-settings');assert.equal(await page.getByLabel('启用自动分类通知',{exact:true}).isDisabled(),true);assert.match(await page.locator('#order-rules-panel').innerText(),/待联调/);
|
||||
await openRuleRoute(page,'notification-settings');
|
||||
const processing=page.getByLabel('自动处理订单(采集、生成 PDF、归档)',{exact:true}),mail=page.getByLabel('自动发送分类邮件',{exact:true});
|
||||
assert.equal(await processing.isEnabled(),true);assert.equal(await mail.isChecked(),false);
|
||||
await processing.check();await page.getByRole('button',{name:'保存设置',exact:true}).click();await page.getByText('设置已保存。',{exact:true}).waitFor();
|
||||
const settingsWrite=writes.find(w=>w.path.endsWith('/settings'));assert.equal(settingsWrite.body.processingEnabled,true);assert.equal(settingsWrite.body.enabled,false);assert.equal(data.settings.enabled,false);
|
||||
await mail.check();await page.getByRole('button',{name:'保存设置',exact:true}).click();await page.getByText('隔离校验:邮箱及归档条件未就绪,邮件不能启用',{exact:true}).waitFor();assert.equal(data.settings.processingEnabled,true);assert.equal(data.settings.enabled,false);await mail.uncheck();
|
||||
data.orders=[{id:'old',orderNo:'HISTORICAL-ORDER',categoryId:'category-1',status:'pending',receivedAt:'2026-10-19T09:00:00+08:00'},{id:'current',orderNo:'CURRENT-ORDER',categoryId:'category-1',status:'pending',receivedAt:'2026-10-20T09:00:00+08:00'},{id:'future',orderNo:'FUTURE-ORDER',categoryId:'category-1',status:'pending',receivedAt:'2026-10-20T15:00:00+08:00'}];
|
||||
await page.reload();await openRuleRoute(page,'notification-batches');await page.getByText('暂无待发批次',{exact:true}).waitFor();
|
||||
assert.equal(await page.getByLabel('本批截止时间(北京时间)',{exact:true}).count(),0);assert.match(await page.locator('#order-rules-panel').innerText(),/工作日第一时段/);assert.match(await page.locator('#order-rules-panel').innerText(),/CURRENT-ORDER/);assert.doesNotMatch(await page.locator('#order-rules-panel').innerText(),/HISTORICAL-ORDER|FUTURE-ORDER/);
|
||||
await page.getByRole('button',{name:'整理本时段批次',exact:true}).click();assert.deepEqual(writes.find(x=>x.path.endsWith('/prepare')).body,{cutoff:data.window.end});
|
||||
await page.locator('[data-rule-recheck="current"]').locator('..').locator('summary').click();await page.getByLabel('重新核对依据',{exact:true}).fill('已核实更新后的业务分类');await page.getByRole('button',{name:'重新核对此订单',exact:true}).click();await page.getByText('此订单已重新核对,请检查新匹配结果及归档状态。',{exact:true}).waitFor();assert.deepEqual(writes.find(x=>x.path.endsWith('/recheck')).body,{note:'已核实更新后的业务分类'});
|
||||
data.window.available=false;await page.reload();await openRuleRoute(page,'notification-batches');assert.equal(await page.getByRole('button',{name:'整理本时段批次',exact:true}).isDisabled(),true);assert.match(await page.locator('#order-rules-panel').innerText(),/当前只预览/);
|
||||
data.window.available=true;data.batches=[{id:'fresh-batch',categoryId:'category-1',subject:'自动刷新后的本时段批次',status:'prepared',windowStart:data.window.start,windowEnd:data.window.end,to:[],orderIds:[]}];await page.clock.fastForward(15001);await page.getByText('自动刷新后的本时段批次',{exact:true}).waitFor();assert.equal(await page.getByRole('button',{name:'整理本时段批次',exact:true}).isDisabled(),false);
|
||||
await openRuleRoute(page,'notification-orders');await page.getByText('HISTORICAL-ORDER',{exact:true}).waitFor();await page.getByText('CURRENT-ORDER',{exact:true}).waitFor();await page.getByText('FUTURE-ORDER',{exact:true}).waitFor();assert.equal(await page.locator('[data-rule-recheck]').count(),0,'retired inline recheck is not restored');
|
||||
data.batches=[{id:'old-batch',categoryId:'category-1',subject:'旧窗口仍未终结批次',status:'prepared',windowStart:'2026-10-19T00:00:00+08:00',windowEnd:'2026-10-19T11:00:00+08:00',orderCount:0}];
|
||||
await openRuleRoute(page,'notification-batches');await page.getByText('旧窗口仍未终结批次',{exact:true}).waitFor();
|
||||
assert.equal(await page.getByLabel('本批截止时间(北京时间)',{exact:true}).count(),0);await page.getByRole('button',{name:'整理本时段批次',exact:true}).click();await page.getByText('批次整理已完成,请核对受阻原因与冻结结果。',{exact:true}).waitFor();assert.deepEqual(writes.find(x=>x.path.endsWith('/prepare')).body,{cutoff:data.window.end});
|
||||
data.window.available=false;await page.reload();await page.getByText('未在配置发送时点的整理期限内。',{exact:true}).waitFor();assert.equal(await page.getByRole('button',{name:'整理本时段批次',exact:true}).isDisabled(),true);
|
||||
data.batches.push({id:'fresh-batch',categoryId:'category-1',subject:'后台新增批次',status:'prepared',windowStart:data.window.start,windowEnd:data.window.end,orderCount:0});
|
||||
await page.clock.fastForward(11000);await page.getByText('记录有更新。',{exact:true}).waitFor();assert.equal(await page.getByText('后台新增批次',{exact:true}).count(),0,'polling must not replace the displayed page');
|
||||
await page.locator('#content .card-header').getByRole('button',{name:'刷新记录',exact:true}).click();await page.getByText('后台新增批次',{exact:true}).waitFor();await page.getByText('旧窗口仍未终结批次',{exact:true}).waitFor();
|
||||
await openRuleRoute(page,'order-rules');await page.getByLabel('规则名称',{exact:true}).fill('保留尚未保存的规则');await page.clock.fastForward(15001);assert.equal(await page.getByLabel('规则名称',{exact:true}).inputValue(),'保留尚未保存的规则');
|
||||
await page.setViewportSize({width:390,height:844});assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth),true);assert.deepEqual(errors,[]);
|
||||
});
|
||||
@@ -64,10 +96,5 @@ test('real catalog workflow publishes a saved and sampled draft while roles and
|
||||
});
|
||||
|
||||
async function openRuleRoute(page,hash){
|
||||
if(!await page.locator('a[href="#'+hash+'"]').count()){
|
||||
const business=['order-rules','rule-fields'].includes(hash);
|
||||
await page.locator('a[href="#'+(business?'business-settings':'order-notifications')+'"]').first().click();
|
||||
if(hash==='notification-settings')await page.locator('a[href="#schedule"]').first().click();
|
||||
}
|
||||
await page.locator('a[href="#'+hash+'"]').first().click();
|
||||
await page.evaluate(hash=>{const link=document.createElement('a');link.href='#'+hash;document.body.append(link);link.click();link.remove();},hash);
|
||||
}
|
||||
@@ -40,7 +40,7 @@ test('editing while a trial is pending invalidates its output and failed saves p
|
||||
|
||||
test('saved state remains the clean baseline when the following list refresh fails',{timeout:60000},async t=>{
|
||||
const {page,runtime}=await setup(t);await page.getByLabel('规则名称',{exact:true}).fill('已保存但刷新失败');
|
||||
await page.route('**/api/order-rules',route=>route.fulfill({status:503,json:{error:'列表暂不可用'}}));
|
||||
await page.route('**/api/order-rules?view=summary',route=>route.fulfill({status:503,json:{error:'列表暂不可用'}}));
|
||||
await page.getByRole('button',{name:'保存草稿',exact:true}).click();await page.getByText(/规则草稿已保存。 刷新失败/).waitFor();
|
||||
assert.equal(runtime.orderRules.get('rules','bs-change').draft.name,'已保存但刷新失败');assert.equal(await page.getByLabel('规则名称',{exact:true}).inputValue(),'已保存但刷新失败');
|
||||
await page.getByLabel('规则名称',{exact:true}).dispatchEvent('input');
|
||||
|
||||
Reference in new issue
Block a user