Skip to content

Commit 6eaf0e2

Browse files
committed
test: add Storybook coverage for Tasks settings
Change-Id: I610ed14466ef41cd45a263a2b48740d3f9aa0c8d Signed-off-by: Thomas Kosiewski <tk@coder.com>
1 parent 799cd10 commit 6eaf0e2

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

.storybook/mocks/orpc.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import type { WorkspaceChatMessage, ProvidersConfigMap } from "@/common/orpc/typ
1010
import type { ChatStats } from "@/common/types/chatStats";
1111
import { DEFAULT_RUNTIME_CONFIG } from "@/common/constants/workspace";
1212
import { createAsyncMessageQueue } from "@/common/utils/asyncMessageQueue";
13+
import type { TaskSettings } from "@/common/orpc/schemas/taskSettings";
1314

1415
/** Session usage data structure matching SessionUsageFileSchema */
1516
export interface MockSessionUsage {
@@ -82,6 +83,8 @@ export interface MockORPCClientOptions {
8283
>;
8384
/** MCP test results - maps server name to tools list or error */
8485
mcpTestResults?: Map<string, { success: true; tools: string[] } | { success: false; error: string }>;
86+
/** Task settings (maxParallelAgentTasks + maxTaskNestingDepth) */
87+
taskSettings?: TaskSettings;
8588
}
8689

8790
/**
@@ -114,11 +117,17 @@ export function createMockORPCClient(options: MockORPCClientOptions = {}): APICl
114117
sessionUsage = new Map(),
115118
mcpServers = new Map(),
116119
mcpOverrides = new Map(),
120+
taskSettings: rawTaskSettings,
117121
mcpTestResults = new Map(),
118122
} = options;
119123

120124
const workspaceMap = new Map(workspaces.map((w) => [w.id, w]));
121125

126+
127+
let taskSettings: TaskSettings = rawTaskSettings ?? {
128+
maxParallelAgentTasks: 3,
129+
maxTaskNestingDepth: 3,
130+
};
122131
const mockStats: ChatStats = {
123132
consumers: [],
124133
totalTokens: 0,
@@ -135,6 +144,12 @@ export function createMockORPCClient(options: MockORPCClientOptions = {}): APICl
135144
_input.texts.map(() => 0),
136145
calculateStats: async () => mockStats,
137146
},
147+
tasks: {
148+
getTaskSettings: async () => taskSettings,
149+
setTaskSettings: async (input: TaskSettings) => {
150+
taskSettings = input;
151+
},
152+
},
138153
server: {
139154
getLaunchProject: async () => null,
140155
getSshHost: async () => null,

src/browser/stories/App.settings.stories.tsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
import type { APIClient } from "@/browser/contexts/API";
13+
import type { TaskSettings } from "@/common/orpc/schemas/taskSettings";
1314
import { appMeta, AppWithMocks, type AppStory } from "./meta.js";
1415
import { createWorkspace, groupWorkspacesByProject } from "./mockFactory";
1516
import { selectWorkspace } from "./storyHelpers";
@@ -32,6 +33,8 @@ function setupSettingsStory(options: {
3233
providersList?: string[];
3334
/** Pre-set experiment states in localStorage before render */
3435
experiments?: Partial<Record<string, boolean>>;
36+
/** Initial task settings values */
37+
taskSettings?: TaskSettings;
3538
}): APIClient {
3639
const workspaces = [createWorkspace({ id: "ws-1", name: "main", projectName: "my-app" })];
3740

@@ -47,6 +50,7 @@ function setupSettingsStory(options: {
4750

4851
return createMockORPCClient({
4952
projects: groupWorkspacesByProject(workspaces),
53+
taskSettings: options.taskSettings,
5054
workspaces,
5155
providersConfig: options.providersConfig ?? {},
5256
providersList: options.providersList ?? ["anthropic", "openai", "xai"],
@@ -168,6 +172,32 @@ export const ModelsConfigured: AppStory = {
168172
},
169173
};
170174

175+
/** Tasks section - shows agent task settings */
176+
export const Tasks: AppStory = {
177+
render: () => (
178+
<AppWithMocks
179+
setup={() =>
180+
setupSettingsStory({
181+
taskSettings: {
182+
maxParallelAgentTasks: 5,
183+
maxTaskNestingDepth: 2,
184+
},
185+
})
186+
}
187+
/>
188+
),
189+
play: async ({ canvasElement }: { canvasElement: HTMLElement }) => {
190+
await openSettingsToSection(canvasElement, "tasks");
191+
192+
const body = within(canvasElement.ownerDocument.body);
193+
await body.findByText(/Agent task limits/i);
194+
195+
// Ensure the values were loaded from the API mock (not just initial defaults)
196+
await body.findByDisplayValue("5");
197+
await body.findByDisplayValue("2");
198+
},
199+
};
200+
171201
/** Experiments section - shows available experiments */
172202
export const Experiments: AppStory = {
173203
render: () => <AppWithMocks setup={() => setupSettingsStory({})} />,

0 commit comments

Comments
 (0)