Initial team BPM workspace with managed connections, scanning and mail templates
This commit is contained in:
commit
34770ed338
101 files changed
+6499
No files matched your search
@@ -0,0 +1,45 @@
|
||||
const {test}=require('node:test');
|
||||
const assert=require('node:assert/strict');
|
||||
const fs=require('node:fs');
|
||||
const os=require('node:os');
|
||||
const path=require('node:path');
|
||||
let Store, nextSlots;
|
||||
try { ({Store}=require('../src/dashboard-store.cjs')); ({nextSlots}=require('../src/schedule.cjs')); } catch(e){if(e.code!=='MODULE_NOT_FOUND')throw e;}
|
||||
function fixture(t){assert.equal(typeof Store,'function','dashboard store not implemented');const dir=fs.mkdtempSync(path.join(os.tmpdir(),'dashboard-store-'));t.after(()=>fs.rmSync(dir,{recursive:true,force:true}));return {dir,store:new Store(dir)};}
|
||||
test('configuration is persisted and stale edits cannot overwrite another colleague',t=>{
|
||||
const {dir,store}=fixture(t);
|
||||
const original=store.settings();
|
||||
assert.equal(original.schedule.timezone,'Asia/Shanghai');
|
||||
const updated=store.saveSettings({schedule:{...original.schedule,times:['10:30','16:45'],weekends:false}},original.version,'admin');
|
||||
assert.deepEqual(new Store(dir).settings().schedule.times,['10:30','16:45']);
|
||||
assert.throws(()=>store.saveSettings({schedule:original.schedule},original.version,'admin'),/已被其他人/);
|
||||
assert.throws(()=>store.saveSettings({schedule:{...updated.schedule,times:['25:00','16:00']}},updated.version,'admin'),/时间/);
|
||||
assert.throws(()=>store.saveSettings({schedule:{...updated.schedule,times:['09:00','09:00']}},updated.version,'admin'),/两个不同/);
|
||||
});
|
||||
test('admin bootstrap is one-time and credentials are hashed with usable roles',t=>{
|
||||
const {dir,store}=fixture(t);
|
||||
const admin=store.bootstrap('admin','Test-password-123');
|
||||
assert.equal(admin.role,'admin');
|
||||
assert.equal(store.authenticate('admin','wrong'),null);
|
||||
assert.equal(store.authenticate('admin','Test-password-123').id,admin.id);
|
||||
assert.throws(()=>store.bootstrap('second','Test-password-123'),/管理员/);
|
||||
const reader=store.addUser({username:'reader',password:'Reader-password-123',role:'viewer'},admin.username);
|
||||
assert.equal(reader.role,'viewer');
|
||||
assert.ok(!JSON.stringify(reader).includes('passwordHash'));
|
||||
assert.ok(!fs.readFileSync(path.join(dir,'state.json'),'utf8').includes('Test-password-123'));
|
||||
});
|
||||
test('export job records update in place and remain visible after restart',t=>{
|
||||
const {dir,store}=fixture(t);
|
||||
store.recordJob({jobId:'abc',status:'running',metadata:{order:'900001',project:'DEMO-PROJECT-001'}});
|
||||
store.recordJob({jobId:'abc',status:'success',filename:'order.pdf',path:'C:/output/order.pdf',bytes:1234});
|
||||
const jobs=new Store(dir).jobs();
|
||||
assert.equal(jobs.length,1);
|
||||
assert.equal(jobs[0].metadata.order,'900001');
|
||||
assert.equal(jobs[0].status,'success');
|
||||
});
|
||||
test('next slots follow Shanghai time, weekend policy and exact slot boundary',()=>{
|
||||
assert.equal(typeof nextSlots,'function','schedule calculation not implemented');
|
||||
const schedule={times:['09:00','17:00'],weekends:false};
|
||||
assert.deepEqual(nextSlots(schedule,new Date('2026-10-16T09:00:00Z'),2),['2026-10-19T01:00:00.000Z','2026-10-19T09:00:00.000Z']);
|
||||
assert.deepEqual(nextSlots({...schedule,weekends:true},new Date('2026-10-16T08:59:00Z'),2),['2026-10-16T09:00:00.000Z','2026-10-17T01:00:00.000Z']);
|
||||
});
|
||||
Reference in new issue
Block a user