Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
/**
* The Publish Studio: the doors, the form, the check, the submit.
*
* Pinned here: the entry screen offers every way a package can arrive, a
* blank skill starts with a template rather than an empty box, the Check
* button runs the backend's own validator and reports its field errors where
* the field is, and Publish stays disabled until somebody is signed in.
*
* No jest-dom in this repo — assertions use toBeTruthy()/toBeNull().
*/
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { cleanup, fireEvent, render, screen } from "@testing-library/react";
import { afterEach, describe, expect, it, vi } from "vitest";
vi.mock("@/lib/openExternal", () => ({ openExternalUrl: vi.fn() }));
vi.mock("@/lib/clipboard", () => ({ robustCopy: vi.fn(async () => true) }));
import { PublishStudio } from "@/components/marketplace/PublishStudio";
import type { PublishIdentityWire } from "@/components/marketplace/PublishIdentity";
import { setUiLanguage } from "@/i18n";
const SIGNED_IN: PublishIdentityWire = {
enabled: true,
signed_in: true,
login: "octocat",
avatar_url: null,
};
const SIGNED_OUT: PublishIdentityWire = { enabled: true, signed_in: false };
function stubServer(identity: PublishIdentityWire, opts?: { validateErrors?: unknown[] }) {
const calls: { url: string; body?: unknown }[] = [];
const json = (body: unknown, ok = true, status = 200) => ({ ok, status, json: async () => body });
vi.stubGlobal(
"fetch",
vi.fn(async (input: unknown, init?: { method?: string; body?: string | FormData }) => {
const url = String(input);
const method = (init?.method ?? "GET").toUpperCase();
calls.push({
url,
body: typeof init?.body === "string" ? JSON.parse(init.body) : init?.body,
});
if (url === "/api/marketplace/publish/identity" && method === "GET") return json(identity);
if (url === "/api/marketplace/publish/validate") {
return json({ ok: !(opts?.validateErrors?.length), errors: opts?.validateErrors ?? [] });
}
if (url === "/api/marketplace/publish/submit") {
const body = JSON.parse(typeof init?.body === "string" ? init.body : "{}") as {
name: string;
version: string;
};
return json(
{
ok: true,
name: body.name,
version: body.version,
pr_url: "https://github.com/Dodaios/marketplace/pull/1",
install: {
cli: `jarvis marketplace install ${body.name}`,
runner: `uvx --from personal-jarvis jarvis marketplace install ${body.name}`,
prompt: `Install the "${body.name}" skill from the community marketplace.`,
},
},
true,
201,
);
}
if (url.startsWith("/api/marketplace/publish/status")) return json({ live: true });
return json({});
}),
);
return calls;
}
function renderStudio(onClose = () => undefined) {
const client = new QueryClient({ defaultOptions: { queries: { retry: false } } });
return render(
<QueryClientProvider client={client}>
<PublishStudio onClose={onClose} />
</QueryClientProvider>,
);
}
afterEach(() => {
cleanup();
vi.unstubAllGlobals();
setUiLanguage("en");
});
describe("PublishStudio", () => {
it("opens on the package doors, with no wallpaper lane", async () => {
stubServer(SIGNED_IN);
renderStudio();
expect(await screen.findByTestId("studio-door-folder")).toBeTruthy();
expect(screen.getByTestId("studio-door-github")).toBeTruthy();
expect(screen.queryByTestId("studio-door-wallpaper")).toBeNull();
// The rail lights the "what" station once somebody is signed in.
await screen.findByText(/Signed in as @octocat/);
});
it("closes on Escape", async () => {
stubServer(SIGNED_IN);
const onClose = vi.fn();
renderStudio(onClose);
await screen.findByTestId("studio-door-folder");
fireEvent.keyDown(window, { key: "Escape" });
expect(onClose).toHaveBeenCalledTimes(1);
});
it("starts a blank skill with a template, checks it, and publishes it", async () => {
const calls = stubServer(SIGNED_IN);
renderStudio();
await screen.findByTestId("studio-door-folder");
fireEvent.click(screen.getByRole("button", { name: /^Skill$/ }));
const form = await screen.findByTestId("studio-form");
expect(form).toBeTruthy();
// The SKILL.md box is pre-filled — nobody starts at an empty document.
expect((screen.getByDisplayValue(/name: my-skill/) as HTMLTextAreaElement).value).toContain(
"---",
);
// The live card preview follows the name.
fireEvent.change(screen.getByTestId("studio-name"), { target: { value: "three-point-check" } });
expect(screen.getByTestId("studio-card-preview").textContent).toContain("three-point-check");
fireEvent.click(screen.getByRole("button", { name: "Check" }));
expect(await screen.findByTestId("studio-check-ok")).toBeTruthy();
const validate = calls.find((c) => c.url === "/api/marketplace/publish/validate");
expect(validate?.body).toMatchObject({ kind: "skill", name: "three-point-check", version: "1.0.0" });
fireEvent.click(screen.getByTestId("studio-publish"));
const done = await screen.findByTestId("studio-published");
expect(done.textContent).toContain("three-point-check");
expect(done.textContent).toContain("View the submission");
});
it("puts a field error where the field is", async () => {
stubServer(SIGNED_IN, {
validateErrors: [{ field: "version", error: "version must be plain SemVer, e.g. 1.0.0" }],
});
renderStudio();
await screen.findByTestId("studio-door-folder");
fireEvent.click(screen.getByRole("button", { name: /^Skill$/ }));
await screen.findByTestId("studio-form");
fireEvent.click(screen.getByRole("button", { name: "Check" }));
expect(await screen.findByText(/version must be plain SemVer/)).toBeTruthy();
expect(screen.queryByTestId("studio-check-ok")).toBeNull();
});
it("keeps Publish disabled until somebody is signed in", async () => {
stubServer(SIGNED_OUT);
renderStudio();
await screen.findByTestId("studio-door-folder");
fireEvent.click(screen.getByRole("button", { name: /^Skill$/ }));
await screen.findByTestId("studio-form");
expect((screen.getByTestId("studio-publish") as HTMLButtonElement).disabled).toBe(true);
});
it("says so when publishing is disabled in this deployment", async () => {
stubServer({ enabled: false, signed_in: false });
renderStudio();
expect(await screen.findByText(/Publishing is disabled/)).toBeTruthy();
});
it("offers a single-file door next to the folder one, and a lone SKILL.md lands in the form", async () => {
stubServer(SIGNED_IN);
renderStudio();
await screen.findByTestId("studio-door-folder");
// The link is the visible promise that a skill does not need a folder.
expect(screen.getByTestId("studio-door-skill-file")).toBeTruthy();
const input = screen.getByTestId("studio-skill-file-input") as HTMLInputElement;
expect(input.hasAttribute("webkitdirectory")).toBe(false);
const file = new File(
["---\nname: todo-triage\ndescription: Sort tasks.\n---\n\nGroup by due date.\n"],
"todo-triage.md",
{ type: "text/markdown" },
);
fireEvent.change(input, { target: { files: [file] } });
await screen.findByTestId("studio-form");
// Read as a skill, name from the frontmatter — not a plugin with a missing manifest.
expect((screen.getByTestId("studio-name") as HTMLInputElement).value).toBe("todo-triage");
});
it("speaks German when the UI does", async () => {
stubServer(SIGNED_IN);
setUiLanguage("de");
renderStudio();
expect(await screen.findByText(/Paketordner ablegen/)).toBeTruthy(); // i18n-allow
expect(screen.getByText("Im Marketplace veröffentlichen")).toBeTruthy(); // i18n-allow
});
});