t
Some checks failed
BEND FIELD CI / release (push) Has been cancelled
BEND FIELD CI / production-bridge (push) Has been cancelled

This commit is contained in:
33333-33333 2026-08-01 22:31:04 +09:00
commit 9d70afb4cc
42 changed files with 1266 additions and 630 deletions

View file

@ -87,23 +87,10 @@ async function endpoint(){
}
async function startStaticServer(){
const types={'.html':'text/html; charset=utf-8','.js':'text/javascript; charset=utf-8','.css':'text/css; charset=utf-8','.svg':'image/svg+xml','.ttf':'font/ttf','.ico':'image/x-icon'};
const server=http.createServer((request,response)=>{
const pathname=new URL(request.url,'http://localhost').pathname;
const relative=pathname==='/'?'index.html':decodeURIComponent(pathname.slice(1));
const file=path.resolve(root,relative);
if(file!==root&&!file.startsWith(root+path.sep)){response.writeHead(403);response.end();return}
fs.readFile(file,(error,body)=>{
if(error){response.writeHead(error.code==='ENOENT'?404:500);response.end();return}
response.writeHead(200,{'content-type':types[path.extname(file)]||'application/octet-stream','cache-control':'no-store'});
response.end(body);
});
});
await new Promise((resolve,reject)=>{
server.once('error',reject);server.listen(0,'127.0.0.1',()=>{server.off('error',reject);resolve()});
});
serverPort=server.address().port;
return server;
const publicDir=path.join(temporaryRoot,'public'),dataRoot=path.join(temporaryRoot,'server-data');
process.env.HOST='127.0.0.1';process.env.PORT='0';process.env.LINK_FIELD_TEST_DATA_ROOT=dataRoot;process.env.LINK_FIELD_PUBLIC_DIR=publicDir;process.env.LINK_FIELD_APACHE_BRIDGE='0';
const service=require('../scripts/service-control');await service.deployPublicFiles(publicDir);
const application=require('../server'),result=await application.main(),server=result.server;serverPort=result.port;server._linkfieldClose=()=>application.closeApplication(result);return server;
}
async function ready(client){
@ -686,7 +673,7 @@ async function main(runProfiles=profiles,cpuRates=[1,4]){
if(startupOnly){
await sleep(12000);
const state=await client.evaluate("({ready:document.body?.dataset?.ready||null,version:document.querySelector('.brand small')?.textContent||null,boards:typeof data!=='undefined'?Object.keys(data.metas).length:null,origin:typeof data!=='undefined'&&Boolean(data.metas?.B0?.puzzle),worldGeneration:typeof data!=='undefined'?data.worldGeneration:null,turnFont:getComputedStyle(document.querySelector('.board-svg text')||document.body).fontFamily,status:document.querySelector('#statusMessage')?.textContent||'',text:document.body?.innerText?.slice(0,300)||''})");
assert(state.ready==='true'&&state.version==='v47.87'&&state.boards===1&&state.origin&&state.worldGeneration==='linkfield-single-world-20260801',`Real-browser startup state is incomplete: ${JSON.stringify(state)}`);
assert(state.ready==='true'&&state.version==='v48.0'&&state.boards===1&&state.origin&&state.worldGeneration==='linkfield-single-world-20260801',`Real-browser startup state is incomplete: ${JSON.stringify(state)}`);
assert(/DotGothic16|Press Start 2P|MS Gothic|monospace/i.test(state.turnFont),'Dot-styled game font is not active in the browser');
console.log(`Real-browser startup passed: ${JSON.stringify(state)}`);return;
}
@ -724,7 +711,7 @@ async function main(runProfiles=profiles,cpuRates=[1,4]){
}finally{
client?.close();
stopBrowserTree(edge);
server.closeAllConnections?.();await new Promise(resolve=>server.close(()=>resolve()));
if(server._linkfieldClose)await server._linkfieldClose();else{server.closeAllConnections?.();await new Promise(resolve=>server.close(()=>resolve()))}
for(let attempt=0;attempt<8;attempt++){
try{fs.rmSync(temporaryRoot,{recursive:true,force:true});break}
catch(error){if(attempt===7)console.warn(`Benchmark cleanup deferred: ${error.message}`);await sleep(150)}