mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-27 06:34:06 +00:00
* feat: enhance Bru grammar to support response blocks and examples - Added new grammar rules for response headers, status, and body types (JSON, XML, text). - Introduced parsing logic for example blocks, allowing multiple examples with various body types. - Implemented tests for example parsing, including edge cases and complex examples with authentication. - Created fixture files for simple and complex examples to validate parsing functionality. feat: extend jsonToBru functionality to support response handling and examples - Updated jsonToBru to include parsing for response headers, status, and body types (JSON, XML, text). - Enhanced example handling to support multiple examples with various body types. - Added comprehensive tests for example parsing, including edge cases and complex scenarios with authentication. - Created fixture files for testing the new features and validating parsing functionality. move: files to fixtures folder refactor: simplify response body handling in Bru grammar and JSON conversion - Removed specific body type handling (JSON, XML, text) from grammar and semantics. - Updated response body parsing in jsonToBru to handle a unified response body format. - Adjusted tests and fixtures to reflect changes in response body structure, ensuring compatibility with the new format. feat: add response bookmarking functionality to ResponsePane - Introduced ResponseBookmark component to allow users to save responses as examples. - Added NameExampleModal for naming saved examples. - Updated ResponsePane to include the new bookmarking feature. - Implemented Redux actions to manage response examples in the collections state. - Enhanced CollectionItem to display saved examples and allow for expansion. fix: remove unnecessary padding from ExampleItem component feat: implement delete and rename functionality for examples in ExampleItem component - Added DeleteExampleModal for confirming deletion of examples. - Integrated modal for renaming examples with state management. - Enhanced ExampleItem to handle example deletion and renaming through modals. - Updated Redux actions to support example updates and deletions in the collections state. fix: example writing to disc properly fix: example parsing errors fix: request with example parsing error fix: handle examples in collections and requests feat: implement response example functionality in the application - Added ResponseExample component to handle displaying and editing response examples. - Integrated ResponseExampleRequestPane and ResponseExampleResponsePane for structured request and response handling. - Enhanced RequestTabPanel and RequestTab components to support response-example tabs. - Introduced new styled components for better UI/UX in response examples. - Updated theme files to include styles for response examples. - Implemented URL bar for editing request URLs in response examples. - Added functionality for managing headers and parameters in response examples. - Improved overall structure and organization of response example components. add styles for example url bar feat: add Checkbox component and Table-v2 for enhanced UI - Introduced a new Checkbox component for better user interaction in forms. - Added Table-v2 component to improve table rendering and resizing functionality. - Updated existing components to utilize the new Checkbox and Table-v2 for managing headers and parameters in response examples. - Enhanced styling for better visual consistency across components. - Updated theme files to include styles for the new components. feat: implement custom scrollbar styles for response example components fix: features add actions , view more feat: enhance response example functionality - Added GenerateCodeItem component for generating code snippets from response examples. - Integrated modal for code generation within ResponseExample component. - Updated ResponseExampleTopBar to handle example name and description editing. - Improved state management for response examples, including new actions for updating names and descriptions. - Enhanced ResponseExampleRequestPane to support editing and saving request details. - Refactored URL handling in ResponseExampleUrlBar to utilize example-specific data. - Improved overall user experience with better UI elements and state management. feat: enhance response example management and UI components feat: enhance editing capabilities in response example components feat: update multipart form parameter handling in response examples feat: refactor response example parameter handling and enhance UI interactions feat: introduce RadioButton component and update Checkbox usage in response examples fix: styles fix radio button styling fixed radio button styles feat: add create example from sidebar feat: enhance ResponseExample components with layout adjustments and new HeightBoundContainer feat: add Checkbox and RadioButton components with comprehensive tests for rendering, user interactions, and accessibility feat: playwright test csaes rm: comments fix: linting fix: tests refactor: update response example tests and enhance functionality fix: tests fix: e2e-tests refactor: implement hasRequestChanges utility for better change detection rm: console rm: consoles fix: lint fix: tests fix: response header disabled by default issue Feat/with bru example parser (#5892) * fix: response header disabled by default issue feat: new parsing logic fix: change test cases to accomodate new brulang add: path params features rm:consoles six: make tab permanent on double click fix width feat: add status editing feat: review fixes review fixes fix: review fixes fix: post review mv: test files fix: review * fix: lint * fix: review comments * fix: icons folder strcuture fix: tests fix: lint fix: unit tests feat: body mode selector fix: close all collections rm: example feat added tests. lang change feat: add custom status text fix: status update feat: add body mode, update tests add default name prefilled for example fix: active tab styles, prefilled name, text fixes fix : pkg lock fix: review fix: review comments fix: hide cursor when readonly fix: height fix: null body fix: response body parsing fix: test cases feat: add method support for examples fix: reponse parsing fix: update response body type when content type is updated rm : commented code feat: update parser logic fix: organize files feat: enhance examples handling in collection export and import feat: postman imports fro examples feat: enhance OpenAPI import functionality to support examples feat: support postman export fix: postman export import fix: open api tests, remove requestbody related logic rm: examples fix: move common attributes files ui fixes fix: clone issue fix: create example from request menu review fixes more review fixes mv: files, fix mode req error organize files fix:tests fix: save dot issue fix: bugs fix: postman export fix: import path params * chore:improve modal handling in environment and response example tests fix: test issues resolved * chore: update response example tests to use new fixture files and improve cleanup logic --------- Co-authored-by: Abhishek S Lal <abhishek@usebruno.com> Co-authored-by: Bijin Bruno <bijin@usebruno.com>
131 lines
5.6 KiB
TypeScript
131 lines
5.6 KiB
TypeScript
import { test, expect } from '../../../playwright';
|
||
import path from 'path';
|
||
|
||
test.describe('Collection Environment Create Tests', () => {
|
||
test('should import collection and create environment for request usage', async ({
|
||
page,
|
||
createTmpDir
|
||
}) => {
|
||
const openApiFile = path.join(__dirname, 'fixtures', 'bruno-collection.json');
|
||
|
||
// Import test collection
|
||
await page.getByRole('button', { name: 'Import Collection' }).click();
|
||
|
||
const importModal = page.locator('[data-testid="import-collection-modal"]');
|
||
await importModal.waitFor({ state: 'visible' });
|
||
|
||
await page.setInputFiles('input[type="file"]', openApiFile);
|
||
|
||
const locationModal = page.locator('[data-testid="import-collection-location-modal"]');
|
||
await expect(locationModal.locator('.bruno-modal-header-title')).toContainText('Import Collection');
|
||
await expect(locationModal.getByText('test_collection')).toBeVisible();
|
||
|
||
await page.locator('#collection-location').fill(await createTmpDir('env-test'));
|
||
await page.getByRole('button', { name: 'Import', exact: true }).click();
|
||
|
||
await expect(page.locator('#sidebar-collection-name').filter({ hasText: 'test_collection' })).toBeVisible();
|
||
|
||
// Configure collection
|
||
await page.locator('#sidebar-collection-name').filter({ hasText: 'test_collection' }).click();
|
||
await page.getByLabel('Safe Mode').check();
|
||
await page.getByRole('button', { name: 'Save' }).click();
|
||
|
||
// Create environment
|
||
await page.locator('[data-testid="environment-selector-trigger"]').click();
|
||
await expect(page.locator('[data-testid="env-tab-collection"]')).toHaveClass(/active/);
|
||
|
||
// Create new environment
|
||
await page.locator('button[id="create-env"]').click();
|
||
|
||
// Fill environment name
|
||
const environmentNameInput = page.locator('input[name="name"]');
|
||
await expect(environmentNameInput).toBeVisible();
|
||
await environmentNameInput.fill('Test Environment');
|
||
await page.getByRole('button', { name: 'Create' }).click();
|
||
|
||
// Add environment variables
|
||
await page.locator('button[data-testid="add-variable"]').click();
|
||
await page.locator('input[name="0.name"]').fill('host');
|
||
await page
|
||
.locator('tr')
|
||
.filter({ has: page.locator('input[name="0.name"]') })
|
||
.locator('.CodeMirror')
|
||
.click();
|
||
await page.keyboard.type('https://echo.usebruno.com');
|
||
|
||
// Add userId
|
||
await page.locator('button[data-testid="add-variable"]').click();
|
||
await page.locator('input[name="1.name"]').fill('userId');
|
||
await page
|
||
.locator('tr')
|
||
.filter({ has: page.locator('input[name="1.name"]') })
|
||
.locator('.CodeMirror')
|
||
.click();
|
||
await page.keyboard.type('1');
|
||
|
||
// Add postTitle
|
||
await page.locator('button[data-testid="add-variable"]').click();
|
||
await page.locator('input[name="2.name"]').fill('postTitle');
|
||
await page
|
||
.locator('tr')
|
||
.filter({ has: page.locator('input[name="2.name"]') })
|
||
.locator('.CodeMirror')
|
||
.click();
|
||
await page.keyboard.type('Test Post from Environment');
|
||
|
||
// Add postBody
|
||
await page.locator('button[data-testid="add-variable"]').click();
|
||
await page.locator('input[name="3.name"]').fill('postBody');
|
||
await page
|
||
.locator('tr')
|
||
.filter({ has: page.locator('input[name="3.name"]') })
|
||
.locator('.CodeMirror')
|
||
.click();
|
||
await page.keyboard.type('This is a test post body with environment variables');
|
||
|
||
// Add secret token
|
||
await page.locator('button[data-testid="add-variable"]').click();
|
||
await page.locator('input[name="4.name"]').fill('secretApiToken');
|
||
await page
|
||
.locator('tr')
|
||
.filter({ has: page.locator('input[name="4.name"]') })
|
||
.locator('.CodeMirror')
|
||
.click();
|
||
await page.keyboard.type('super-secret-token-12345');
|
||
await page.locator('input[name="4.secret"]').check();
|
||
|
||
// Save environment
|
||
await page.getByRole('button', { name: 'Save' }).click();
|
||
await page.getByText('×').click();
|
||
await expect(page.locator('.current-environment')).toContainText('Test Environment');
|
||
|
||
// Test GET request with environment variables
|
||
await page.locator('.collection-item-name').first().click();
|
||
await expect(page.locator('#request-url .CodeMirror-line')).toContainText('{{host}}');
|
||
await page.locator('[data-testid="send-arrow-icon"]').click();
|
||
await page.locator('[data-testid="response-status-code"]').waitFor({ state: 'visible' });
|
||
await expect(page.locator('[data-testid="response-status-code"]')).toContainText('200');
|
||
|
||
// Verify the JSON response contains the environment variables
|
||
const responsePane = page.locator('.response-pane');
|
||
await expect(responsePane).toContainText('"userId": 1');
|
||
await expect(responsePane).toContainText('"title": "Test Post from Environment"');
|
||
await expect(responsePane).toContainText('"body": "This is a test post body with environment variables"');
|
||
await expect(responsePane).toContainText('"apiToken": "super-secret-token-12345"');
|
||
|
||
// Cleanup
|
||
await page
|
||
.locator('.collection-name')
|
||
.filter({ has: page.locator('#sidebar-collection-name:has-text("test_collection")') })
|
||
.locator('.collection-actions')
|
||
.click();
|
||
await page.locator('.dropdown-item').filter({ hasText: 'Close' }).click();
|
||
// Scope the Close button to the confirmation modal to avoid matching the dropdown close button
|
||
// Wait for the confirmation modal with "Close Collection" title to appear
|
||
const closeModal = page.getByRole('dialog').filter({ has: page.getByText('Close Collection') });
|
||
await closeModal.getByRole('button', { name: 'Close' }).click();
|
||
|
||
await page.locator('.bruno-logo').click();
|
||
});
|
||
});
|