62 lines
2.2 KiB
TypeScript
62 lines
2.2 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import os from "node:os";
|
|
import path from "node:path";
|
|
import { mkdtemp, rm } from "node:fs/promises";
|
|
|
|
let runtimeRoot = "";
|
|
let readState: (typeof import("../src/lib/boss-data"))["readState"];
|
|
let writeState: (typeof import("../src/lib/boss-data"))["writeState"];
|
|
let getDeviceWorkspaceView: (typeof import("../src/lib/boss-projections"))["getDeviceWorkspaceView"];
|
|
let buildDeviceWorkspaceDetailCards: (typeof import("../src/components/app-ui"))["buildDeviceWorkspaceDetailCards"];
|
|
|
|
async function setup() {
|
|
if (runtimeRoot) return;
|
|
|
|
runtimeRoot = await mkdtemp(path.join(os.tmpdir(), "boss-device-computer-control-capabilities-"));
|
|
process.env.BOSS_RUNTIME_ROOT = runtimeRoot;
|
|
process.env.BOSS_STATE_FILE = path.join(runtimeRoot, "boss-state.json");
|
|
|
|
const [data, projections, ui] = await Promise.all([
|
|
import("../src/lib/boss-data.ts"),
|
|
import("../src/lib/boss-projections.ts"),
|
|
import("../src/components/app-ui.tsx"),
|
|
]);
|
|
|
|
readState = data.readState;
|
|
writeState = data.writeState;
|
|
getDeviceWorkspaceView = projections.getDeviceWorkspaceView;
|
|
buildDeviceWorkspaceDetailCards = ui.buildDeviceWorkspaceDetailCards;
|
|
}
|
|
|
|
test.after(async () => {
|
|
if (runtimeRoot) {
|
|
await rm(runtimeRoot, { recursive: true, force: true });
|
|
}
|
|
});
|
|
|
|
test("device detail exposes browser automation and computer use capability state", async () => {
|
|
await setup();
|
|
|
|
const state = await readState();
|
|
const macStudio = state.devices.find((device) => device.id === "mac-studio");
|
|
assert.ok(macStudio, "expected seeded mac-studio");
|
|
macStudio.capabilities.browserAutomation = {
|
|
connected: true,
|
|
lastSeenAt: "2026-04-22T10:00:00.000Z",
|
|
lastActiveProjectId: "master-agent",
|
|
};
|
|
macStudio.capabilities.computerUse = {
|
|
connected: false,
|
|
lastSeenAt: "2026-04-22T10:00:00.000Z",
|
|
lastActiveProjectId: "",
|
|
};
|
|
await writeState(state);
|
|
|
|
const workspace = getDeviceWorkspaceView(await readState(), "mac-studio");
|
|
const cards = buildDeviceWorkspaceDetailCards(workspace);
|
|
|
|
assert.equal(cards.capabilities.items.browserAutomation, "浏览器自动化:已连接");
|
|
assert.equal(cards.capabilities.items.computerUse, "桌面控制:未连接");
|
|
});
|