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.

1.3 KB
Raw Blame
import { afterEach, expect, it, vi } from "vitest";
import { NextRequest } from "next/server";

afterEach(() => vi.unstubAllEnvs());

it("forces a network reload after the viewer ticket exchange", async () => {
  vi.resetModules();
  vi.stubEnv("NEXT_PUBLIC_MANAGED_APP_HOST_TEMPLATE", "{id}.mso.example.com");
  vi.stubEnv("OS_PUBLIC_ORIGIN", "https://mso.example.com");
  vi.stubEnv("OS_SESSION_COOKIE_DOMAIN", "mso.example.com");
  vi.stubEnv("CAMOUFOX_NOVNC_URL", "http://127.0.0.1:6080");
  vi.stubEnv("CAMOUFOX_VIEWER_ORIGIN", "https://camoufox-mso.example.com");
  const proxy = (await import("../../proxy")).proxy;
  const response = await proxy(new NextRequest(
    "https://camoufox-mso.example.com/__viewer_bootstrap.js",
    { headers: { host: "camoufox-mso.example.com" } },
  ));
  expect(response.status).toBe(200);
  const script = await response.text();
  expect(script).toContain("p.delete('viewer_ticket')");
  expect(script).toContain("keepalive:true");
  expect(script).toContain("await r.text()");
  expect(script.indexOf("await r.text()")).toBeLessThan(script.indexOf("history.replaceState"));
  expect(script).toContain("history.replaceState");
  expect(script).toContain("p.toString()");
  expect(script).toContain("setTimeout(()=>location.reload(),50)");
  expect(script).not.toContain("location.replace(");
});