mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-11 09:51:30 +00:00
fix: pasting request ito parent folder even if request is selected (#6446)
This commit is contained in:
@@ -47,7 +47,7 @@ import ExampleIcon from 'components/Icons/ExampleIcon';
|
||||
import { scrollToTheActiveTab } from 'utils/tabs';
|
||||
import { isTabForItemActive as isTabForItemActiveSelector, isTabForItemPresent as isTabForItemPresentSelector } from 'src/selectors/tab';
|
||||
import { isEqual } from 'lodash';
|
||||
import { calculateDraggedItemNewPathname, getInitialExampleName } from 'utils/collections/index';
|
||||
import { calculateDraggedItemNewPathname, getInitialExampleName, findParentItemInCollection } from 'utils/collections/index';
|
||||
import { sortByNameThenSequence } from 'utils/common/index';
|
||||
import CreateExampleModal from 'components/ResponseExample/CreateExampleModal';
|
||||
import { openDevtoolsAndSwitchToTerminal } from 'utils/terminal';
|
||||
@@ -533,13 +533,14 @@ const CollectionItem = ({ item, collectionUid, collectionPathname, searchText })
|
||||
};
|
||||
|
||||
const handlePasteItem = () => {
|
||||
// Only allow paste into folders
|
||||
// Determine target folder: if item is a folder, paste into it; otherwise paste into parent folder
|
||||
let targetFolderUid = item.uid;
|
||||
if (!isFolder) {
|
||||
toast.error('Paste is only available for folders');
|
||||
return;
|
||||
const parentFolder = findParentItemInCollection(collection, item.uid);
|
||||
targetFolderUid = parentFolder ? parentFolder.uid : null;
|
||||
}
|
||||
|
||||
dispatch(pasteItem(collectionUid, item.uid))
|
||||
dispatch(pasteItem(collectionUid, targetFolderUid))
|
||||
.then(() => {
|
||||
toast.success('Item pasted successfully');
|
||||
})
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { test, expect } from '../../../playwright';
|
||||
import { closeAllCollections, createCollection } from '../../utils/page';
|
||||
import { closeAllCollections, createCollection, createRequest } from '../../utils/page';
|
||||
|
||||
test.describe('Copy and Paste Requests', () => {
|
||||
test.afterAll(async ({ page }) => {
|
||||
@@ -66,4 +66,20 @@ test.describe('Copy and Paste Requests', () => {
|
||||
// Verify the pasted request appears with the same name
|
||||
await expect(page.locator('.collection-item-name').filter({ hasText: 'original-request' })).toHaveCount(4);
|
||||
});
|
||||
|
||||
test('should paste request into parent folder even if request is selected', async ({ page, createTmpDir }) => {
|
||||
// Create a collection and a request
|
||||
await createCollection(page, 'test-collection-3', await createTmpDir('test-collection-3'));
|
||||
await createRequest(page, 'request-to-copy', 'test-collection-3');
|
||||
|
||||
const modifier = process.platform === 'darwin' ? 'Meta' : 'Control';
|
||||
|
||||
// Copy the request
|
||||
await page.locator('.collection-item-name').filter({ hasText: 'request-to-copy' }).click();
|
||||
await page.keyboard.press(`${modifier}+C`);
|
||||
await page.keyboard.press(`${modifier}+V`);
|
||||
|
||||
// Verify the pasted request appears with the same name
|
||||
await expect(page.locator('.collection-item-name').filter({ hasText: 'request-to-copy' })).toHaveCount(2);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user