-
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathappSettings.test.ts
More file actions
113 lines (96 loc) · 3.66 KB
/
Copy pathappSettings.test.ts
File metadata and controls
113 lines (96 loc) · 3.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import * as Schema from "effect/Schema";
import { describe, expect, it } from "vitest";
import {
AppSettingsSchema,
DEFAULT_BROWSER_PREVIEW_START_PAGE_URL,
DEFAULT_PR_REVIEW_REQUEST_CHANGES_TONE,
DEFAULT_SIDEBAR_FONT_SIZE,
DEFAULT_SIDEBAR_PROJECT_ROW_HEIGHT,
DEFAULT_SIDEBAR_SPACING,
DEFAULT_SIDEBAR_THREAD_ROW_HEIGHT,
getProviderStartOptions,
resolveBrowserPreviewStartPageUrl,
} from "./appSettings";
describe("AppSettingsSchema", () => {
it("defaults codeViewerAutosave to false", () => {
const settings = Schema.decodeUnknownSync(AppSettingsSchema)({});
expect(settings.codeViewerAutosave).toBe(false);
});
it("defaults notification detail toggles to false", () => {
const settings = Schema.decodeUnknownSync(AppSettingsSchema)({});
expect(settings.showNotificationDetails).toBe(false);
expect(settings.includeDiagnosticsTipsInCopy).toBe(false);
expect(settings.browserPreviewStartPageUrl).toBe("");
});
it("defaults sidebar appearance controls", () => {
const settings = Schema.decodeUnknownSync(AppSettingsSchema)({});
expect(settings.sidebarProjectRowHeight).toBe(DEFAULT_SIDEBAR_PROJECT_ROW_HEIGHT);
expect(settings.sidebarThreadRowHeight).toBe(DEFAULT_SIDEBAR_THREAD_ROW_HEIGHT);
expect(settings.sidebarFontSize).toBe(DEFAULT_SIDEBAR_FONT_SIZE);
expect(settings.sidebarSpacing).toBe(DEFAULT_SIDEBAR_SPACING);
});
it("preserves an explicit codeViewerAutosave setting", () => {
const settings = Schema.decodeUnknownSync(AppSettingsSchema)({
codeViewerAutosave: true,
});
expect(settings.codeViewerAutosave).toBe(true);
});
it("preserves explicit notification detail settings", () => {
const settings = Schema.decodeUnknownSync(AppSettingsSchema)({
showNotificationDetails: true,
includeDiagnosticsTipsInCopy: true,
});
expect(settings.showNotificationDetails).toBe(true);
expect(settings.includeDiagnosticsTipsInCopy).toBe(true);
});
it("defaults the PR request changes button tone to warning", () => {
const settings = Schema.decodeUnknownSync(AppSettingsSchema)({});
expect(settings.prReviewRequestChangesTone).toBe(DEFAULT_PR_REVIEW_REQUEST_CHANGES_TONE);
});
});
describe("getProviderStartOptions", () => {
it("includes the Claude binary path when configured", () => {
expect(
getProviderStartOptions({
claudeBinaryPath: "/usr/local/bin/claude",
codexBinaryPath: "",
codexHomePath: "",
copilotBinaryPath: "",
copilotConfigDir: "",
openclawGatewayUrl: "",
openclawPassword: "",
}),
).toEqual({
claudeAgent: {
binaryPath: "/usr/local/bin/claude",
},
});
});
it("does not emit Claude start options without a Claude binary path", () => {
expect(
getProviderStartOptions({
claudeBinaryPath: "",
codexBinaryPath: "",
codexHomePath: "",
copilotBinaryPath: "",
copilotConfigDir: "",
openclawGatewayUrl: "",
openclawPassword: "",
}),
).toBeUndefined();
});
});
describe("resolveBrowserPreviewStartPageUrl", () => {
it("falls back to the default start page for blank or invalid values", () => {
expect(resolveBrowserPreviewStartPageUrl("")).toBe(DEFAULT_BROWSER_PREVIEW_START_PAGE_URL);
expect(resolveBrowserPreviewStartPageUrl("not-a-url")).toBe(
DEFAULT_BROWSER_PREVIEW_START_PAGE_URL,
);
});
it("normalizes valid http and https URLs", () => {
expect(resolveBrowserPreviewStartPageUrl(" https://example.com ")).toBe("https://example.com/");
expect(resolveBrowserPreviewStartPageUrl("http://localhost:3000/path")).toBe(
"http://localhost:3000/path",
);
});
});