94 lines
2.6 KiB
TypeScript
94 lines
2.6 KiB
TypeScript
// @vitest-environment node
|
|
import { describe, expect, it } from "vitest";
|
|
import { buildNewAgentHirePayload } from "./new-agent-hire-payload";
|
|
import { defaultCreateValues } from "../components/agent-config-defaults";
|
|
|
|
describe("buildNewAgentHirePayload", () => {
|
|
it("persists the selected default environment id", () => {
|
|
expect(
|
|
buildNewAgentHirePayload({
|
|
name: "Linux Claude",
|
|
effectiveRole: "general",
|
|
configValues: {
|
|
...defaultCreateValues,
|
|
adapterType: "claude_local",
|
|
defaultEnvironmentId: "11111111-1111-4111-8111-111111111111",
|
|
},
|
|
adapterConfig: { foo: "bar" },
|
|
}),
|
|
).toMatchObject({
|
|
name: "Linux Claude",
|
|
role: "general",
|
|
adapterType: "claude_local",
|
|
defaultEnvironmentId: "11111111-1111-4111-8111-111111111111",
|
|
adapterConfig: { foo: "bar" },
|
|
budgetMonthlyCents: 0,
|
|
});
|
|
});
|
|
|
|
it("sends null when no default environment is selected", () => {
|
|
expect(
|
|
buildNewAgentHirePayload({
|
|
name: "Local Claude",
|
|
effectiveRole: "general",
|
|
configValues: {
|
|
...defaultCreateValues,
|
|
adapterType: "claude_local",
|
|
},
|
|
adapterConfig: {},
|
|
}),
|
|
).toMatchObject({
|
|
defaultEnvironmentId: null,
|
|
});
|
|
});
|
|
|
|
it("includes core trust preset permissions when provided", () => {
|
|
expect(
|
|
buildNewAgentHirePayload({
|
|
name: "PR Reviewer",
|
|
effectiveRole: "engineer",
|
|
configValues: {
|
|
...defaultCreateValues,
|
|
adapterType: "codex_local",
|
|
},
|
|
adapterConfig: {},
|
|
permissions: {
|
|
canCreateAgents: false,
|
|
trustPreset: "low_trust_review",
|
|
authorizationPolicy: {
|
|
trustPreset: "low_trust_review",
|
|
reviewPreset: {
|
|
id: "low_trust_review",
|
|
version: 1,
|
|
rawOutputDisposition: "quarantine",
|
|
},
|
|
trustBoundary: {
|
|
mode: "low_trust_review",
|
|
companyId: "company-1",
|
|
rootIssueId: "issue-root",
|
|
},
|
|
},
|
|
},
|
|
}),
|
|
).toMatchObject({
|
|
permissions: {
|
|
canCreateAgents: false,
|
|
trustPreset: "low_trust_review",
|
|
authorizationPolicy: {
|
|
trustPreset: "low_trust_review",
|
|
reviewPreset: {
|
|
id: "low_trust_review",
|
|
version: 1,
|
|
rawOutputDisposition: "quarantine",
|
|
},
|
|
trustBoundary: {
|
|
mode: "low_trust_review",
|
|
companyId: "company-1",
|
|
rootIssueId: "issue-root",
|
|
},
|
|
},
|
|
},
|
|
});
|
|
});
|
|
});
|