bend_puzzle/test/cleanup-performance-smoke-test.js

54 lines
4.1 KiB
JavaScript
Raw Normal View History

2026-07-30 15:13:53 +09:00
'use strict';
const assert=require('assert/strict');
const fs=require('fs');
const path=require('path');
const {root,app,html,css,functionSource,read}=require('./helpers/app-source');
const server=read('server.js'),realtime=read('realtime-server.js'),catalog=JSON.parse(read('store-catalog.json'));
// Retired difficulty-adjustment system must be absent from every runtime layer.
assert.equal(catalog.some(item=>item.id==='level-min-10'||item.id==='level-max-10'||item.targetMode||item.fieldRadius),false);
for(const [name,source] of [['app',app],['server',server],['realtime',realtime],['html',html]]){
assert(!source.includes('fieldOverlayCanvas'),`${name}: field overlay remains`);
assert(!source.includes('level-min-10')&&!source.includes('level-max-10'),`${name}: retired item id remains`);
assert(!source.includes('fieldAdjusted')&&!source.includes('generatedDifficulty'),`${name}: retired difficulty metadata remains`);
}
assert(!server.includes("url.pathname==='/api/player/place-field'")&&!realtime.includes('broadcastFieldEffect'));
assert(!app.includes('invalidateFieldOverlay')&&!app.includes('invalidateStoreEffectCache'));
assert.equal(catalog.length>0,true);assert.equal(catalog.filter(item=>item.id==='score-lens').length,1);
// Clicking a board must select/input only; camera navigation is explicit elsewhere.
2026-07-31 12:54:46 +09:00
assert(!app.includes('shouldTeleportToUnsolvedBoard'));
2026-07-30 15:13:53 +09:00
assert(!functionSource('bindBoard').includes('centerMeta('));
assert(!app.includes('function promoteStaticBoard('));
2026-07-31 12:54:46 +09:00
assert(!app.includes('makeStaticBoard')&&!app.includes('board-static'));
2026-07-30 15:13:53 +09:00
// Every hydrated puzzle in the visible field remains fully detailed.
assert(functionSource('desiredInteractiveBoardIds').includes('for(const id of ids)'));
assert(!app.includes('INTERACTIVE_DETAIL_CELL_BUDGET')&&!functionSource('ensureBoards').includes('makeStaticBoard(meta)'));
const makeBoard=functionSource('makeBoard');
assert(makeBoard.includes('boardCellsPath(p.valid)')&&makeBoard.includes("class:'cell-shape'"));
assert(!makeBoard.includes('cellHits.set')&&!makeBoard.includes("class:'cell-hit'"));
assert(functionSource('drawOuterEdges').includes("svgEl('path'"));
assert(functionSource('flashConfirmedCell').includes("svgEl('rect'")&&functionSource('flashConfirmedCell').includes('node.remove()'));
// Work and memory are bounded without hiding visible boards.
assert(app.includes('LOD_CHANGES_PER_PASS=1')&&app.includes('BOARD_RENDERS_PER_FRAME=6')&&app.includes('HYDRATE_CONCURRENCY=4'));
assert(functionSource('evictHydratedBoardDetails').includes('hydratedBoardLru.size>32'));
assert(functionSource('evictHydratedBoardDetails').includes('hydratedBoardBytes>8*1024*1024'));
assert(functionSource('drawPresenceLayer').includes('dpr=1')&&functionSource('drawReactionLayer').includes('dpr=1'));
assert(functionSource('scheduleNoiseBackground').includes('noisePainted')&&!functionSource('scheduleNoiseBackground').includes('setTimeout'));
assert(!functionSource('applyCamera').includes('FRAME_INTERVAL')&&app.includes('AUXILIARY_FPS=30')&&app.includes('DRAG_TARGET_FPS=60'));
// Lightweight diagnostics and larger/longer completion reward visuals.
assert(html.includes('id="fpsCounter"')&&functionSource('refreshFpsCounter').includes('FPS ${fpsLastValue}'));
assert(css.includes('.gem-particle{position:fixed')&&css.includes('width:28px;height:28px'));
assert(functionSource('completionEffect').includes('1800'));
assert(functionSource('playGemCollectionAnimation').includes('duration=reduced?520:1450'));
assert(!functionSource('bindBoard').includes('skipCompletionVisuals'));
// Purchase normalization must remain functional after deleting field purchases.
assert(server.includes('function cleanId(')&&server.includes('function storeItem('));
assert.equal(fs.existsSync(path.join(root,'docs','v47.71-input-ui-performance.md')),false);
const internalSpec=fs.readFileSync(path.join(root,'docs','internal-system.md'),'utf8');
assert(internalSpec.includes('Do not add changelog')&&internalSpec.includes('update the relevant current specification in place'));
console.log('Difficulty removal, no-click-teleport, rendering, memory, FPS, and completion visual guards passed');