From ae18f59a01917604ba914264eedaffa48b67736f Mon Sep 17 00:00:00 2001 From: dancode-188 Date: Sun, 28 Dec 2025 01:54:24 +0300 Subject: [PATCH 1/2] fix: use setChainVariables instead of merge for deletion, fixes #39 Chain variable deletion wasn't working because mergeChainVariables merges new variables with existing ones instead of replacing them. When you delete a key and call merge, the deleted key gets added back from the old state. Changed VariablesPanel to use setChainVariables instead, which replaces the entire variable object rather than merging. --- src/components/VariablesPanel.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/VariablesPanel.tsx b/src/components/VariablesPanel.tsx index c4a82e2..5f2cfc7 100644 --- a/src/components/VariablesPanel.tsx +++ b/src/components/VariablesPanel.tsx @@ -14,7 +14,7 @@ interface ConfirmDialog { } export default function VariablesPanel() { - const { chainVariables, mergeChainVariables, clearChainVariables } = useStore(); + const { chainVariables, mergeChainVariables, setChainVariables, clearChainVariables } = useStore(); const [scriptVariables, setScriptVariables] = useState>(new Map()); const [editingKey, setEditingKey] = useState(null); const [editingValue, setEditingValue] = useState(''); @@ -91,7 +91,7 @@ export default function VariablesPanel() { if (activeSource === 'chain') { const newVars = { ...chainVariables }; delete newVars[key]; - mergeChainVariables(newVars); + setChainVariables(newVars); } else { scriptingService.deleteVariable(key); loadScriptVariables(); From c022aedc28e5fb5936765fbf9c6ea25cb5cdfd8e Mon Sep 17 00:00:00 2001 From: dancode-188 Date: Sun, 28 Dec 2025 02:02:27 +0300 Subject: [PATCH 2/2] test: fix delete chain variable test to expect not visible The test was expecting the variable to be visible after deletion because deletion wasn't working. Now that deletion works correctly, the test should expect the variable to NOT be visible. --- e2e/tests/main-components/requestBuilder.component.spec.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/e2e/tests/main-components/requestBuilder.component.spec.ts b/e2e/tests/main-components/requestBuilder.component.spec.ts index 5594820..2db3c4c 100644 --- a/e2e/tests/main-components/requestBuilder.component.spec.ts +++ b/e2e/tests/main-components/requestBuilder.component.spec.ts @@ -164,8 +164,7 @@ test('add chain variable', async({page, apiReq}) => { test('delete chain varaible', async({preVariables, apiReq}) => { await apiReq.chainVariableDelete('chainVar1') - //below test is failing so i have put visisble for now - await expect(apiReq.reqBuilderMain.getByText('chainVar1')).toBeVisible() + await expect(apiReq.reqBuilderMain.getByText('chainVar1')).not.toBeVisible() }) test('chain variables clear all', async({apiReq, preVariables}) => {