char-slop/berry
multipurpose self-modifiable agentic harness
git clone https://git.t4t.associates/char-slop/berry
cb11725
main
1// The app's client signed in to a fake berry, in a happy-dom page. 2 3import { type FakeBerry , fakeBerry , withDom } from "@berry/util/dom.ts" ; 4import type { Window } from "happy-dom" ; 5import { Scope } from "./ui.ts" ; 6 7export type Page = { 8window :Window ; 9server :FakeBerry ; 10/** Disposed once the test ends. */ 11scope :Scope ; 12settle () :Promise < void >; 13}; 14 15export function withBerry ( 16test :( page :Page ) => Promise < void >, 17{ url, globals} :{ url ?:string ; globals ?:Record < string , unknown > } = {}, 18) :Promise < void > { 19const server = fakeBerry (); 20return withDom ( async ( window ) => { 21const { setToken} = await import ( "./client.ts" ); 22const scope = new Scope (); 23setToken ( "test" ); 24try { 25await test ({ window, server, scope, settle :() => window . happyDOM . waitUntilComplete () }); 26} finally { 27scope . dispose (); 28setToken ( null ); 29} 30}, { url, globals :{ ...server . globals , ...globals } }); 31}