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/mouth-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,readFile} 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/mouth-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-width:0;min-height: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,id)=>{
  const old=await f.locator('#bodyViewport').getAttribute('data-focus'),hidden=await f.locator('#bodyViewport').getAttribute('data-hidden');
  await openAnatomy(f);await f.locator('#anatomySearch').fill(search);await f.locator(`button[data-focus="${id}"]`).click();
  assert.equal(await f.locator('#bodyViewport').getAttribute('data-focus'),old);await f.locator('#applyFocus').click();await closeAnatomy(f);await settle();
  assert.equal(await f.locator('#bodyViewport').getAttribute('data-hidden'),hidden);
 };
 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}`);
 };
 await f.locator('#anatomyLayer').selectOption('mouth');assert.ok(await f.locator('#jawControls').isVisible());assert.equal(await f.locator('#bodyViewport').getAttribute('data-focus'),'whole','layer selection does not focus');
 await f.locator('#jawOpening').focus();await f.locator('#jawOpening').press('End');assert.equal(await f.locator('#jawOpening').inputValue(),'100');
 await f.locator('#focusMouth').click();await settle();await page.screenshot({path:`${output}/mouth-open.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.equal(await f.locator('#jawOpening').inputValue(),'100','unmarked jaw survives SDK storage reload');
 await focus('FDI 21','structure:FMA55682');await mark('FDI 21');await f.locator('#description').fill('Synthetic upper left central incisor observation.');assert.match(await f.locator('#jawScope').innerText(),/Editing concern 1/);
 await page.screenshot({path:`${output}/tooth-mark.png`});
 await f.locator('#closeJawControls').click();await f.locator('[data-pose="sitting"]').click();await f.locator('#jawControlsButton').click();assert.equal(await f.locator('#jawOpening').inputValue(),'100','body preset preserves jaw');
 await f.locator('#newConcern').click();await f.locator('#jawOpening').fill('55');await f.locator('#jawOpening').dispatchEvent('change');
 await focus('tongue','structure:FMA54640');
 await openAnatomy(f);await f.locator('#hideAllAnatomy').click();await f.locator('#anatomySearch').fill('Tongue');await f.locator('[data-visibility="structure:FMA54640"]').check();await closeAnatomy(f);await settle();
 await mark('Tongue');await f.locator('#description').fill('Synthetic tongue surface observation.');
 await page.screenshot({path:`${output}/tongue-mark.png`});
 await openAnatomy(f);await f.locator('#anatomySearch').fill('upper left teeth');await f.locator('[data-visibility="region:upper-left-teeth"]').check();assert.equal(await f.locator('[data-visibility^="structure:"]:checked').count(),7);await f.locator('[data-visibility="region:upper-left-teeth"]').uncheck();await closeAnatomy(f);
 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.equal(await f.locator('#jawOpening').inputValue(),'55');assert.equal(await f.locator('#bodyViewport').getAttribute('data-hidden'),'32');
 await f.locator('#concern-toggle-1').click();assert.equal(await f.locator('#jawOpening').inputValue(),'100');assert.equal(await f.locator('#bodyViewport').getAttribute('data-hidden'),'0');
 await f.locator('#concern-toggle-2').click();assert.equal(await f.locator('#jawOpening').inputValue(),'55');assert.equal(await f.locator('#bodyViewport').getAttribute('data-hidden'),'32');
 await f.locator('#connectionsButton').click();await f.locator('#apiKey').fill('dummy-mouth-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();assert.match(await f.locator('.review-report').innerText(),/FDI 21/i);assert.match(await f.locator('.review-report').innerText(),/jaw partly open/);
 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],/jaw open/);assert.match(captions[1],/jaw partly open/);for(const caption of captions)assert.match(caption,/No wisdom teeth, gums or palate/);
 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.equal(await f.locator('#jawOpening').inputValue(),'55','capture restores working opening');assert.equal(await f.locator('#bodyViewport').getAttribute('data-hidden'),'32');
 await openAnatomy(f);await f.locator('#showAllAnatomy').click();await closeAnatomy(f);await f.locator('#focusMouth').click();await f.locator('button[data-mode="rotate"]').click();
 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();
  for(const selector of ['#jawOpening','#closeJawControls','#focusMouth','#openJaw','#closeJaw'])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;}),selector);
  const box=await f.locator('canvas').boundingBox();assert.ok(box.height>=100&&box.width>=150,`live canvas ${w}x${h}: ${JSON.stringify(box)}`);
  await settle();await page.screenshot({path:`${output}/controls-${w}x${h}.png`});
 }
 // Check the new editor itself under both explicit host appearances.
 for(const theme of ['light','dark']){
  await size(900,600);await iframe.evaluate(e=>e.style.cssText='');
  const appearance=page.getByRole('button',{name:/Appearance:/});
  let label='';for(let i=0;i<4;i++){label=(await appearance.getAttribute('aria-label')) || await appearance.innerText();if(label.toLowerCase().includes(theme))break;await appearance.click();}
  assert.ok(label.toLowerCase().includes(theme),`host ${theme}: ${label}`);
  for(const [w,h] of [[1600,1000],[900,600],[320,560],[200,160]]){
   await size(w,h);await settle();assert.deepEqual(await f.evaluate(()=>[innerWidth,innerHeight]),[w,h]);
   const palette=await f.evaluate(()=>({accent:getComputedStyle(document.documentElement).getPropertyValue('--emphasis').trim(),background:getComputedStyle(document.querySelector('#jawControls')).backgroundColor,ink:getComputedStyle(document.querySelector('#jawControls')).color}));
   assert.deepEqual(palette,{accent:'#c43c20',background:'rgb(255, 255, 255)',ink:'rgb(32, 33, 36)'});
   await page.screenshot({path:`${output}/${theme}-${w}x${h}.png`});
  }
 }
 assert.deepEqual(errors,[]);
 const absent=await browser.newContext({viewport:{width:900,height:600}}),ap=await absent.newPage();ap.on('pageerror',e=>errors.push(e.message));
 await ap.setContent('<iframe sandbox="allow-scripts" style="position:fixed;inset:0;width:900px;height:600px;border:0"></iframe>');
 await ap.locator('iframe').evaluate((el,html)=>el.srcdoc=html,await readFile('dist/index.html','utf8'));const af=await(await ap.locator('iframe').elementHandle()).contentFrame();
 await af.locator('#app[data-ready="true"]').waitFor();await closeAnatomy(af);await af.locator('#anatomyLayer').selectOption('mouth');await af.locator('#jawOpening').fill('65');await af.locator('#jawOpening').dispatchEvent('change');await af.locator('#focusMouth').click();
 assert.equal(await af.locator('#jawOpening').inputValue(),'65');assert.match(await af.locator('#sessionStatus').innerText(),/session only/i);assert.deepEqual(errors,[]);await absent.close();
 // Exercise real pointer input with touch emulation in an isolated host session.
 const touch=await browser.newContext({viewport:{width:390,height:844},hasTouch:true,isMobile:true}),tp=await touch.newPage();await tp.goto(process.argv[2]);
 const ti=tp.locator('iframe');await ti.waitFor();const resizeTouch=async(w,h)=>{await tp.setViewportSize({width:w,height:h});await ti.evaluate((e,[w,h])=>e.style.cssText=`position:fixed;inset:0;width:${w}px;height:${h}px;z-index:9999;border:0;min-width:0;min-height:0`,[w,h]);};
 await resizeTouch(390,844);const tf=await(await ti.elementHandle()).contentFrame();await tf.locator('#app[data-ready="true"]').waitFor();await closeAnatomy(tf);await tf.locator('#anatomyLayer').selectOption('mouth');await tf.locator('#focusMouth').tap();await tf.evaluate(()=>new Promise(r=>requestAnimationFrame(()=>requestAnimationFrame(r))));
 for(const id of ['focusMouth','openJaw','closeJaw','closeJawControls']){const b=await tf.locator(`#${id}`).boundingBox();assert.ok(b.width>=44&&b.height>=44,`touch target ${id}`);}
 const slider=await tf.locator('#jawOpening').boundingBox();await tp.touchscreen.tap(slider.x+slider.width*.75,slider.y+slider.height/2);assert.ok(Number(await tf.locator('#jawOpening').inputValue())>50);
 await tp.screenshot({path:`${output}/touch-portrait.png`});await resizeTouch(844,390);await tf.evaluate(()=>new Promise(r=>requestAnimationFrame(()=>requestAnimationFrame(r))));assert.ok((await tf.locator('canvas').boundingBox()).width>500,'landscape canvas uses the full area beside controls');await tp.screenshot({path:`${output}/touch-landscape.png`});
 await tf.locator('#closeJaw').tap();assert.equal(await tf.locator('#jawOpening').inputValue(),'0');await tf.locator('#closeJawControls').tap();assert.ok(await tf.locator('#jawControlsButton').isVisible());
 console.log('PASS: adult teeth/tongue marking; FDI names; jaw controls; independent focus/visibility; per-observation and working-session SDK persistence; saved-pose evidence and capture restoration; responsive frames/themes, missing domains and emulated touch. No provider requests.');
}finally{await browser.close();}