mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-11 09:51:30 +00:00
fix: file extension for clone and rename request (#7278)
* fix: file extension for clone and rename request * fix
This commit is contained in:
@@ -3,7 +3,7 @@ import toast from 'react-hot-toast';
|
||||
import { useFormik } from 'formik';
|
||||
import * as Yup from 'yup';
|
||||
import Modal from 'components/Modal';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
import { isItemAFolder } from 'utils/tabs';
|
||||
import { cloneItem } from 'providers/ReduxStore/slices/collections/actions';
|
||||
import { IconArrowBackUp, IconEdit, IconCaretDown } from '@tabler/icons';
|
||||
@@ -18,6 +18,7 @@ import Button from 'ui/Button';
|
||||
|
||||
const CloneCollectionItem = ({ collectionUid, item, onClose }) => {
|
||||
const dispatch = useDispatch();
|
||||
const collection = useSelector((state) => state.collections.collections?.find((c) => c.uid === collectionUid));
|
||||
const isFolder = isItemAFolder(item);
|
||||
const inputRef = useRef();
|
||||
const [isEditing, toggleEditing] = useState(false);
|
||||
@@ -168,7 +169,7 @@ const CloneCollectionItem = ({ collectionUid, item, onClose }) => {
|
||||
onChange={formik.handleChange}
|
||||
value={formik.values.filename || ''}
|
||||
/>
|
||||
{itemType !== 'folder' && <span className="absolute right-2 top-4 flex justify-center items-center file-extension">.bru</span>}
|
||||
{itemType !== 'folder' && <span className="absolute right-2 top-4 flex justify-center items-center file-extension">.{collection?.format || 'bru'}</span>}
|
||||
</div>
|
||||
) : (
|
||||
<div className="relative flex flex-row gap-1 items-center justify-between">
|
||||
|
||||
@@ -2,7 +2,7 @@ import React, { useRef, useEffect, useState, forwardRef } from 'react';
|
||||
import { useFormik } from 'formik';
|
||||
import * as Yup from 'yup';
|
||||
import Modal from 'components/Modal';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
import { isItemAFolder } from 'utils/tabs';
|
||||
import { renameItem, saveRequest, closeTabs } from 'providers/ReduxStore/slices/collections/actions';
|
||||
import path from 'utils/common/path';
|
||||
@@ -18,6 +18,7 @@ import Button from 'ui/Button';
|
||||
|
||||
const RenameCollectionItem = ({ collectionUid, item, onClose }) => {
|
||||
const dispatch = useDispatch();
|
||||
const collection = useSelector((state) => state.collections.collections?.find((c) => c.uid === collectionUid));
|
||||
const isFolder = isItemAFolder(item);
|
||||
const inputRef = useRef();
|
||||
const [isEditing, toggleEditing] = useState(false);
|
||||
@@ -168,6 +169,7 @@ const RenameCollectionItem = ({ collectionUid, item, onClose }) => {
|
||||
size={16}
|
||||
strokeWidth={1.5}
|
||||
onClick={() => toggleEditing(true)}
|
||||
data-testid="rename-request-edit-icon"
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
@@ -186,7 +188,7 @@ const RenameCollectionItem = ({ collectionUid, item, onClose }) => {
|
||||
onChange={formik.handleChange}
|
||||
value={formik.values.filename || ''}
|
||||
/>
|
||||
{itemType !== 'folder' && <span className="absolute right-2 top-4 flex justify-center items-center file-extension">.bru</span>}
|
||||
{itemType !== 'folder' && <span className="absolute right-2 top-4 flex justify-center items-center file-extension">.{collection?.format || 'bru'}</span>}
|
||||
</div>
|
||||
) : (
|
||||
<div className="relative flex flex-row gap-1 items-center justify-between">
|
||||
|
||||
45
tests/sidebar/rename-collection-item.spec.ts
Normal file
45
tests/sidebar/rename-collection-item.spec.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { test, expect } from '../../playwright';
|
||||
import { buildCommonLocators, createCollection, createRequest, closeAllCollections } from '../utils/page';
|
||||
|
||||
test.describe('Rename Collection Item - File Extension', () => {
|
||||
test.afterEach(async ({ page }) => {
|
||||
await closeAllCollections(page);
|
||||
});
|
||||
|
||||
test('should show .yml extension for OpenCollection format when renaming a request', async ({ page, createTmpDir }) => {
|
||||
const locators = buildCommonLocators(page);
|
||||
const testDir = await createTmpDir('yml-rename-test');
|
||||
|
||||
// Create a collection with OpenCollection (YAML) format
|
||||
await test.step('Create collection with OpenCollection format', async () => {
|
||||
await createCollection(page, 'YML Rename Test', testDir);
|
||||
});
|
||||
|
||||
// Create a request inside the collection
|
||||
await createRequest(page, 'Test Request', 'YML Rename Test');
|
||||
|
||||
// Open rename dialog via context menu
|
||||
await test.step('Open rename dialog and verify .yml extension', async () => {
|
||||
await locators.sidebar.request('Test Request').hover();
|
||||
await locators.actions.collectionItemActions('Test Request').click();
|
||||
await locators.dropdown.item('Rename').click();
|
||||
|
||||
const renameModal = page.locator('.bruno-modal').filter({ hasText: 'Rename Request' });
|
||||
await renameModal.waitFor({ state: 'visible' });
|
||||
|
||||
// Show filesystem name via Options dropdown
|
||||
await renameModal.locator('.btn-advanced').click();
|
||||
await page.locator('.dropdown-item').filter({ hasText: 'Show Filesystem Name' }).click();
|
||||
|
||||
// Click the IconEdit SVG to enable filename editing
|
||||
await renameModal.getByTestId('rename-request-edit-icon').click();
|
||||
|
||||
// Verify the extension shows .yml, not .bru
|
||||
const extensionLabel = renameModal.locator('.file-extension');
|
||||
await expect(extensionLabel).toHaveText('.yml');
|
||||
|
||||
// Close the rename modal
|
||||
await renameModal.getByRole('button', { name: 'Cancel' }).click();
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user