Files
shacraft-core/client/tests/dynamics-diagnostics.test.js
Emil c7e86663d8
MVP checks / mvp (push) Waiting to run
Expand voxel gameplay, lighting, full-height streaming and world imports
Add shared Rust/WASM physics, worker meshing and diagnostics, 64-chunk full-height streaming, atlas texture support, and baseline world import. Document the current implementation and include the supplied in-game lobby screenshot.
2026-09-17 02:10:53 +03:00

18 lines
1.6 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import {DynamicsDiagnostics} from '../dynamics-diagnostics.js';
const sample=(x=0)=>({position:[x,77,0],yaw:0,frameMs:10,physicsMs:1,drawMs:2,correction:0,waiting:false,dirty:0,viewChanges:x?2:0,batches:x?3:0,meshResets:1,loadedSections:245,totalSections:245,voxelBytes:4014080});
test('diagnostics exclude warmup, record movement and calculate bounded summaries',()=>{
const d=new DynamicsDiagnostics();d.arm('flight',5);const t=d.armed;
d.ready(sample(),false,t+100);d.frame(sample(),t+200);assert.equal(d.frames.length,0);
d.ready(sample(),true,t+500);d.ready(sample(),true,t+1001);assert.equal(d.status,'recording');
d.frame(sample(),t+1100);d.frame({...sample(16),frameMs:40},t+6100);
assert.equal(d.status,'done');assert.equal(d.result.frames,2);assert.equal(d.result.frameMs.max,40);assert.equal(d.result.over25ms,1);assert.equal(d.result.distance,16);assert.equal(d.result.meshResets,0);assert.equal(d.result.viewChanges,2);
});
test('automatic flight sends one toggle, climbs obstacles, and stops yielding input after recording',()=>{
const d=new DynamicsDiagnostics();d.arm('flight');d.status='recording';d.started=0;d.yaw=0;
assert.equal(d.controls(false,false,0).fly_toggle,true);assert.equal(d.controls(true,false,0).fly_toggle,true);assert.equal(d.controls(true,false,50).fly_toggle,false);
assert.equal(d.controls(true,true,5000,true).jump,true);assert.equal(d.controls(false,true,5500).jump,true);assert.equal(d.controls(false,true,6100).jump,false);
d.status='done';assert.equal(d.controls(true,true,6200),null);
});