fix: keep orders and batches as independent navigation entries
This commit is contained in:
1 parent
d46370df92
commit
d03a4ccd9d
9 files changed
+32
-12
No files matched your search
@@ -6,3 +6,10 @@ test('business list state preserves whitelisted filters and account separation',
|
||||
test('retired supervisor entry delegates to health without a write form',async()=>{
|
||||
let renders=0;const context={window:{HealthViews:{render:async()=>renders++}}};vm.runInNewContext(fs.readFileSync('web/modules/workspace/view.js','utf8'),context);await context.window.WorkspaceViews.supervisor({},()=>true);assert.equal(renders,1);
|
||||
});
|
||||
|
||||
test('primary order routes stay outside settings groups and configuration belongs to business settings',()=>{
|
||||
const context={window:{addEventListener(){}}};vm.runInNewContext(fs.readFileSync('web/modules/navigation/view.js','utf8'),context);const nav=context.window.AppNavigation;
|
||||
for(const route of ['notification-orders','notification-batches','notification-execution','notification-history'])assert.equal(nav.sectionFor(route),null,route);
|
||||
for(const route of ['schedule','calendar','templates','notification-settings'])assert.equal(nav.sectionFor(route),'business-settings',route);
|
||||
assert.deepEqual(Array.from(nav.groups['business-settings']),['order-rules','rule-fields','schedule']);assert.equal(nav.groups['order-notifications'],undefined);
|
||||
});
|
||||
@@ -11,11 +11,11 @@ test('compact navigation groups settings, retains deep links and role boundaries
|
||||
await page.goto(base+'/#system-settings');await page.getByLabel('账号',{exact:true}).fill(role);await page.getByLabel('密码',{exact:true}).fill(password);await page.getByRole('button',{name:'登录',exact:true}).click();
|
||||
await page.getByRole('heading',{name:'BPM 连接',exact:true}).first().waitFor();assert.equal(await page.locator('#sidebar-menu [data-view]').count(),7);
|
||||
assert.equal(await page.locator('#settings-tabs a[href="#users"]').count(),role==='admin'?1:0);
|
||||
await page.getByRole('link',{name:'邮件批次',exact:true}).click();await page.getByRole('link',{name:'通知配置',exact:true}).click();await page.locator('#schedule-form').waitFor();
|
||||
assert.equal(await page.locator('#sidebar-menu [aria-current="page"]').getAttribute('href'),'#notification-batches');
|
||||
await page.getByRole('link',{name:'业务设置',exact:true}).click();await page.getByRole('link',{name:'通知配置',exact:true}).click();await page.locator('#schedule-form').waitFor();
|
||||
assert.equal(await page.locator('#sidebar-menu [aria-current="page"]').getAttribute('href'),'#business-settings');
|
||||
await page.getByRole('link',{name:'业务设置',exact:true}).click();await page.getByRole('heading',{name:'分类通知规则',exact:true}).waitFor();
|
||||
await page.goto(base+'/#users');await page.getByRole('heading',{name:role==='admin'?'团队账号':'业务首页',exact:true}).first().waitFor();
|
||||
await page.goto(base+'/#calendar');await page.getByRole('heading',{name:'业务日历',exact:true}).waitFor();assert.equal(await page.locator('#sidebar-menu [aria-current="page"]').getAttribute('href'),'#notification-batches');
|
||||
await page.goto(base+'/#calendar');await page.getByRole('heading',{name:'业务日历',exact:true}).waitFor();assert.equal(await page.locator('#sidebar-menu [aria-current="page"]').getAttribute('href'),'#business-settings');
|
||||
await page.goto(base+'/#system-settings');await page.setViewportSize({width:390,height:844});await page.getByRole('button',{name:'展开菜单',exact:true}).click();
|
||||
await page.locator('#sidebar-menu').getByRole('link',{name:'业务设置',exact:true}).click();await page.getByRole('heading',{name:'分类通知规则',exact:true}).waitFor();
|
||||
await page.waitForFunction(()=>!document.querySelector('#sidebar-menu').classList.contains('collapsing'));assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth),true);assert.equal(await page.locator('#sidebar-menu').evaluate(el=>el.classList.contains('show')),false);assert.equal(await page.getByRole('button',{name:'展开菜单',exact:true}).getAttribute('aria-expanded'),'false');
|
||||
|
||||
@@ -3,6 +3,14 @@ const test=require('node:test'),assert=require('node:assert/strict'),fs=require(
|
||||
const {startTestDashboard,login}=require('../fixtures/dashboard-runtime.cjs');
|
||||
const {loadPlaywright,browserOptions}=require('../../src/platform/browser.cjs');
|
||||
async function fixture(t){const dir=await fs.mkdtemp(path.join(os.tmpdir(),'notification-navigation-')),runtime=await startTestDashboard({stateDir:dir,mailHistory:true}),browser=await loadPlaywright().chromium.launch(browserOptions());t.after(async()=>{await browser.close();await runtime.close();await fs.rm(dir,{recursive:true,force:true});});return {runtime,browser,base:'http://127.0.0.1:'+runtime.server.address().port};}
|
||||
|
||||
test('independent sidebar order entries have no duplicate top tabs and configuration stays in business settings',{timeout:90000},async t=>{
|
||||
const {runtime,browser,base}=await fixture(t);runtime.store.addUser({username:'viewer',password:'Test-password-123',role:'viewer'},'admin');
|
||||
for(const role of ['admin','viewer']){const page=await browser.newPage({viewport:{width:1280,height:900}});page.setDefaultTimeout(6000);await page.goto(base+'/#overview');await page.getByLabel('账号',{exact:true}).fill(role);await page.getByLabel('密码',{exact:true}).fill('Test-password-123');await page.getByRole('button',{name:'登录',exact:true}).click();
|
||||
for(const [route,title]of [['notification-orders','订单中心'],['notification-batches','邮件批次'],['notification-orders','订单中心']]){await page.locator('#sidebar-menu a[data-view='+route+']').click();await page.locator('[data-record-count]').waitFor();assert.equal(await page.locator('#view-title').innerText(),title);assert.equal(await page.locator('#settings-tabs').isVisible(),false);assert.equal(await page.locator('#settings-tabs a').count(),0);assert.equal(await page.locator('#view-breadcrumb').isVisible(),false);assert.equal(await page.locator('#sidebar-menu [aria-current=page]').count(),1);assert.equal(await page.locator('#sidebar-menu a[data-view='+route+']').getAttribute('aria-current'),'page');await page.locator('#sidebar-menu a[data-view='+route+']').click();assert.equal(new URL(page.url()).hash,'#'+route);}
|
||||
await page.setViewportSize({width:390,height:844});await page.getByRole('button',{name:'展开菜单',exact:true}).click();await page.locator('#sidebar-menu a[data-view=business-settings]').click();await page.locator('#order-rules-panel').waitFor();await page.locator('#settings-tabs').getByRole('link',{name:'通知配置',exact:true}).click();await page.locator('#schedule-form').waitFor();assert.equal(await page.locator('#sidebar-menu a[data-view=business-settings]').getAttribute('aria-current'),'page');assert.deepEqual(await page.locator('#settings-tabs a').allTextContents(),['分类通知规则','字段映射','通知配置']);assert.equal(await page.locator('#settings-tabs a[aria-current=page]').innerText(),'通知配置');assert.equal(await page.locator('#notification-config-tabs a').count(),4);await page.locator('#notification-config-tabs').getByRole('link',{name:'业务日历',exact:true}).click();await page.getByRole('heading',{name:'业务日历',exact:true}).waitFor();await page.goBack();await page.locator('#schedule-form').waitFor();await page.reload();await page.locator('#schedule-form').waitFor();assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth),true);await page.close();
|
||||
}
|
||||
});
|
||||
test('one business homepage and canonical order/batch routes preserve old deep links and configuration navigation',{timeout:90000},async t=>{
|
||||
const {runtime,browser,base}=await fixture(t),page=await browser.newPage();page.setDefaultTimeout(6000);const errors=[],writes=[],full=[];page.on('pageerror',e=>errors.push(e.message));page.on('request',r=>{if(r.method()==='POST'&&!r.url().endsWith('/login'))writes.push(r.url());if(r.url()===base+'/api/order-rules')full.push(r.url());});await page.goto(base+'/#order-notifications');await login(page);await page.getByRole('heading',{name:'业务首页',exact:true}).waitFor();assert.equal(new URL(page.url()).hash,'#overview');assert.equal(await page.locator('#sidebar-menu [data-view]').count(),7);
|
||||
for(const [route,title,canonical]of [['notification-execution','订单中心','notification-orders'],['notification-orders','订单中心','notification-orders'],['notification-history','邮件批次','notification-batches'],['notification-batches','邮件批次','notification-batches'],['schedule','发送计划','schedule'],['calendar','业务日历','calendar'],['templates','邮件模板','templates'],['notification-settings','发送设置','notification-settings']]){await page.goto(base+'/#'+route);await page.locator('#view-title').getByText(title,{exact:true}).waitFor();assert.equal(new URL(page.url()).hash,'#'+canonical+(route==='notification-history'?'?scope=all':''));if(['schedule','calendar','templates','notification-settings'].includes(route))await page.locator('#notification-config-tabs [aria-current=page]').waitFor();}
|
||||
|
||||
@@ -3,7 +3,7 @@ const {test}=require('node:test'),assert=require('node:assert/strict'),fs=requir
|
||||
const {startTestDashboard,login}=require('../fixtures/dashboard-runtime.cjs');
|
||||
const {loadPlaywright,browserOptions}=require('../../src/platform/browser.cjs');
|
||||
async function fixture(t,hash='schedule') {const dir=await fs.mkdtemp(path.join(os.tmpdir(),'web-closure-'));const runtime=await startTestDashboard({stateDir:dir,mailHistory:true});const browser=await loadPlaywright().chromium.launch(browserOptions());t.after(async()=>{await browser.close();await runtime.close();await fs.rm(dir,{recursive:true,force:true});});const page=await browser.newPage({viewport:{width:1440,height:1000}});page.setDefaultTimeout(5000);await page.goto('http://127.0.0.1:'+runtime.server.address().port+'/#'+hash);await login(page);return {page,runtime};}
|
||||
test('settings open directly with horizontal tabs, retired hashes redirect, and mobile stays inside viewport',{timeout:45000},async t=>{const {page}=await fixture(t,'business-settings');await page.locator('#order-rules-panel').waitFor();assert.equal(await page.locator('#settings-tabs a').count(),2);await page.getByRole('link',{name:'邮件批次',exact:true}).click();await page.getByRole('link',{name:'通知配置',exact:true}).first().click();await page.locator('#schedule-form').waitFor();assert.equal(await page.locator('#send-mode').count(),0);await page.goBack();await page.goBack();await page.locator('#order-rules-panel').waitFor();for(const [hash,title] of [['supervisor','系统健康'],['connections','系统健康'],['notifications','分类通知规则']]){await page.evaluate(h=>location.hash=h,hash);await page.getByRole('heading',{name:title,exact:true}).first().waitFor();}await page.evaluate(()=>location.hash='system-settings');await page.getByRole('heading',{name:'BPM 连接',exact:true}).first().waitFor();assert.equal(await page.locator('#settings-tabs a').count(),6);await page.setViewportSize({width:390,height:844});assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth),true);assert.equal(await page.locator('#settings-tabs').evaluate(e=>getComputedStyle(e).overflowX),'auto');});
|
||||
test('settings open directly with horizontal tabs, retired hashes redirect, and mobile stays inside viewport',{timeout:45000},async t=>{const {page}=await fixture(t,'business-settings');await page.locator('#order-rules-panel').waitFor();assert.equal(await page.locator('#settings-tabs a').count(),3);await page.getByRole('link',{name:'业务设置',exact:true}).click();await page.getByRole('link',{name:'通知配置',exact:true}).first().click();await page.locator('#schedule-form').waitFor();assert.equal(await page.locator('#send-mode').count(),0);await page.goBack();await page.goBack();await page.locator('#order-rules-panel').waitFor();for(const [hash,title] of [['supervisor','系统健康'],['connections','系统健康'],['notifications','分类通知规则']]){await page.evaluate(h=>location.hash=h,hash);await page.getByRole('heading',{name:title,exact:true}).first().waitFor();}await page.evaluate(()=>location.hash='system-settings');await page.getByRole('heading',{name:'BPM 连接',exact:true}).first().waitFor();assert.equal(await page.locator('#settings-tabs a').count(),6);await page.setViewportSize({width:390,height:844});assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth),true);assert.equal(await page.locator('#settings-tabs').evaluate(e=>getComputedStyle(e).overflowX),'auto');});
|
||||
test('dirty navigation offers stay discard save, suppresses duplicate saves and preserves failed inputs',{timeout:45000},async t=>{const {page}=await fixture(t);await page.locator('#schedule-form').waitFor();await page.locator('#time-first').fill('09:11');await page.getByRole('link',{name:'业务日历',exact:true}).first().click();await page.getByRole('dialog',{name:'未保存的修改'}).waitFor();await page.getByRole('button',{name:'留在此页',exact:true}).click();assert.equal(await page.locator('#time-first').inputValue(),'09:11');await page.getByRole('link',{name:'业务日历',exact:true}).first().click();await page.getByRole('button',{name:'放弃并继续',exact:true}).click();await page.locator('#day-form').waitFor();await page.getByRole('link',{name:'发送计划',exact:true}).first().click();await page.locator('#time-first').fill('09:12');let requests=0;await page.route('**/api/settings',async route=>{if(route.request().method()==='GET')return route.continue();requests++;await new Promise(r=>setTimeout(r,100));await route.fulfill({status:409,json:{error:'版本已更新,请核对'}});});await page.getByRole('button',{name:'保存发送计划',exact:true}).dblclick();await page.getByRole('alert').getByText('版本已更新,请核对',{exact:true}).waitFor();assert.equal(requests,1);assert.equal(await page.locator('#time-first').inputValue(),'09:12');await page.unroute('**/api/settings');await page.getByRole('link',{name:'业务日历',exact:true}).first().click();await page.getByRole('button',{name:'保存并继续',exact:true}).click();await page.locator('#day-form').waitFor();await page.getByRole('link',{name:'发送计划',exact:true}).first().click();assert.equal(await page.locator('#time-first').inputValue(),'09:12');});
|
||||
test('password creation is discard-only and assistant settings have a distinct route',{timeout:45000},async t=>{const {page}=await fixture(t,'account');await page.route('**/api/assistant',route=>route.fulfill({json:{settings:{version:1,runtimePath:'',apiBase:'',model:'',timeoutSeconds:60,dailyLimit:30,enabled:false,allowActions:false},conversations:[],usage:{calls:0,limit:30}}}));await page.locator('#account-current').fill('unsaved-test-secret');await page.getByRole('link',{name:'系统设置',exact:true}).click();await page.getByRole('dialog',{name:'未保存的修改'}).waitFor();assert.equal(await page.getByRole('button',{name:'保存并继续',exact:true}).count(),0);await page.getByRole('button',{name:'放弃并继续',exact:true}).click();await page.getByRole('link',{name:'助手设置',exact:true}).click();await page.locator('#assistant-settings-form').waitFor();await page.getByRole('link',{name:'工具',exact:true}).click();await page.getByRole('link',{name:'ZCode 助手',exact:true}).click();await page.locator('#assistant-compose').waitFor();assert.equal(await page.locator('#assistant-settings-form').count(),0);});
|
||||
test('execution scan, evidence-only field draft and check emit versioned contracts',{timeout:45000},async t=>{
|
||||
|
||||
@@ -3,6 +3,6 @@ test('mail management saves a real config, previews template under CSP and confi
|
||||
const dir=fs.mkdtempSync(path.join(os.tmpdir(),'mail-ui-')),store=new Store(path.join(dir,'users'));store.bootstrap('admin','Test-password-123');const mailStore=new MailStore(path.join(dir,'mail')),mail=new MailService({store:mailStore});const server=createDashboard({store,mail,outputDir:dir});let browser;
|
||||
t.after(async()=>{await browser?.close();await mail.stop();await new Promise(r=>server.close(r));mailStore.close();fs.rmSync(dir,{recursive:true,force:true});});await new Promise(r=>server.listen(0,'127.0.0.1',r));const base='http://127.0.0.1:'+server.address().port;browser=await loadPlaywright().chromium.launch(browserOptions());const page=await browser.newPage({viewport:{width:1360,height:950}});const errors=[];page.on('pageerror',e=>errors.push(e.message));await page.goto(base+'/#mail');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 page.getByRole('button',{name:'添加邮箱',exact:true}).click({timeout:5000});
|
||||
await page.getByLabel('邮箱名称',{exact:true}).fill('通知邮箱');await page.getByLabel('邮箱地址',{exact:true}).fill('orders@company.test');for(const type of ['SMTP','IMAP']){await page.getByLabel(type+' 服务器',{exact:true}).fill(type.toLowerCase()+'.company.test');await page.getByLabel(type+' 登录账号',{exact:true}).fill('orders');await page.getByLabel(type+' 密码 / 授权码',{exact:true}).fill('Secret-mail-123');}await page.getByLabel('允许提交模板的发件人',{exact:true}).fill('author@company.test');await page.getByRole('button',{name:'保存邮箱',exact:true}).click();await page.getByText('通知邮箱',{exact:true}).waitFor();assert.equal(mailStore.channels().length,1);
|
||||
const c=mailStore.channels()[0],raw=Buffer.from('From: author@company.test\r\nTo: orders@company.test\r\nSubject: [模板]Notice\r\nMIME-Version: 1.0\r\nContent-Type: text/html\r\n\r\n<table><tr><td>Template body</td></tr></table><img src="https://tracker.test/1">');const draft=mailStore.ingest(c.id,'1',1,await parseTemplate(raw,c),raw,1);await page.locator('#sidebar-menu a[data-view=notification-batches]').click();await page.getByRole('link',{name:'通知配置',exact:true}).click();await page.locator('#notification-config-tabs').getByRole('link',{name:'邮件模板',exact:true}).click();await page.getByRole('button',{name:'预览并确认',exact:true}).click();await page.frameLocator('iframe[title="邮件正文预览"]').getByText('Template body',{exact:true}).waitFor();assert.equal(mailStore.template(draft.id).status,'pending');await page.getByLabel('发信标题',{exact:true}).fill('Confirmed notice');await page.getByRole('button',{name:'确认生效',exact:true}).click();await page.getByText('模板已确认生效。',{exact:true}).waitFor();assert.equal(mailStore.template(draft.id).status,'active');
|
||||
const c=mailStore.channels()[0],raw=Buffer.from('From: author@company.test\r\nTo: orders@company.test\r\nSubject: [模板]Notice\r\nMIME-Version: 1.0\r\nContent-Type: text/html\r\n\r\n<table><tr><td>Template body</td></tr></table><img src="https://tracker.test/1">');const draft=mailStore.ingest(c.id,'1',1,await parseTemplate(raw,c),raw,1);await page.locator('#sidebar-menu a[data-view=business-settings]').click();await page.getByRole('link',{name:'通知配置',exact:true}).click();await page.locator('#notification-config-tabs').getByRole('link',{name:'邮件模板',exact:true}).click();await page.getByRole('button',{name:'预览并确认',exact:true}).click();await page.frameLocator('iframe[title="邮件正文预览"]').getByText('Template body',{exact:true}).waitFor();assert.equal(mailStore.template(draft.id).status,'pending');await page.getByLabel('发信标题',{exact:true}).fill('Confirmed notice');await page.getByRole('button',{name:'确认生效',exact:true}).click();await page.getByText('模板已确认生效。',{exact:true}).waitFor();assert.equal(mailStore.template(draft.id).status,'active');
|
||||
await page.setViewportSize({width:390,height:844});assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth),true);assert.deepEqual(errors,[]);
|
||||
});
|
||||
Reference in new issue
Block a user