Skip to content

armgit / mso

Public Imported from GitHub
0

Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.

2.6 KB
Raw Blame
import {execFileSync} from "node:child_process";import {mkdtempSync,writeFileSync,readFileSync} from "node:fs";import os from "node:os";import path from "node:path";import {expect,it} from "vitest";
const script=path.join(__dirname,"test-support/integrations-cli-tui-harness.sh");
function runTui(events:string[],prompts:string[]=[]){const dir=mkdtempSync(path.join(os.tmpdir(),"mso-integrations-finder-")),choice=path.join(dir,"events"),prompt=path.join(dir,"prompts"),log=path.join(dir,"log");writeFileSync(choice,events.join("\n")+"\n");writeFileSync(prompt,prompts.join("\n")+"\n");writeFileSync(log,"");execFileSync("bash",[script],{encoding:"utf8",env:{...process.env,MSO_TUI_CHOICES:choice,MSO_TUI_PROMPTS:prompt,MSO_TUI_LOG:log}});return readFileSync(log,"utf8").split("\n").filter(Boolean).map(line=>JSON.parse(line.split("\t").slice(1).join("\t")));}
it("Finder columns create a named connection through the same manage API",()=>{const calls=runTui(["OPEN:connections","OPEN:user:alice","OPEN:provider:github","OPEN:new","OPEN:source:direct","OPEN:auth:direct","SELECT:action:create-connection","QUIT"],["Work GitHub","work","n"]);expect(calls).toContainEqual(expect.objectContaining({mode:"manage",action:"connection.create",confirm:true,user:"alice",provider:"github",connection:"work",source:"direct",authMethod:"direct"}));});
it("Finder action column mutates only the selected connection identity",()=>{const calls=runTui(["OPEN:connections","OPEN:user:alice","OPEN:provider:github","OPEN:connection:work","SELECT:action:connection-rename","SELECT:action:connection-default","SELECT:action:connection-delete","QUIT"],["Renamed","work"]);const rows=calls.filter(x=>x.action?.startsWith("connection."));expect(rows.map(x=>x.action)).toEqual(expect.arrayContaining(["connection.rename","connection.default","connection.delete"]));expect(rows.every(x=>x.user==="alice"&&x.provider==="github"&&x.connection==="work")).toBe(true);});
it("Finder left/Esc event returns one column instead of terminating",()=>{expect(()=>runTui(["OPEN:connections","BACK","QUIT"])).not.toThrow();});

it("Finder keyboard verify shortcut executes through the exact selected identity",()=>{const calls=runTui(["OPEN:connections","OPEN:user:alice","OPEN:provider:github","OPEN:connection:work","SHORTCUT:verify","QUIT"]);const verify=calls.find(x=>x.operation==="verify");expect(verify).toMatchObject({mode:"execute",operation:"verify",user:"alice",provider:"github",connection:"work"});});
it("section events change Finder roots without creating parallel mutations",()=>{const calls=runTui(["SECTION:users","BACK","SECTION:catalog","BACK","SECTION:transfer","BACK","QUIT"]);expect(calls).toHaveLength(0);});