okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
4fb068a8c
main
1/** Owner test round 6: short model names, one logs button, the Monitor sentence and screenshot, Tasks without the deleted list and the suggestions. */ 2import test from 'node:test' ; 3import assert from 'node:assert/strict' ; 4import { readFile } from 'node:fs/promises' ; 5import { build } from 'esbuild' ; 6import { fileURLToPath } from 'node:url' ; 7 8const src = f => fileURLToPath ( new URL ( `../src/ ${ f } ` , import . meta. url )); 9const read = f => readFile ( src ( f ), 'utf8' ); 10async function load ( file ) { 11const result = await build ({ entryPoints :[ src ( `lib/ ${ file } ` )], bundle :true , format :'esm' , platform :'node' , write :false , alias :{ react :fileURLToPath ( new URL ( './helpers/react-stub.mjs' , import . meta. url )) }, logLevel :'silent' , loader :{ '.json' :'json' } }); 12return import ( `data:text/javascript;base64, ${ Buffer . from ( result . outputFiles [ 0 ]. text ). toString ( 'base64' )} ` ); 13} 14globalThis . window ??= globalThis ; globalThis . localStorage ??= { getItem :() => null , setItem :() => {} }; 15globalThis . navigator ??= { language :'en' }; 16 17test ( 'item 1: downloaded models get a short name, family and quantization' , async () => { 18const { nativeShortName} = await load ( 'native-names.ts' ); 19assert . equal ( nativeShortName ( 'swift-iq2_xs' ), 'Swift IQ2_XS' ); 20assert . equal ( nativeShortName ( 'iq3_s' ), 'IQ3_S' ); 21assert . equal ( nativeShortName ( 'unsloth-ud-q4_k_xl' ), 'Unsloth UD-Q4_K_XL' ); 22assert . equal ( nativeShortName ( 'gyro-gyro-s' ), 'Gyro-S' ); 23assert . equal ( nativeShortName ( 'coder-iq1_m' ), 'Coder IQ1_M' ); 24assert . equal ( nativeShortName ( 'nvfp4-nvfp4' ), 'NVFP4 (Strata’s version)' ); 25assert . equal ( nativeShortName ( 'nvfp4-nvfp4-nvidia' ), 'NVFP4 (NVIDIA’s version)' ); 26assert . equal ( nativeShortName ( 'nvfp4-nvfp4-qad' ), 'NVFP4 (NVIDIA, trained for FP4)' ); 27const storage = await read ( 'components/SettingsStorage.tsx' ); 28assert . match ( storage , / title=\{m\.model_name \|\| m\.model\} / , 'the full name is the tooltip' ); 29}); 30 31test ( 'item 2: Diagnostics has one button, View logs; Save logs lives in the logs view' , async () => { 32const ops = await read ( 'components/NativeOperations.tsx' ); 33const card = ops . slice ( ops . indexOf ( 'tr("Diagnostics")' ), ops . indexOf ( '<Dialog open={showLogs}' )); 34assert . equal (( card . match ( / <Btn / g ) ?? []). length , 1 , 'one button in the Diagnostics card' ); 35assert . match ( card , / View logs / ); assert . ok ( ! /Save logs / . test ( card )); 36const dialog = ops . slice ( ops . indexOf ( '<Dialog open={showLogs}' ), ops . indexOf ( '</Dialog>' , ops . indexOf ( '<Dialog open={showLogs}' ))); 37assert . match ( dialog , / Save logs / ); 38}); 39 40test ( 'item 4: the Monitor sentence is plain words; the screenshot leaves out the model state and the conversation cache' , async () => { 41const { requestSummary} = await load ( 'monitor-summary.ts' ); 42const f = { number :( n , d = 0 ) => n . toLocaleString ( 'en' , { maximumFractionDigits :d , minimumFractionDigits :d }), tokens :n => n >= 1000 ?` ${ Math . round ( n / 1000 )} K` :String ( n ) }; 43assert . equal ( requestSummary ({ requests :18 , output :47.4 , reading :1332 , reused :91000 }, f ), 'In 18 requests your average output was 47.4 tok/s and prompt reading 1,332 tok/s, reusing 91K tokens.' ); 44assert . equal ( requestSummary ({ requests :3 , output :40 }, f ), 'In 3 requests your average output was 40.0 tok/s.' ); 45assert . equal ( requestSummary ({ requests :2 }, f ), '2 requests so far.' ); 46const monitor = await read ( 'screens/Monitor.tsx' ); 47assert . match ( monitor , / monitor-state" aria-label=\{tr\("Model state"\)\} data-snapshot-skip / ); 48assert . match ( monitor , / monitor-cache" data-snapshot-skip / ); 49assert . match ( await read ( 'lib/snapshot.ts' ), / querySelectorAll\('\[data-snapshot-skip\]'\) / ); 50}); 51 52test ( 'items 6, 7, 8: Bypass permissions everywhere, no deleted-tasks list or suggestions, a + icon, and a plain "Task removed"' , async () => { 53const tasks = await read ( 'screens/Tasks.tsx' ), detail = await read ( 'components/TaskDetail.tsx' ), editor = await read ( 'components/TaskEditor.tsx' ), tree = await read ( 'app/TaskTree.tsx' ), lib = await read ( 'lib/tasks.ts' ); 54for ( const [ name , text ] of [[ 'Tasks' , tasks ], [ 'TaskDetail' , detail ], [ 'TaskEditor' , editor ], [ 'TaskTree' , tree ]]) assert . ok ( ! /Allowed to make changes / . test ( text ), ` ${ name } still says it` ); 55assert . match ( detail , / Bypass permissions / ); assert . match ( editor , / Bypass permissions / ); 56assert . match ( lib , / mode:'bypass' / , 'a new task starts as Bypass permissions' ); 57assert . ok ( ! /Deleted tasks | task-templates | Restore / . test ( tasks ), 'no deleted list, suggestions or restore on the Tasks screen' ); 58assert . match ( tasks , / IconBtn name="plus" / ); 59assert . ok ( ! /back=\{ / . test ( tasks ) && / titleDetail=\{currentTask \? undefined / . test ( tasks ), 'nothing on the left of the navbar of an opened task (the help lines show only on the list views)' ); 60assert . ok ( ! /modelName | "Model" / . test ( detail ), 'no Model section' ); 61assert . match ( tree , / pushToast\('success', 'Task removed'\) / ); assert . match ( tasks , / pushToast\('success', 'Task removed'\) / ); 62});