Files
behind_glass/scripts/test-original-photo-only.mjs
horoli e358e24436 Replace project with current server release and Windows setup
Import the 2026-10-09 source release, Fastify/SQLite backend, restored source
assets, and analytics-enabled server build. Replace files from the previous
release while retaining the existing repository history.

Make builds portable across Windows and Linux, configure local startup,
normalize Windows static asset paths, and fix test fixture cleanup and file
URL handling. Exclude local environment settings, databases, dependencies,
validation output, and TypeScript build cache from version control.

Validation: npm ci, static and server builds, 106 arrival tests, and actual
local HTTP checks passed. The full suite passed 467 of 470 tests; three tests
still require QA fixtures omitted from the supplied release, documented in
README-서버실행.md.
2026-10-09 16:43:35 +09:00

53 lines
3.1 KiB
JavaScript

import assert from 'node:assert/strict';
import { readFile, readdir, access } from 'node:fs/promises';
import { test } from 'node:test';
const read = path => readFile(new URL('../' + path, import.meta.url), 'utf8');
async function files(path) {
const entries = await readdir(new URL('../' + path, import.meta.url), { withFileTypes: true });
return (await Promise.all(entries.map(entry => entry.isDirectory() ? files(path + '/' + entry.name) : path + '/' + entry.name))).flat();
}
test('ordinary photo entry preserves intact-photo flow beside an explicitly selected experiment', async () => {
const html = await read('index.html'), main = await read('src/main.ts');
assert.doesNotMatch(html, /cutout|countryside|scene-mode|누끼/);
assert.match(html, /data-pick-photo/);
assert.doesNotMatch(main, /CountrysideExperience|loadLegacyFile/);
assert.match(main,/let cutoutTexture[^;]*cutoutEnabled=false/);
assert.match(main,/onAccept\(result\)/);
assert.match(main, /imageInput\.onchange[\s\S]*?loader\.load\(file\)/);
assert.match(main, /selectedRenderer: 'a' \| 'b' = 'b'/);
});
test('experimental segmentation is lazy and the original bounded preparation remains', async () => {
const sourceFiles = await files('src');
const source = (await Promise.all(sourceFiles.map(read))).join('\n');
assert.doesNotMatch(source, /CountrysideExperience|LayeredSceneData|LayeredMeshRefraction/);
const ui=await read('src/ui/PeekingExperimentUI.ts');
assert.match(ui,/import\(['"]\.\.\/cutout\/CutoutPreparation['"]\)/);
assert.match(ui,/이 누끼로 배치/);
assert.match(source, /PHOTO_WORKING_LONG_EDGE = 1024/);
assert.match(source, /createWorkingPhotoImage/);
});
test('only the explicitly restored small model ships, while private house composites stay out of public assets', async () => {
const publicFiles = await files('public');
assert.equal(publicFiles.some(path => /assets\/countryside\//.test(path)), false);
assert.ok(publicFiles.includes('public/models/u2netp/model.onnx'));
assert.equal(publicFiles.filter(path=>path.endsWith('.onnx')).length,1);
await access(new URL('../docs/reference-assets/countryside/open-house.png', import.meta.url));
const pkg = JSON.parse(await read('package.json'));
assert.equal(Object.hasOwn(pkg.dependencies, 'onnxruntime-web'), false, 'direct runtime was only the cutout worker; Depth Anything retains its transitive ORT');
assert.equal(pkg.dependencies['@huggingface/transformers'], '^4.3.0');
assert.match(await read('vite.config.ts'), /onnxruntime-web-use-extern-wasm/);
});
test('car travel is triggered by actual depth analysis rather than photo decoding or a mask stage', async () => {
const main = await read('src/main.ts');
assert.equal([...main.matchAll(/experience\.startJourney\(\)/g)].length, 1);
const fn = main.slice(main.indexOf('async function generateAIDepth'), main.indexOf("aiDepthButton.addEventListener"));
assert.match(fn, /aiDepthBusy = true;[\s\S]*experience\.startJourney\(\);[\s\S]*await aiDepthProvider\.getDepthMap\(sourceImage\)/);
assert.match(fn, /request !== depthRequest \|\| active !== sourceTexture/);
assert.match(fn, /catch[\s\S]*experience\.setState\('error', true\)/);
});