Files
order-notification-automation/tests/order-rules/batch-history-ui.test.cjs
T

16 lines
2.7 KiB
JavaScript

'use strict';
const test=require('node:test'),assert=require('node:assert/strict');
const {orderDrivenUI}=require('../fixtures/order-driven-ui.cjs');
test('batch tabs separate sent history, survive reload/back and keep sent content read-only',{timeout:60000},async t=>{
const {page,runtime,base,sample}=await orderDrivenUI(t,'#notification-batches'),s=runtime.orderRules;
s.put('orders',{id:'history-order',categoryId:'bs-change',orderNo:'HISTORY-1',status:'sent',sample:{connectionId:sample.connectionId},event:{connectionId:sample.connectionId}});
for(const [id,status]of [['pending-batch','prepared'],['sent-batch','sent'],['cancelled-batch','cancelled']])s.put('batches',{id,status,version:1,orderIds:['history-order'],orderNos:['HISTORY-1'],categoryId:'bs-change',subject:id,createdAt:'2026-10-26T02:00:00Z',sentAt:status==='sent'?'2026-10-26T03:00:00Z':undefined,text:'Frozen body',to:['2639266652@qq.com'],cc:[],attachments:[]});
await page.getByRole('button',{name:'刷新数据',exact:true}).click();
const pending=page.getByRole('tab',{name:'待发送',exact:true}),sent=page.getByRole('tab',{name:'已发送',exact:true});await pending.waitFor();await page.getByText('pending-batch',{exact:true}).waitFor();assert.equal(await page.getByText('sent-batch',{exact:true}).count(),0);
await sent.click();await page.getByText('sent-batch',{exact:true}).waitFor();assert.match(page.url(),/scope=sent/);assert.equal(await sent.getAttribute('aria-selected'),'true');assert.equal(await page.getByText('pending-batch',{exact:true}).count(),0);
await page.getByRole('button',{name:'查看详情',exact:true}).click();const dialog=page.getByRole('dialog',{name:'业务详情',exact:true});await dialog.getByText('Frozen body',{exact:true}).waitFor();await dialog.getByText('发送时间',{exact:true}).waitFor();assert.equal(await dialog.getByRole('button',{name:'保存批次内容',exact:true}).count(),0);assert.equal(await dialog.getByRole('button',{name:'人工补发原冻结批次',exact:true}).count(),0);await dialog.getByRole('button',{name:'关闭详情',exact:true}).click();
await page.reload();await page.getByText('sent-batch',{exact:true}).waitFor();await page.getByRole('tab',{name:'待发送',exact:true}).click();await page.getByText('pending-batch',{exact:true}).waitFor();await page.goBack();await page.getByText('sent-batch',{exact:true}).waitFor();
await page.goto(base+'/#notification-batches?status=sent');await page.getByText('sent-batch',{exact:true}).waitFor();assert.equal(await page.getByRole('tab',{name:'已发送',exact:true}).getAttribute('aria-selected'),'true');
await page.getByRole('tab',{name:'全部',exact:true}).click();await page.getByText('cancelled-batch',{exact:true}).waitFor();
});