Treat a refused tool update as a failed save

This commit is contained in:
arc53-machine committed 2026-09-29 00:54:07 +01:00
1 parent 9cd8c6c45c
commit 526b7a9fb3
2 files changed
+26 -6

No files matched your search

+22
View File
@@ -185,6 +185,28 @@ describe('ToolConfig', () => {
expect(alert?.className).toContain('text-destructive');
});
it('shows a save the server refused as failed', async () => {
updateTool.mockResolvedValue({ ok: false, status: 400 });
await render({ ...userTool, customName: '' });
const name = container.querySelector<HTMLInputElement>(
'input[placeholder="settings.tools.customNamePlaceholder"]',
);
await act(async () => {
const setter = Object.getOwnPropertyDescriptor(
HTMLInputElement.prototype,
'value',
)?.set;
setter?.call(name, 'Renamed');
name?.dispatchEvent(new Event('input', { bubbles: true }));
});
await act(async () => {
buttonByText('settings.tools.save')?.click();
});
expect(
container.querySelector<HTMLElement>('[role="alert"]')?.textContent,
).toBe('settings.tools.saveFailed');
});
it('renders the API tool header actions as outline-primary pills', async () => {
await render(apiTool);
for (const label of [
+4 -6
View File
@@ -257,12 +257,10 @@ export default function ToolConfig({
actions: 'actions' in tool ? tool.actions : [],
status: tool.status,
};
if (tool.id) {
await userService.updateTool({ id: tool.id, ...payload }, token);
return;
}
const response = await userService.createTool(payload, token);
if (!response.ok) throw new Error('create failed');
const response = tool.id
? await userService.updateTool({ id: tool.id, ...payload }, token)
: await userService.createTool(payload, token);
if (!response.ok) throw new Error('save failed');
};
const handleSaveChanges = async () => {