feat(storage): require readable connections before adding servers
This commit is contained in:
1 parent
b34d51432d
commit
8417b1dff8
11 files changed
+100
-20
No files matched your search
@@ -4,7 +4,7 @@ const {Store}=require('../src/dashboard-store.cjs');const {StorageStore}=require
|
||||
|
||||
test('already-managed storage previews real files locally in an isolated frame',{timeout:240000},async t=>{
|
||||
const dir=await fs.mkdtemp(path.join(os.tmpdir(),'storage-preview-ui-')),remote=path.join(dir,'remote');await fs.mkdir(remote);await makePreviewFiles(remote);
|
||||
const store=new Store(path.join(dir,'users'));store.bootstrap('admin','Test-password-123');const storageStore=new StorageStore(path.join(dir,'storage')),storage=new StorageService({store:storageStore,jobs:store,outputDir:dir,client:{area:async()=>new FileArea(remote)}});storage.saveServer({name:'已托管服务器',host:'storage.company.test',share:'orders',directory:'',username:'archive',password:'Fixture-storage-password',enabled:true});
|
||||
const store=new Store(path.join(dir,'users'));store.bootstrap('admin','Test-password-123');const storageStore=new StorageStore(path.join(dir,'storage')),storage=new StorageService({store:storageStore,jobs:store,outputDir:dir,client:{area:async()=>new FileArea(remote)}});await storage.saveServer({name:'已托管服务器',host:'storage.company.test',share:'orders',directory:'',username:'archive',password:'Fixture-storage-password',enabled:true});
|
||||
const server=createDashboard({store,storage,outputDir:dir});await new Promise(r=>server.listen(0,'127.0.0.1',r));let browser;
|
||||
t.after(async()=>{await browser?.close();await storage.stop();server.closeAllConnections();await new Promise(r=>server.close(r));storageStore.close();await fs.rm(dir,{recursive:true,force:true});});
|
||||
browser=await loadPlaywright().chromium.launch(browserOptions());const page=await browser.newPage({viewport:{width:1440,height:1000}});page.setDefaultTimeout(15000);const errors=[],external=[],failed=[],consoleErrors=[],previewRequests=[];page.on('console',m=>{if(m.type()==='error'||m.type()==='warning')consoleErrors.push(m.text());});page.on('response',r=>{if(r.url().includes('/vendor/embedpdf/'))previewRequests.push({url:r.url(),status:r.status()});});page.on('pageerror',e=>errors.push(e.message));page.on('request',r=>{if(/^https?:/.test(r.url())&&!r.url().startsWith(base+'/'))external.push(r.url());});page.on('requestfailed',r=>failed.push({url:r.url(),error:r.failure()?.errorText}));const base='http://127.0.0.1:'+server.address().port;
|
||||
|
||||
Reference in new issue
Block a user