Back to Body Journal
SOURCE / PINNED RELEASE

Made of little things.

Body Journal

Release
e8049f8da4e2…
Author-recorded commit
61c04bf0e8aa…
License
LICENSE
Author’s source reference
nostr://npub182jczunncwe0jn6frpqwq3e0qjws7yqqnc3auccqv9nte2dnd63scjm4rf/wss%3A%2F%2Fgit.napplet.soy%2F/n-6c4554844c7

Archive hash verified: 4369d778da046a8b…. The source-to-build association is the author’s claim; it has not been independently rebuilt.

tests/inspection-smoke.mjs
import {openAnatomy,closeAnatomy} from './anatomy-ui-helpers.mjs';
import assert from 'node:assert/strict';
import {createRequire} from 'node:module';
import {realpathSync} from 'node:fs';
import {mkdir,writeFile} from 'node:fs/promises';
import {execFileSync} from 'node:child_process';
const require=createRequire(realpathSync('node_modules/@napplet/conformance-cli/package.json'));
const {chromium}=require('playwright');
const info=JSON.parse(execFileSync('soyli',['browser','path','--json'],{encoding:'utf8'}));
const browser=await chromium.launch({executablePath:info.executables.find(e=>e.name==='chromium'&&e.installed).path,headless:true});
const output='.napplet-space/inspection-checks';await mkdir(output,{recursive:true});
try{
 const context=await browser.newContext({viewport:{width:1600,height:1000}}),page=await context.newPage(),errors=[];
 page.setDefaultTimeout(20000);page.on('pageerror',e=>errors.push(e.message));await page.goto(process.argv[2]);
 const iframe=page.locator('iframe');await iframe.waitFor();
 const size=async(w,h)=>{await page.setViewportSize({width:w,height:h});await iframe.evaluate((e,[w,h])=>e.style.cssText=`position:fixed;inset:0;width:${w}px;height:${h}px;z-index:9999;border:0;min-height:0;min-width:0`,[w,h]);};
 await size(1600,1000);let f=await(await iframe.elementHandle()).contentFrame();await f.locator('#app[data-ready="true"]').waitFor();await closeAnatomy(f);
 const settle=()=>f.evaluate(()=>new Promise(resolve=>requestAnimationFrame(()=>requestAnimationFrame(resolve))));
 const focus=async(search,label,mode)=>{
  await openAnatomy(f);await f.locator('#anatomySearch').fill(search);
  const previous=await f.locator('#bodyViewport').getAttribute('data-focus'),hidden=await f.locator('#bodyViewport').getAttribute('data-hidden');
  const option=f.locator('.anatomy-name').filter({hasText:label}).first();const target=await option.getAttribute('data-focus');await option.click();
  assert.equal(await f.locator('#bodyViewport').getAttribute('data-focus'),previous,'selecting alone does not focus');
  await f.locator('#applyFocus').click();await closeAnatomy(f);await settle();assert.equal(await f.locator('#bodyViewport').getAttribute('data-hidden'),hidden,'focusing does not change visibility');
  if(mode){await openAnatomy(f);await f.locator('#hideAllAnatomy').click();await f.locator('#anatomySearch').fill(search);await f.locator(`[data-visibility="${target}"]`).check();await closeAnatomy(f);await settle();}

 };
 const mark=async(label)=>{
  await f.locator('button[data-mode="paint"]').click();const b=await f.locator('canvas').boundingBox();
  for(const y of [.5,.45,.55,.4,.6,.35,.65])for(const x of [.5,.45,.55,.4,.6,.35,.65]){
   await page.mouse.move(b.x+b.width*x,b.y+b.height*y);
   if((await f.locator('#sceneHint').innerText()).toLowerCase().includes(label.toLowerCase())){await page.mouse.click(b.x+b.width*x,b.y+b.height*y);return;}
  }
  throw new Error(`Cannot paint ${label}`);
 };
 // Keyboard-select a focus without hiding anatomy, then exercise parent propagation.
 await focus('left hand','Left hand');
 await openAnatomy(f);
 await f.locator('#anatomySearch').fill('left arm');
 const arm=f.locator('[data-visibility="region:left-arm"]'),hand=f.locator('[data-visibility="region:left-hand"]'),finger=f.locator('[data-visibility="region:left-index"]');
 await arm.uncheck();assert.equal(await hand.isChecked(),false);assert.equal(await finger.isChecked(),false);
 await hand.check();assert.equal(await finger.isChecked(),true);assert.ok(await arm.evaluate(e=>e.indeterminate));
 await f.locator('[data-visibility="region:left-index-tip"]').uncheck();assert.ok(await hand.evaluate(e=>e.indeterminate));assert.ok(await finger.evaluate(e=>e.indeterminate));
 await arm.check();assert.equal(await f.locator('[data-visibility="region:left-index-tip"]').isChecked(),true);
 assert.equal(await f.locator('#bodyViewport').getAttribute('data-focus'),'region:left-hand','checkboxes leave focus alone');
 await settle();await page.screenshot({path:`${output}/visibility-tree.png`});await closeAnatomy(f);
 await focus('left index','Left index finger','isolate');assert.equal(await f.locator('#bodyViewport').getAttribute('data-focus'),'region:left-index');
 await mark('Left index finger');await f.locator('#description').fill('Synthetic focused finger observation.');
 await settle();await page.screenshot({path:`${output}/finger.png`});
 const b=await f.locator('canvas').boundingBox();await page.mouse.move(b.x+b.width*.5,b.y+b.height*.5);await page.mouse.down({button:'right'});await page.mouse.move(b.x+b.width*.5+75,b.y+b.height*.5+15,{steps:8});await page.mouse.up({button:'right'});
 assert.equal(await f.locator('#concernCount').innerText(),'1','Right drag rotates without painting');
 await f.locator('#newConcern').click();await f.locator('#anatomyLayer').selectOption('organs');await focus('stomach','Stomach','fade');await mark('Stomach');
 await f.locator('#description').fill('Synthetic focused organ observation.');await f.locator('[data-pose="sitting"]').click();
 await settle();await page.screenshot({path:`${output}/stomach.png`});
 await f.waitForFunction(()=>document.querySelector('#sessionStatus').textContent==='Session saved');await page.reload();await iframe.waitFor();await size(1600,1000);
 f=await(await iframe.elementHandle()).contentFrame();await f.locator('#app[data-ready="true"]').waitFor();await closeAnatomy(f);
 assert.match(await f.locator('#anatomySelection').textContent(),/Stomach/);assert.ok(Number(await f.locator('#bodyViewport').getAttribute('data-hidden'))>0);
 assert.equal(await f.locator('[data-pose="sitting"]').getAttribute('aria-pressed'),'true');
 await f.locator('#concern-toggle-1').click();assert.match(await f.locator('#anatomySelection').textContent(),/Left index finger/);assert.ok(Number(await f.locator('#bodyViewport').getAttribute('data-hidden'))>0);
 assert.equal(await f.locator('#anatomyLayer').inputValue(),'skin');assert.equal(await f.locator('[data-pose="standing"]').getAttribute('aria-pressed'),'true');
 await f.locator('#concern-toggle-2').click();assert.match(await f.locator('#anatomySelection').textContent(),/Stomach/);
 await f.locator('#connectionsButton').click();await f.locator('#apiKey').fill('dummy-inspection-test');await f.locator('#bridgePubkey').fill('a'.repeat(64));await f.locator('#bridgeTrust').check();await f.locator('#closeModal').click();
 await f.locator('[data-page="review"]').first().click();await f.locator('[data-ai="request"]').click();
 assert.equal(await f.locator('.evidence-gallery img').count(),2);
 const captions=await f.locator('.evidence-gallery figcaption').allTextContents();assert.match(captions[0],/Saved view · Left index finger · visibility selection/);assert.match(captions[1],/Saved view · Stomach · visibility selection/);
 for(let i=0;i<2;i++){const data=await f.locator('.evidence-gallery img').nth(i).getAttribute('src');await writeFile(`${output}/evidence-${i+1}.jpg`,Buffer.from(data.split(',')[1],'base64'));}
 await f.locator('#closeModal').click();await f.locator('[data-page="map"]').first().click();assert.match(await f.locator('#anatomySelection').textContent(),/Stomach/);assert.ok(Number(await f.locator('#bodyViewport').getAttribute('data-hidden'))>0);
 const hiddenBeforeReset=await f.locator('#bodyViewport').getAttribute('data-hidden');await openAnatomy(f);await f.locator('#wholeBody').click();await closeAnatomy(f);assert.equal(await f.locator('#bodyViewport').getAttribute('data-focus'),'whole');assert.equal(await f.locator('#bodyViewport').getAttribute('data-hidden'),hiddenBeforeReset,'whole body only resets camera');
 for(const [w,h] of [[900,600],[320,560],[390,844],[844,390],[200,160]]){
  await size(w,h);assert.deepEqual(await f.evaluate(()=>[innerWidth,innerHeight]),[w,h]);if(w<280||h<280){assert.ok(await f.locator('.minimum-notice').isVisible());continue;}
  if(w<761&&h>440)await f.locator('button[data-panel="body"]').click();
  await f.locator('#anatomyLayer').selectOption('skin');await focus('right hand','Right hand','fade');
  for(const selector of ['#anatomyToggle','#anatomyLayer'])assert.ok(await f.locator(selector).evaluate(e=>{const b=e.getBoundingClientRect();return b.left>=0&&b.top>=0&&b.right<=innerWidth&&b.bottom<=innerHeight;}));
  await settle();await page.screenshot({path:`${output}/focus-${w}x${h}.png`});
  await openAnatomy(f);await f.locator('#anatomySearch').fill('tongue');assert.equal(await f.locator('.anatomy-name').count(),0);await settle();await page.screenshot({path:`${output}/picker-${w}x${h}.png`});await closeAnatomy(f);
  await openAnatomy(f);await f.locator('#anatomySearch').fill('left arm');await settle();await f.locator('[data-visibility="region:left-arm"]').check();
  await page.screenshot({path:`${output}/visibility-${w}x${h}.png`});await closeAnatomy(f);
 }
 assert.deepEqual(errors,[]);console.log('PASS: independent focus and hierarchical visibility, finger and organ picking, right-drag rotation, independent saved views, reload, SDK autosave, saved-angle evidence, camera-only whole-body reset and responsive focus controls; no provider requests.');
}finally{await browser.close();}