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.7 KB
Raw Blame
import { inlineScripts } from "../../scripts/test-support/inline-scripts";
import { describe, expect, it } from "vitest";
import { LEGACY_PAGE_V12_URI, LEGACY_PAGE_V11_URI, LEGACY_PAGE_V10_URI, LEGACY_PAGE_V2_URI, LEGACY_PAGE_V3_URI, LEGACY_PAGE_V9_URI, MSO_PAGE_URI, listUiResources, readUiResource } from "./ui-resources";

describe("MCP Page lifecycle and cached resource migration", () => {
  it("serves current bytes to cached Page clients without advertising legacy aliases", async () => {
    const page = await readUiResource(MSO_PAGE_URI);
    expect(await readUiResource("ui://mso/page-v13.html")).toMatchObject({ uri: "ui://mso/page-v13.html", text: page?.text });
    expect(await readUiResource(LEGACY_PAGE_V12_URI)).toMatchObject({ uri: LEGACY_PAGE_V12_URI, text: page?.text });
    expect(await readUiResource(LEGACY_PAGE_V11_URI)).toMatchObject({ uri: LEGACY_PAGE_V11_URI, text: page?.text });
    expect(await readUiResource(LEGACY_PAGE_V10_URI)).toMatchObject({ uri: LEGACY_PAGE_V10_URI, text: page?.text });
    expect(await readUiResource(LEGACY_PAGE_V2_URI)).toMatchObject({ uri: LEGACY_PAGE_V2_URI, text: page?.text });
    expect(await readUiResource(LEGACY_PAGE_V3_URI)).toMatchObject({ uri: LEGACY_PAGE_V3_URI, text: page?.text });
    expect(await readUiResource(LEGACY_PAGE_V9_URI)).toMatchObject({ uri: LEGACY_PAGE_V9_URI, text: page?.text });
    expect(await listUiResources()).toHaveLength(4);
    expect((await listUiResources()).some((resource) => resource.uri === LEGACY_PAGE_V2_URI)).toBe(false);
  });
  it("includes the Apps handshake and reviewed preview contract in valid self-contained JavaScript", async () => {
    const html = (await readUiResource(MSO_PAGE_URI))?.text ?? "";
    const script = inlineScripts(html)[0];
    expect(script).toBeTruthy();
    expect(() => new Function(script ?? "")).not.toThrow();
    for (const marker of [
      'rpcRequest("ui/initialize"',
      'appInfo:{name:"MSO Page",version:"3.0.0"}',
      'method:"ui/notifications/initialized"',
      'event.source!==window.parent',
      'if(key===lastOutputKey){',
      'dimensions.height,dimensions.maxHeight,api.maxHeight',
      'availableDisplayModes:["inline","fullscreen","pip"]',
      'frame.setAttribute("sandbox",safe.sandbox)',
      'openPath("/browser")',
    ]) expect(script).toContain(marker);
    expect(html).toContain('height:var(--page-height)');
    expect(script).not.toContain('hostMax*.48');
    expect(html).toContain('html[data-display-mode="fullscreen"] .surface{height:100vh;height:100dvh');
    expect(html).not.toContain('presentation:"fullscreen"');
    expect(script).not.toContain('play-together:embed-ready');
    expect(script).toContain('el("iframe","preview-frame")');
    expect(script).not.toContain("mountReviewedFrame");
  });
});