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\)/); });