Skip to content

Commit c3b5532

Browse files
committed
fix crash if presets is null
1 parent a1d06f5 commit c3b5532

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

site/src/pages/TasksPage/TasksPage.stories.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,26 @@ export const LoadedTasksWithAIPromptPresets: Story = {
176176
},
177177
};
178178

179+
export const LoadedTasksEdgeCases: Story = {
180+
decorators: [withProxyProvider()],
181+
beforeEach: () => {
182+
spyOn(data, "fetchAITemplates").mockResolvedValue([MockTemplate]);
183+
spyOn(data, "fetchTasks").mockResolvedValue(MockTasks);
184+
185+
// Test various edge cases for presets
186+
spyOn(API, "getTemplateVersionPresets").mockImplementation(async () => {
187+
return [
188+
{
189+
ID: "malformed",
190+
Name: "Malformed Preset",
191+
Default: true,
192+
},
193+
// biome-ignore lint/suspicious/noExplicitAny: Testing malformed data edge cases
194+
] as any;
195+
});
196+
},
197+
};
198+
179199
export const CreateTaskSuccessfully: Story = {
180200
decorators: [withProxyProvider()],
181201
parameters: {

site/src/pages/TasksPage/TasksPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ const TaskForm: FC<TaskFormProps> = ({ templates, onSuccess }) => {
239239

240240
// Extract AI prompt from selected preset
241241
const selectedPreset = presets?.find((p) => p.ID === selectedPresetId);
242-
const presetAIPrompt = selectedPreset?.Parameters.find(
242+
const presetAIPrompt = selectedPreset?.Parameters?.find(
243243
(param) => param.Name === AI_PROMPT_PARAMETER_NAME,
244244
)?.Value;
245245
const isPromptReadOnly = !!presetAIPrompt;

0 commit comments

Comments
 (0)