34 lines
6.3 KiB
JavaScript
34 lines
6.3 KiB
JavaScript
'use strict';
|
|
const test=require('node:test'),assert=require('node:assert/strict');
|
|
const {orderDrivenUI}=require('../fixtures/order-driven-ui.cjs');
|
|
test('authorized users can explicitly revalidate only the original departed task while viewers cannot',{timeout:90000},async t=>{
|
|
const {page,runtime,sample,browser,base}=await orderDrivenUI(t,'#notification-orders');
|
|
for(const role of ['operator','viewer'])runtime.store.addUser({username:role,password:'Test-password-123',role},'admin');
|
|
const admin=runtime.store.users()[0],connection=runtime.workspace.createConnection({name:'重核连接',owner:'operator'},admin,runtime.store.users());
|
|
runtime.orderRules.put('execution-tasks',{id:'departed',version:1,connectionId:connection.id,categoryIds:['bs-change'],row:{...sample,connectionId:connection.id,taskId:'original-task'},status:'blocked',step:'capture',errorCode:'BPM_TASK_NOT_CURRENT',retryPolicy:'manual',error:'任务已离开通知节点'});
|
|
let writes=0;
|
|
for(const role of ['admin','operator','viewer']){
|
|
const context=role==='admin'?null:await browser.newContext(),member=context?await context.newPage():page;member.setDefaultTimeout(7000);
|
|
await member.route('**/api/order-execution/tasks/*/retry',route=>{writes++;return route.fulfill({json:{ok:true}});});
|
|
if(context){await member.goto(base+'/#notification-orders');await member.getByLabel('账号',{exact:true}).fill(role);await member.getByLabel('密码',{exact:true}).fill('Test-password-123');await member.getByRole('button',{name:'登录',exact:true}).click();}else await member.getByRole('button',{name:'刷新数据',exact:true}).click();
|
|
if(role==='viewer'){await member.getByRole('heading',{name:'订单中心',exact:true}).first().waitFor();assert.equal(await member.getByRole('button',{name:'查看详情',exact:true}).count(),0);}
|
|
else{await member.getByRole('button',{name:'查看详情',exact:true}).click();const dialog=member.getByRole('dialog',{name:'业务详情',exact:true});await dialog.getByRole('button',{name:'核验当前任务并重试',exact:true}).waitFor();const check=dialog.getByLabel('确认仅核验原通知任务;不使用历史实例替代',{exact:true});assert.equal(await check.getAttribute('required'),'');assert.equal(await dialog.getByLabel('操作依据',{exact:true}).getAttribute('required'),'');assert.match(await dialog.innerText(),/仍不存在.*保持受阻/);await dialog.getByRole('button',{name:'关闭详情',exact:true}).click();}
|
|
await context?.close();
|
|
}
|
|
assert.equal(writes,0);
|
|
});
|
|
test('test settings and rule editor name uncovered flows even when all categories are ready',{timeout:90000},async t=>{
|
|
const {page}=await orderDrivenUI(t,'#notification-orders'),name='零售国内返工订单更改评审<待适配>';
|
|
await page.route('**/api/order-rules?view=summary',async route=>{const response=await route.fetch(),data=await response.json();data.restrictedTest={id:'coverage-test',version:1,enabled:true,ruleCount:15,readyCount:15,recipient:'2639266652@qq.com',archiveRoot:'C:\\isolated',since:'2026-10-26T00:00:00Z',uncovered:[{categoryId:'domestic-change',processName:name}]};await route.fulfill({json:data});});
|
|
for(const hash of ['notification-settings','order-rules']){await page.goto(new URL('/#'+hash,page.url()).href);await page.getByText(name,{exact:true}).waitFor();assert.equal(await page.locator('待适配').count(),0);assert.match(await page.locator('#content').innerText(),/domestic-change/);}
|
|
});
|
|
test('failure modal shows field sources and actionable diagnosis without offering an unsafe immediate retry',{timeout:90000},async t=>{
|
|
const {page,runtime,sample}=await orderDrivenUI(t,'#notification-orders'),store=runtime.orderRules;
|
|
const task={id:'failed-detail',version:1,connectionId:sample.connectionId,categoryIds:['bs-change'],row:{...sample,taskId:'failure-t1',instanceId:'failure-i1'},status:'failed',step:'capture',error:'明细结构无法确定',errorCode:'FORM_STRUCTURE_UNSUPPORTED',retryPolicy:'manual',captureDiagnostics:{reason:'ROW_COUNT_MISMATCH',tableName:'OrderItems',backendRows:2,domRows:1,fieldPaths:['OrderItems.OrderNum']}};
|
|
const capture=store.recordCapture({taskId:task.id,sample:{...task.row,fields:{'OrderItems.OrderNum':'315198'}},snapshot:{processVersion:sample.processVersion,purpose:'field-mapping',fieldSources:{'OrderItems.OrderNum':{source:'DataProvider.GetFormProcessData',table:'OrderItems',column:'OrderNum',rowIndex:0}},fields:[{path:'OrderItems.OrderNum',label:'订单号',value:'315198'}]}});task.captureEvidenceId=capture.id;store.put('execution-tasks',task);
|
|
await page.getByRole('button',{name:'刷新数据',exact:true}).click();await page.getByRole('button',{name:'查看详情',exact:true}).click();
|
|
const dialog=page.getByRole('dialog',{name:'业务详情',exact:true});await dialog.getByRole('heading',{name:'采集诊断',exact:true}).waitFor();
|
|
assert.match(await dialog.innerText(),/停止自动重试/);assert.match(await dialog.innerText(),/明细行数与表单行数不一致/);assert.match(await dialog.innerText(),/DataProvider.GetFormProcessData/);assert.match(await dialog.innerText(),/OrderItems/);assert.match(await dialog.innerText(),/315198/);assert.match(await dialog.innerText(),/OrderItems.OrderNum/);assert.equal(await dialog.getByRole('button',{name:'重试失败任务',exact:true}).count(),0);
|
|
await dialog.getByRole('button',{name:'关闭详情',exact:true}).click();task.history=[{status:'failed',step:'capture',error:'之前明细行数与表单行数不一致',at:'2026-10-26T02:00:00Z'}];task.error='当前任务不在原节点';task.errorCode='BPM_TASK_NOT_CURRENT';task.captureDiagnostics={reason:'任务已离开原通知节点'};task.retryPolicy='manual';store.put('execution-tasks',task);await page.getByRole('button',{name:'刷新数据',exact:true}).click();await page.getByRole('button',{name:'查看详情',exact:true}).click();await dialog.getByText(/原通知任务的历史证据/).waitFor();assert.match(await dialog.innerText(),/之前明细行数与表单行数不一致/);await dialog.getByRole('button',{name:'关闭详情',exact:true}).click();task.errorCode='CAPTURE_FAILED';task.retryPolicy='automatic';task.nextRetryAt='2026-10-26T02:03:00Z';store.put('execution-tasks',task);await page.getByRole('button',{name:'刷新数据',exact:true}).click();await page.getByRole('button',{name:'查看详情',exact:true}).click();await dialog.getByText(/临时故障,等待退避后重试/).waitFor();
|
|
});
|