Skip to content

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.

1.1 KB
Raw Blame
import { describe, expect, it } from "vitest";
import { WSAudioLevel, WSCommand, WSWelcome } from "./ws";

describe("WSCommand mission.inject", () => {
  it("validates a mission.inject command", () => {
    const parsed = WSCommand.parse({
      type: "command",
      action: "mission.inject",
      payload: { slug: "s", utterance: "u", status: "success" },
    });
    expect(parsed.action).toBe("mission.inject");
  });
});

describe("WSWelcome", () => {
  it("does not retain legacy session tokens", () => {
    const parsed = WSWelcome.parse({
      type: "welcome",
      session_id: "session-1",
      version: "1.0.0",
      token: "must-not-reach-the-client",
    });

    expect(parsed).toEqual({
      type: "welcome",
      session_id: "session-1",
      version: "1.0.0",
    });
    expect("token" in parsed).toBe(false);
  });
});

describe("WSAudioLevel", () => {
  it("accepts only normalized microphone samples", () => {
    expect(WSAudioLevel.parse({ type: "audio.level", input: 0.72 }).input).toBe(0.72);
    expect(WSAudioLevel.safeParse({ type: "audio.level", input: 1.2 }).success).toBe(
      false,
    );
  });
});