Remove demo workspace and restore formal account access

This commit is contained in:
abaishu0730 committed 2026-10-19 10:49:45 +08:00
1 parent efa982a8a1
commit 23e28a7dcb
15 files changed
+79 -171

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
'use strict';
// Test-only runtime. Exercises ordinary password authentication without background jobs.
const path=require('node:path');
const {Store}=require('../../src/modules/dashboard/store.cjs');
const {WorkspaceStore}=require('../../src/modules/workspace/store.cjs');
const {RuleStore}=require('../../src/modules/order-rules/store.cjs');
const {MailStore}=require('../../src/modules/mail/store.cjs');
const {MailService}=require('../../src/modules/mail/service.cjs');
const {createDashboard}=require('../../src/app/dashboard.cjs');
async function startTestDashboard({stateDir,mailHistory=false}){
const store=new Store(path.join(stateDir,'accounts'));store.bootstrap('admin','Test-password-123');
const workspace=new WorkspaceStore(path.join(stateDir,'workspace'));
const orderRules=new RuleStore(path.join(stateDir,'order-rules'));
const mailStore=mailHistory?new MailStore(path.join(stateDir,'mail')):null;
const mail=mailStore?new MailService({store:mailStore}):null;
const server=createDashboard({store,workspace,orderRules,mail,outputDir:stateDir});
await new Promise((resolve,reject)=>{server.once('error',reject);server.listen(0,'127.0.0.1',resolve);});
return {server,store,workspace,orderRules,mail,async close(){await mail?.stop();server.closeAllConnections();await new Promise(r=>server.close(r));workspace.close();orderRules.close();mailStore?.close();}};
}
async function login(page){await page.getByLabel('账号',{exact:true}).fill('admin');await page.getByLabel('密码',{exact:true}).fill('Test-password-123');await page.getByRole('button',{name:'登录',exact:true}).click();}
module.exports={startTestDashboard,login};