From 5cd3e7abbd3305ce58c4d5952b35267c6be59123 Mon Sep 17 00:00:00 2001 From: shubh-bruno Date: Thu, 2 Apr 2026 18:13:37 +0530 Subject: [PATCH] fix: handle copy/paste item for requests & js file (#7656) --- .../Collections/Collection/CollectionItem/index.js | 11 +++++++---- .../Sidebar/Collections/CollectionSearch/index.js | 1 + tests/shortcuts/bound-actions.spec.ts | 13 +++++++------ 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/index.js b/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/index.js index ad6f4688c..7f1fbe70c 100644 --- a/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/index.js +++ b/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/index.js @@ -565,9 +565,12 @@ const CollectionItem = ({ item, collectionUid, collectionPathname, searchText }) }; const handlePasteItem = () => { - // Paste as sibling: find the parent folder so the pasted item appears next to the focused item - const parentFolder = findParentItemInCollection(collection, item.uid); - const targetFolderUid = parentFolder ? parentFolder.uid : null; + // Determine target folder: if item is a folder, paste into it; otherwise paste into parent folder + let targetFolderUid = item.uid; + if (!isFolder) { + const parentFolder = findParentItemInCollection(collection, item.uid); + targetFolderUid = parentFolder ? parentFolder.uid : null; + } dispatch(pasteItem(collectionUid, targetFolderUid)) .then(() => { @@ -644,7 +647,7 @@ const CollectionItem = ({ item, collectionUid, collectionPathname, searchText }) key={i} style={{ width: 16, minWidth: 16, height: '100%' }} > -  {/* Indent */} +  {/* Indent */} )) : null} diff --git a/packages/bruno-app/src/components/Sidebar/Collections/CollectionSearch/index.js b/packages/bruno-app/src/components/Sidebar/Collections/CollectionSearch/index.js index 68e3d654a..00828ea8d 100644 --- a/packages/bruno-app/src/components/Sidebar/Collections/CollectionSearch/index.js +++ b/packages/bruno-app/src/components/Sidebar/Collections/CollectionSearch/index.js @@ -8,6 +8,7 @@ const CollectionSearch = ({ searchText, setSearchText }) => { { await page.keyboard.press(`${modifier}+KeyF`); - await expect(page.getByPlaceholder('Search requests...')).toBeVisible({ timeout: 3000 }); + // await expect(page.getByPlaceholder('Search requests...')).toBeVisible({ timeout: 3000 }); + await expect(page.getByTestId('sidebar-search-input')).toBeVisible({ timeout: 3000 }); await page.getByTitle('Search requests').click(); }); @@ -879,7 +880,7 @@ test.describe('Shortcut Keys - BOUND_ACTIONS', () => { await page.keyboard.up('KeyF'); await page.keyboard.up('Alt'); - await expect(page.getByPlaceholder('Search requests...')).toBeVisible({ timeout: 3000 }); + await expect(page.getByTestId('sidebar-search-input')).toBeVisible({ timeout: 2000 }); await page.getByTitle('Search requests').click(); }); }); @@ -1260,8 +1261,8 @@ test.describe('Shortcut Keys - BOUND_ACTIONS', () => { await page.keyboard.press(`${modifier}+KeyC`); await page.keyboard.press(`${modifier}+KeyV`); - // Verify cloned request appears in sidebar - await expect(page.locator('.collection-item-name').filter({ hasText: 'kb-folder (1)' })).toBeVisible({ timeout: 2000 }); + // Verify copied item appears in sidebar as child of folder + await expect(page.locator('.collection-item-name').filter({ hasText: 'kb-folder' })).toHaveCount(2); }); test('customized Alt+C/V copy paste item for request', async ({ page, createTmpDir }) => { @@ -1338,8 +1339,8 @@ test.describe('Shortcut Keys - BOUND_ACTIONS', () => { await page.keyboard.up('KeyV'); await page.keyboard.up('Alt'); - // Verify cloned request appears in sidebar - await expect(page.locator('.collection-item-name').filter({ hasText: 'kb-folder-copy-src (1)' })).toBeVisible({ timeout: 2000 }); + // Verify copied item appears in sidebar as child of folder + await expect(page.locator('.collection-item-name').filter({ hasText: 'kb-folder-copy-src' })).toHaveCount(2); }); });