okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge f-q4-feedmodels (d4b72bc90): the signed feed's optional models member (strata_control/feed.py, feed_models.py), setup tables and prescan, tools/strata_mcp.py catalog, packaging/feed_tool.py --models/model-files/verify-feed, the app family menu (Qwen4 prep)0fdfa40b4

main
2.5 KiB29 linesraw
1import test from 'node:test';
2import assert from 'node:assert/strict';
3import {resolve} from 'node:path';
4import {createRequire} from 'node:module';
5import {build} from 'esbuild';
6
7/* The family menu rows for the update feed's models: a model this engine cannot use is a note with its reason, not a choice; one that is allowed shows the reason beside its name. */
8const root=resolve(import.meta.dirname,'..');
9const virtual={'./ui':"export const Icon=()=>null;",'./FloatingMenu':"export const FloatingMenu=()=>null;"};
10const stubs={name:'stubs',setup(b){b.onResolve({filter:/^\.\/(ui|FloatingMenu)$/},a=>({path:a.path,namespace:'stub'}));b.onLoad({filter:/.*/,namespace:'stub'},a=>({contents:virtual[a.path],loader:'js'}));}};
11const out=await build({entryPoints:[resolve(root,'src/components/FamilySwitch.tsx')],bundle:true,write:false,platform:'node',format:'cjs',jsx:'automatic',plugins:[stubs],external:['react','react-dom','react/jsx-runtime'],loader:{'.json':'json'}});
12const require=createRequire(resolve(root,'package.json'));
13const mod={exports:{}};new Function('module','exports','require',out.outputFiles[0].text)(mod,mod.exports,require);
14const {renderToStaticMarkup}=require('react-dom/server');
15const React=require('react');
16const {FamilyMenuList}=mod.exports;
17const fam=(family,title,extra={})=>({family,title,about:'',experimental:false,images:true,sizes:[{id:family+'-x'}],...extra});
18test('a model the engine cannot use is a note with its reason; an allowed one shows the reason beside its name',()=>{
19 const reason='needs a newer Strata engine: update Strata to use it';
20 const shown=[fam('qwen3.8','Qwen3.8-Flash-Next'),fam('qwen4-test','Qwen4 Test',{feed:true,available:false,unavailable_reason:reason})];
21 const missing=[fam('later-one','Later One',{sizes:[],feed:true,available:false,unavailable_reason:"this Strata version doesn't know this model yet: update Strata to use it"})];
22 const html=renderToStaticMarkup(React.createElement(FamilyMenuList,{shown,missing,current:shown[0],onPick(){}}));
23 assert.equal((html.match(/role="menuitemradio"/g)||[]).length,2);
24 assert.equal((html.match(/role="note"/g)||[]).length,1);
25 assert(html.includes('Qwen4 Test</strong><small>'+reason+'</small>'));
26 assert(html.includes('Later One</strong><small>this Strata version doesn&#x27;t know this model yet: update Strata to use it</small>'));
27 const plain=renderToStaticMarkup(React.createElement(FamilyMenuList,{shown:[shown[0]],missing:[],current:shown[0],onPick(){}}));
28 assert(!plain.includes('<small>'));assert(!plain.includes('role="note"'));
29});