From 90ab419d124e1a880d8150fbcf05d9b9d15f764e Mon Sep 17 00:00:00 2001 From: "jeetul.samaiya" Date: Wed, 10 Sep 2025 21:01:24 +0530 Subject: [PATCH] fix: enhance error handling for custom headers and improve test coverage for header management --- client/src/App.tsx | 6 +- client/src/components/CustomHeaders.tsx | 3 + .../src/components/__tests__/Sidebar.test.tsx | 195 ++++++++++++++---- 3 files changed, 163 insertions(+), 41 deletions(-) diff --git a/client/src/App.tsx b/client/src/App.tsx index 17c50435..1454811a 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -137,7 +137,11 @@ const App = () => { if (savedHeaders) { try { return JSON.parse(savedHeaders); - } catch { + } catch (error) { + console.warn( + `Failed to parse custom headers: "${savedHeaders}", will try legacy migration`, + error, + ); // Fall back to migration if JSON parsing fails } } diff --git a/client/src/components/CustomHeaders.tsx b/client/src/components/CustomHeaders.tsx index 67aee18d..463f7333 100644 --- a/client/src/components/CustomHeaders.tsx +++ b/client/src/components/CustomHeaders.tsx @@ -153,6 +153,7 @@ const CustomHeaders = ({ size="sm" onClick={addHeader} className="text-xs px-2" + data-testid="add-header-button" > Add @@ -185,6 +186,7 @@ const CustomHeaders = ({ value={header.name} onChange={(e) => updateHeader(index, "name", e.target.value)} className="font-mono text-xs" + data-testid={`header-name-input-${index}`} />