Skip to content

An open-source, self-hosted system for apps built with web technologies.

1.5 KB
Raw Blame
import { expect, test } from "vitest"
import { parseProcessSnapshot, type ProgramSnapshot } from "@phreshos/core"
import { sdkProcess, type SdkProcessSource } from "@client/view/components/desktop-host/sdk-records"

test("Desktop preserves Endpoint service roles in SDK snapshots", () => {
  const program: ProgramSnapshot & { permissions: {} } = {
    identity: "example", reference: "program-reference", assetId: "program-assets", createdAt: "2026-10-11T00:00:00.000Z", installedAt: null,
    name: "Example", version: "0.0.0", description: null, website: null, categories: [], keywords: [], opens: [], declaredPermissions: {}, hasAgent: false,
    server: { start: true, service: false }, client: null, permissions: {}
  }
  for (const server of [null, { service: false as const }, { service: "editor-v1" }]) {
    for (const client of [null, { service: false as const }, { service: "canvas-v1" }]) {
      const source: SdkProcessSource = {
        identity: "process-identity", reference: "process-reference", program: program.identity,
        name: null, options: { language: "en" }, opened: { type: "text/markdown", uri: "file:///notes.md" }, startedAt: new Date(0), server, client
      }
      const snapshot = parseProcessSnapshot(sdkProcess(source, program))
      // What it was started to open crosses the boundary with it.
      expect(snapshot.opened).toEqual(source.opened)
      expect(snapshot.server).toEqual(server)
      expect(snapshot.client).toEqual(client)
    }
  }
})