1// Integration: JazzServer boots under Deno via jazz-napi, serves a WebSocket,2// and chains upstream (createTestMesh). Convergence assertions with a real3// Jazz client come next (lofi's Playwright fixtures pointed at node URLs).45import { assert, assertEquals } from "@std/assert";6import { createTestMesh } from "../testing/mod.ts";78async function healthy(wsUrl: string): Promise<boolean> {9 const httpUrl = wsUrl.replace(/^ws/, "http");10 try {11 const res = await fetch(new URL("/health", httpUrl));12 const body = await res.json();13 return res.status === 200 && body.status === "healthy";14 } catch {15 return false;16 }17}1819Deno.test({20 name: "two in-memory JazzServers boot and chain upstream",21 sanitizeOps: false,22 sanitizeResources: false,23 fn: async () => {24 const mesh = await createTestMesh({ nodes: 2 });25 try {26 assertEquals(mesh.nodes.length, 2);27 assert(mesh.nodes[0].url.startsWith("ws://"), `root url: ${mesh.nodes[0].url}`);28 const status = mesh.nodes[1].status();29 assertEquals(status.upstream, { url: mesh.nodes[0].url });30 assertEquals(status.mesh.state, "off");31 assert(await healthy(mesh.nodes[0].url), "root node reports healthy");32 assert(await healthy(mesh.nodes[1].url), "leaf node reports healthy");33 } finally {34 await mesh.stop();35 }36 },37});