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.

11.7 KB
Raw Blame
#!/usr/bin/env node
// Required release journeys against a built app with synthetic stores and a local provider.
import { execFileSync } from "node:child_process";
import { chromium, expect } from "@playwright/test";
import AxeBuilder from "@axe-core/playwright";
import { mcpOwnerJourneys, mcpPublicJourney, oauthRegistrationJourney, settingsAccessibilityJourney } from "./mcp-settings.mjs";
import { automationJourney } from "./automation.mjs";
import { organizationJourney } from "./organization.mjs";
import { agentVaultJourney } from "./agent-vault.mjs";
import { workflowCanvasJourney } from "./workflow-canvas.mjs";
import { storeExtensionsJourney } from "./store-extensions.mjs";
import { releaseFixture } from "./release-fixture.mjs";
import { camoufoxConnectionJourney } from "./camoufox-connection.mjs";
import { memoryBackupHistoryJourney } from "./memory-backup-history.mjs";
import { aiProviderSwitchJourney } from "./ai-provider-switch.mjs";
import { shellNoticesJourney } from "./shell-notices.mjs";
import { settingsDraftJourney } from "./settings-draft.mjs";

execFileSync(process.execPath, ["scripts/e2e/socket-authority.mjs"], { stdio: "inherit", timeout: 30000 });
execFileSync(process.execPath, ["scripts/e2e/request-bodies.mjs"], { stdio: "inherit", timeout: 60000 });
execFileSync(process.execPath, ["scripts/e2e/shell-apps.mjs"], { stdio: "inherit" });
execFileSync(process.execPath, ["scripts/e2e/mcp-page.mjs"], { stdio: "inherit" });
execFileSync(process.execPath, ["scripts/e2e/workflow-embeds.mjs"], { stdio: "inherit" });
execFileSync(process.execPath, ["scripts/e2e/organization-flow.mjs"], { stdio: "inherit" });
execFileSync(process.execPath, ["scripts/e2e/graph-custom.mjs"], { stdio: "inherit" });
execFileSync(process.execPath, ["scripts/e2e/nakama-slices.mjs"], { stdio: "inherit" });
execFileSync(process.execPath, ["scripts/e2e/orca-rewrite.mjs"], { stdio: "inherit", timeout: 120000 });
const fixture = await releaseFixture();
let browser;
try {
  execFileSync(process.execPath, ["node_modules/vitest/vitest.mjs", "run", "--config", "scripts/e2e/vitest.config.mts"], { env: { ...process.env, E2E_BASE_URL: fixture.base }, stdio: "inherit" });
  browser = await chromium.launch({ headless: true });
  for (const viewport of [{ width: 1363, height: 936 }, { width: 390, height: 844 }, { width: 844, height: 390 }]) {
    const context = await browser.newContext({ viewport });
    const page = await context.newPage();
    const errors = [];
    page.on("pageerror", error => errors.push(error.message));
    await page.goto(fixture.base + "/integrations");
    await expect(page.locator("#mso-boot-splash")).toHaveCount(0);
    const sections = page.getByRole("navigation", { name: "Integrations sections", exact: true });
    if (viewport.width < 600) await expect(sections).not.toBeVisible();
    else await expect(sections).toBeVisible();
    await expect(page.getByRole("heading", { name: "GitHub", exact: true, level: 2 })).toBeVisible();
    if (viewport.width < 600) {await page.getByRole("button", { name: "Integrations sections", exact: true }).click();await expect(sections).toBeVisible();await sections.getByRole("button", { name:"GitHub", exact:true }).click();await expect(sections).not.toBeVisible();}
    else {await page.getByLabel("Search integrations").fill("GitHub");await page.getByRole("navigation", { name: "Integrations sections", exact: true }).getByRole("button", { name:"GitHub", exact:true }).click();}
    await expect(page.getByRole("heading", {name:"GitHub", exact:true})).toBeVisible();
    await page.getByText("Connection methods & setup guides", { exact: true }).click();
    await expect(page.getByRole("link", { name: "Official setup page" }).first()).toBeVisible();
    expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth + 1)).toBe(true);
    const accessibility = await new AxeBuilder({ page }).withTags(["wcag2a", "wcag2aa", "wcag21aa"]).analyze();
    expect(accessibility.violations.map(v => ({ id: v.id, targets: v.nodes.map(n => n.target) }))).toEqual([]);
    const popupPromise = context.waitForEvent("page");
    await page.getByRole("link", { name: "Sign in to MSO as Owner" }).click();
    const login = await popupPromise;
    await expect(login.getByRole("heading", { name: "Sign in to your server" })).toBeVisible();
    await login.close();
    await page.goto(fixture.base);
    await expect(page.getByLabel("Server connection mode")).toHaveAttribute("data-connection-mode", "mock");
    // Real launcher click, not only deep-link route mounting.
    const settingsName = /^(System )?Settings(?: \(running\))?$/;
    const settings = viewport.width >= 768
      ? page.getByRole("link", { name: settingsName }).first()
      : page.getByRole("button", { name: settingsName }).first();
    await expect(settings).toBeVisible();
    await settings.hover(); // Let dock magnification move its hit target before pressing.
    await settings.click();
    await expect(page).toHaveURL(/\/settings/);
    await expect(page.getByLabel("Server connection mode")).toHaveAttribute("data-connection-mode", "mock");
    expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth + 1)).toBe(true);
    if (viewport.width < 768) {
      const title = page.locator('[data-slot="mobile-feature-header"]').getByText("Settings", { exact: true });
      await expect(title).toBeVisible();
      await expect.poll(async () => {
        const badge = await page.getByLabel("Server connection mode").boundingBox();
        const heading = await title.boundingBox();
        return badge && heading ? badge.y + badge.height <= heading.y : false;
      }).toBe(true);
    }
    for (const theme of ["dark", "light"]) {
      await page.evaluate(theme => {document.documentElement.dataset.theme=theme}, theme);
      expect(await page.locator("body").evaluate(el => getComputedStyle(el).colorScheme)).toBe(theme);
      expect(await page.locator("body").evaluate(el => getComputedStyle(el).scrollbarWidth)).toBe("thin");
    }
    await page.emulateMedia({forcedColors:"active"});
    expect(await page.locator("body").evaluate(el => getComputedStyle(el).scrollbarColor)).toBe("auto");
    await page.emulateMedia({forcedColors:"none"});
    await mcpPublicJourney(page);
    await settingsAccessibilityJourney(page, fixture.base);
    expect(errors).toEqual([]);
    await context.close();
    console.log(`PASS public guides, login entry, launcher and reflow ${viewport.width}x${viewport.height}`);
  }
  const context = await browser.newContext({ viewport: { width: 1280, height: 900 } });
  await context.addInitScript(device => {
    localStorage.setItem("mso.device.id", device);
    localStorage.setItem("mso:onboarding:v1", "done");
  }, fixture.device);
  const page = await context.newPage();
  await page.goto(fixture.base + "/login?returnTo=%2Fintegrations");
  await page.locator('input[type="password"]').fill(fixture.password);
  await page.getByRole("button", { name: "Unlock", exact: true }).click();
  await expect(page).toHaveURL(fixture.base + "/integrations");
  await settingsDraftJourney(page, fixture);
  await agentVaultJourney(page, fixture);
  await page.goto(fixture.base + "/integrations");
  await shellNoticesJourney(page, fixture);
  await expect(page.getByRole("group", { name: "Credential owner" }).getByRole("button")).toContainText("fixture");
  await page.getByRole("navigation", { name: "Integrations sections", exact: true }).getByRole("button", { name: "AI Providers", exact: true }).click();
  await expect(page.getByRole("heading", { name: "AI Providers", exact: true })).toBeVisible();
  await expect(page.getByRole("heading", { name: "JEV decision kernel", exact: true })).toBeVisible();
  await expect(page.getByText("Actual JEV input / cost · 30d", { exact: true })).toBeVisible();
  await expect(page.getByText("Estimated LLM input / cost avoided · 30d", { exact: true })).toBeVisible();
  await page.getByText("JEV Lab · bounded decision test", { exact: true }).click();
  await expect(page.getByText("JEV Lab never executes tools, writes memory, or promotes recipes.")).toBeVisible();
  await page.getByRole("button", { name: "Run bounded test", exact: true }).click();
  await expect(page.getByRole("status")).toContainText("JEV Lab decision complete; no action executed.");
  await storeExtensionsJourney(page, fixture);
  await page.goto(fixture.base + "/integrations");
  await page.getByRole("navigation", { name: "Integrations sections", exact: true }).getByRole("button", { name: "Transfer & backup", exact: true }).click();
  await expect(page.getByRole("heading", { name: "Transfer & backup", exact: true })).toBeVisible();
  await expect(page.getByLabel("Export scope")).toHaveValue("all");
  await page.getByLabel("Export scope").selectOption("custom");
  await expect(page.getByText("Release fixture · fixture", { exact: true })).toBeVisible();
  await page.getByLabel("Export scope").selectOption("all");
  await page.getByLabel("Export format").selectOption("env");
  await page.getByLabel("MSO owner password").fill(fixture.password);
  await page.getByLabel("I understand this download contains plaintext credentials").check();
  const rawDownloadPromise = page.waitForEvent("download");
  await page.getByRole("button", { name: "Re-authenticate & download", exact: true }).click();
  const rawDownload = await rawDownloadPromise;
  expect(rawDownload.suggestedFilename()).toMatch(/\.env$/);
  await expect(page.locator('.portable-transfer [role="status"]')).toContainText("one-time export grant is now invalid");
  await page.getByRole("button", { name: "← Connections", exact: true }).click();
  await page.getByRole("button", { name: /^Convex$/ }).click();
  await page.getByRole("button", { name: "Verify", exact: true }).click();
  await expect(page.locator(".connection-state")).toHaveText("Verified");
  await expect(page.getByRole("status")).toContainText("Verified: authenticated");
  fixture.revokeProvider();
  await page.getByRole("button", { name: "Verify", exact: true }).click();
  await expect(page.locator(".connection-state")).toHaveText("Access rejected");
  await page.reload();
  await page.getByRole("button", { name: /^Convex$/ }).click();
  await expect(page.locator(".connection-state")).toHaveText("Access rejected");
  const call = (route, body) => page.evaluate(async ([route, body]) => {
    const res = await fetch(route, body ? { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(body) } : {});
    return { status: res.status, body: await res.json() };
  }, [route, body]);
  const exec = await call("/api/v1/exec/run", { cmd: "pwd", cwd: fixture.dir });
  expect(exec.status).toBe(200); expect(exec.body.cwd).toBe(fixture.dir);
  expect((await call("/api/v1/exec/run", { cmd: "exit 0", cwd: fixture.dir + "/missing" })).status).not.toBe(200);
  expect((await call("/api/v1/fs/list?path=" + encodeURIComponent(fixture.dir))).status).toBe(200);
  await camoufoxConnectionJourney(page, fixture);
  await mcpOwnerJourneys(page, fixture);
  await oauthRegistrationJourney(page, fixture);
  await automationJourney(page, fixture);
  await organizationJourney(page, fixture);
  await workflowCanvasJourney(page, fixture);
  await aiProviderSwitchJourney(page, fixture);
  await memoryBackupHistoryJourney(page, fixture);
  await fixture.setRole("viewer");
  expect((await call("/api/v1/agent-sessions?view=monitor")).status).toBe(403);
  expect((await call("/api/v1/integrations")).status).toBe(403);
  // Legacy privileged shell routes return 401 for a non-owner session.
  expect((await call("/api/v1/exec/run", { cmd: "pwd", cwd: fixture.dir })).status).toBe(401);
  console.log("PASS browser login/return, live provider revocation, reload, file/exec boundaries and immediate role demotion");
  await context.close();
} finally {
  await browser?.close();
  await fixture.close();
}
console.log("release E2E: all required journeys passed");