mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-03 08:53:36 +00:00
Enhance unit tests for settings service and error handling
- Add comprehensive unit tests for SettingsService, covering global and project settings management, including creation, updates, and merging with defaults. - Implement tests for handling credentials, ensuring proper masking and merging of API keys. - Introduce tests for migration from localStorage, validating successful data transfer and error handling. - Enhance error handling in subprocess management tests, ensuring robust timeout and output reading scenarios.
This commit is contained in:
@@ -144,6 +144,40 @@ describe("sdk-options.ts", () => {
|
||||
expect(options.maxTurns).toBe(MAX_TURNS.extended);
|
||||
expect(options.allowedTools).toEqual([...TOOL_PRESETS.readOnly]);
|
||||
});
|
||||
|
||||
it("should include systemPrompt when provided", async () => {
|
||||
const { createSuggestionsOptions } = await import("@/lib/sdk-options.js");
|
||||
|
||||
const options = createSuggestionsOptions({
|
||||
cwd: "/test/path",
|
||||
systemPrompt: "Custom prompt",
|
||||
});
|
||||
|
||||
expect(options.systemPrompt).toBe("Custom prompt");
|
||||
});
|
||||
|
||||
it("should include abortController when provided", async () => {
|
||||
const { createSuggestionsOptions } = await import("@/lib/sdk-options.js");
|
||||
|
||||
const abortController = new AbortController();
|
||||
const options = createSuggestionsOptions({
|
||||
cwd: "/test/path",
|
||||
abortController,
|
||||
});
|
||||
|
||||
expect(options.abortController).toBe(abortController);
|
||||
});
|
||||
|
||||
it("should include outputFormat when provided", async () => {
|
||||
const { createSuggestionsOptions } = await import("@/lib/sdk-options.js");
|
||||
|
||||
const options = createSuggestionsOptions({
|
||||
cwd: "/test/path",
|
||||
outputFormat: { type: "json" },
|
||||
});
|
||||
|
||||
expect(options.outputFormat).toEqual({ type: "json" });
|
||||
});
|
||||
});
|
||||
|
||||
describe("createChatOptions", () => {
|
||||
@@ -205,6 +239,29 @@ describe("sdk-options.ts", () => {
|
||||
autoAllowBashIfSandboxed: true,
|
||||
});
|
||||
});
|
||||
|
||||
it("should include systemPrompt when provided", async () => {
|
||||
const { createAutoModeOptions } = await import("@/lib/sdk-options.js");
|
||||
|
||||
const options = createAutoModeOptions({
|
||||
cwd: "/test/path",
|
||||
systemPrompt: "Custom prompt",
|
||||
});
|
||||
|
||||
expect(options.systemPrompt).toBe("Custom prompt");
|
||||
});
|
||||
|
||||
it("should include abortController when provided", async () => {
|
||||
const { createAutoModeOptions } = await import("@/lib/sdk-options.js");
|
||||
|
||||
const abortController = new AbortController();
|
||||
const options = createAutoModeOptions({
|
||||
cwd: "/test/path",
|
||||
abortController,
|
||||
});
|
||||
|
||||
expect(options.abortController).toBe(abortController);
|
||||
});
|
||||
});
|
||||
|
||||
describe("createCustomOptions", () => {
|
||||
@@ -234,5 +291,42 @@ describe("sdk-options.ts", () => {
|
||||
expect(options.maxTurns).toBe(MAX_TURNS.maximum);
|
||||
expect(options.allowedTools).toEqual([...TOOL_PRESETS.readOnly]);
|
||||
});
|
||||
|
||||
it("should include sandbox when provided", async () => {
|
||||
const { createCustomOptions } = await import("@/lib/sdk-options.js");
|
||||
|
||||
const options = createCustomOptions({
|
||||
cwd: "/test/path",
|
||||
sandbox: { enabled: true, autoAllowBashIfSandboxed: false },
|
||||
});
|
||||
|
||||
expect(options.sandbox).toEqual({
|
||||
enabled: true,
|
||||
autoAllowBashIfSandboxed: false,
|
||||
});
|
||||
});
|
||||
|
||||
it("should include systemPrompt when provided", async () => {
|
||||
const { createCustomOptions } = await import("@/lib/sdk-options.js");
|
||||
|
||||
const options = createCustomOptions({
|
||||
cwd: "/test/path",
|
||||
systemPrompt: "Custom prompt",
|
||||
});
|
||||
|
||||
expect(options.systemPrompt).toBe("Custom prompt");
|
||||
});
|
||||
|
||||
it("should include abortController when provided", async () => {
|
||||
const { createCustomOptions } = await import("@/lib/sdk-options.js");
|
||||
|
||||
const abortController = new AbortController();
|
||||
const options = createCustomOptions({
|
||||
cwd: "/test/path",
|
||||
abortController,
|
||||
});
|
||||
|
||||
expect(options.abortController).toBe(abortController);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user