Skip to content

Commit 910faa3

Browse files
committed
test: add Storybook coverage for Tasks settings
Change-Id: I610ed14466ef41cd45a263a2b48740d3f9aa0c8d Signed-off-by: Thomas Kosiewski <tk@coder.com>
1 parent 270d73c commit 910faa3

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
@@ -14,6 +14,7 @@ import type {
1414
import type { ChatStats } from "@/common/types/chatStats";
1515
import { DEFAULT_RUNTIME_CONFIG } from "@/common/constants/workspace";
1616
import { createAsyncMessageQueue } from "@/common/utils/asyncMessageQueue";
17+
import type { TaskSettings } from "@/common/orpc/schemas/taskSettings";
1718

1819
/** Session usage data structure matching SessionUsageFileSchema */
1920
export interface MockSessionUsage {
@@ -88,6 +89,8 @@ export interface MockORPCClientOptions {
8889
>;
8990
/** MCP test results - maps server name to tools list or error */
9091
mcpTestResults?: Map<string, { success: true; tools: string[] } | { success: false; error: string }>;
92+
/** Task settings (maxParallelAgentTasks + maxTaskNestingDepth) */
93+
taskSettings?: TaskSettings;
9194
}
9295

9396
/**
@@ -122,6 +125,7 @@ export function createMockORPCClient(options: MockORPCClientOptions = {}): APICl
122125
statsTabVariant = "control",
123126
mcpServers = new Map(),
124127
mcpOverrides = new Map(),
128+
taskSettings: rawTaskSettings,
125129
mcpTestResults = new Map(),
126130
} = options;
127131

@@ -141,6 +145,11 @@ export function createMockORPCClient(options: MockORPCClientOptions = {}): APICl
141145

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

148+
149+
let taskSettings: TaskSettings = rawTaskSettings ?? {
150+
maxParallelAgentTasks: 3,
151+
maxTaskNestingDepth: 3,
152+
};
144153
const mockStats: ChatStats = {
145154
consumers: [],
146155
totalTokens: 0,
@@ -167,6 +176,12 @@ export function createMockORPCClient(options: MockORPCClientOptions = {}): APICl
167176
telemetry: {
168177
track: async () => undefined,
169178
},
179+
tasks: {
180+
getTaskSettings: async () => taskSettings,
181+
setTaskSettings: async (input: TaskSettings) => {
182+
taskSettings = input;
183+
},
184+
},
170185
server: {
171186
getLaunchProject: async () => null,
172187
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)