66 lines
2.2 KiB
JavaScript
66 lines
2.2 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
import {
|
|
TaskEntryInputError,
|
|
buildMainAppUrl,
|
|
buildTaskEntryDestination,
|
|
buildTaskEntrySessionSearch,
|
|
parseTaskEntryParams,
|
|
} from "./task-entry.ts";
|
|
|
|
test("parses the dedicated single-agent task entry", () => {
|
|
const params = parseTaskEntryParams(
|
|
"?username=admin&taskId=108&goPath=XDFX&theme=dark-blue&hideJump=1",
|
|
);
|
|
assert.deepEqual(params, {
|
|
username: "admin",
|
|
password: "",
|
|
taskId: "108",
|
|
goPath: "xdfx",
|
|
theme: "dark-blue",
|
|
hideJump: true,
|
|
});
|
|
});
|
|
|
|
test("rejects missing identity, task, and roundtable routes", () => {
|
|
assert.throws(() => parseTaskEntryParams("?taskId=108&goPath=xdfx"), TaskEntryInputError);
|
|
assert.throws(() => parseTaskEntryParams("?username=admin&goPath=xdfx"), TaskEntryInputError);
|
|
assert.throws(
|
|
() => parseTaskEntryParams("?username=admin&taskId=108&goPath=xdfx-A"),
|
|
TaskEntryInputError,
|
|
);
|
|
});
|
|
|
|
test("forces isolated embed state and an allowlisted task target", () => {
|
|
const params = parseTaskEntryParams(
|
|
"?username=admin&taskId=108&goPath=xdfx&hideJump=true",
|
|
);
|
|
const session = new URLSearchParams(buildTaskEntrySessionSearch(params));
|
|
assert.equal(session.get("embed"), "1");
|
|
assert.equal(session.get("hideChrome"), "1");
|
|
assert.equal(session.get("isolate"), "1");
|
|
assert.equal(session.get("hideJump"), "1");
|
|
|
|
const destination = buildTaskEntryDestination(
|
|
"/page/strategy/task-management/plan-task/plan-task-action/agent/a-1/chats",
|
|
params,
|
|
);
|
|
assert.equal(
|
|
destination,
|
|
"/page/strategy/task-management/plan-task/plan-task-action/agent/a-1/chats?embed=1&hideChrome=1&isolate=1&hideJump=1",
|
|
);
|
|
assert.throws(() => buildTaskEntryDestination("https://example.com", params));
|
|
assert.throws(() => buildTaskEntryDestination("/page/workspace/chats/new", params));
|
|
});
|
|
|
|
test("returns to the main app at the same deployment prefix", () => {
|
|
assert.equal(
|
|
buildMainAppUrl(
|
|
"https://example.com/deerflow/task-entry.html?username=admin",
|
|
"/page/strategy/task-management/plan-task/plan-task-action/agent/a-1/chats",
|
|
),
|
|
"https://example.com/deerflow/#/page/strategy/task-management/plan-task/plan-task-action/agent/a-1/chats",
|
|
);
|
|
});
|