mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-02 08:58:32 +00:00
* feat: enhance ScriptError with source context, code snippets, and navigation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: remove auto-commenting of untranslated pm commands during import Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: update CodeSnippet styles to use theme colors for error and warning highlights * fix: remove unused SCRIPT_TYPES import from network IPC module * refactor: remove unused functions and clean up source-context utility - Removed `getUnifiedScriptContext`, `getWarningSourceGroups`, and related helper functions from `source-context.js` to streamline the utility. - Updated tests in `source-context.spec.js` to reflect the removal of unused functions, ensuring only relevant tests for `findLineInSource` and `getScriptContext` remain. * refactor: simplify ScriptError component and update styles * refactor: streamline tab management in Script components * refactor: enhance tab management in ScriptError and add testsMetadata handling in prepare-request * refactor: improve error source identification in ScriptError component - Enhanced the logic for determining error source types by introducing separate checks for folder and collection files. - Updated the handling of folder file names to ensure accurate UID retrieval and labeling. - Streamlined the overall structure of the getErrorSourceInfo function for better readability and maintainability. * refactor: improve ScriptError component and enhance styling - Simplified the conditions for displaying the ScriptError component in ResponsePane. - Updated navigation logic in ScriptErrorCard to ensure proper handling of source information. - Adjusted styles in StyledWrapper to allow for visible overflow. - Enhanced ScriptErrorIcon to accept additional class names for better styling flexibility. - Minor layout adjustments in RunnerResults ResponsePane for improved UI consistency. * refactor: simplify test description for untranslated pm commands and consolidate error formatter imports * fixes * refactor: update focusedTab logic in Script components to use collection and folder UIDthe respective collection and folder UID instead of the activeTabUid. * feat: add buildErrorContext utility for enhanced error handling in network IPC - Introduced a new utility function `buildErrorContext` to construct detailed error context from script errors. - This function parses error locations, adjusts line numbers, and retrieves relevant source context, improving error reporting. - Removed the previous inline error handling logic from the network IPC module to streamline the codebase. * feat: added playwright test cases to test scriptError behavior * refactor: enhance ScriptError component and improve error handling - Updated labels for error source types in ScriptError to be more concise (e.g., "Request Script" to "Request"). - Improved navigation logic in ScriptErrorCard to ensure proper handling of navigable file paths. - Enhanced styling in StyledWrapper for better visual consistency and user experience. - Added tests to verify fallback behavior for missing error types and non-navigable file paths. - Refined utility functions for better context extraction from script errors. * refactor: normalize file paths for cross-platform compatibility in ScriptError component * refactor: improve file path handling in ScriptError component * refactor: enhance buildErrorContext for improved error handling * docs: add detailed comments to build-error-context for better understanding of error handling * refactor: enhance error block line detection in error formatter - Updated `findScriptBlockEndLine` and `findYmlScriptBlockEndLine` functions to return null for empty or missing blocks, improving accuracy in line detection. - Added comprehensive tests for both functions to ensure correct behavior across various scenarios, including handling of non-.bru and non-.yml files. * refactor: improve error handling and testing in ScriptError and buildErrorContext - Updated ScriptError component to streamline tab management by replacing focusTab with addTab for better request handling. - Enhanced buildErrorContext to return null for empty or missing script blocks in .bru and .yml files, ensuring accurate error reporting. - Added tests to validate behavior for empty script blocks and improved error context extraction in various scenarios. * test: add new tests for script error navigation and handling - Implemented tests for post-response file-path navigation to the Script tab and verification of active sub-tabs. - Added keyboard navigation tests to trigger file-path navigation using the Enter key. - Included a test for multiple error cards to ensure closing one does not affect others. - Enhanced runner tests to verify navigation to the Tests tab from script error results. * refactor: enhance CodeSnippet line rendering and remove unused source-context utilities * refactor: update locators in script-errors tests for improved readability and maintainability * test: enhance script-errors tests to verify error line content * review fixes * refactor: update RunnerResults component and enhance locators for improved testability * refactor: remove buildErrorContext and replace with formatErrorWithContextV2 - Deleted the buildErrorContext function and its associated tests. - Updated network IPC to utilize formatErrorWithContextV2 for improved error context handling. - Enhanced error reporting by ensuring structured error context is returned for desktop UI. * refactor: enhance tab components with data-testid attributes for improved testability - Added data-testid attributes to tab elements in CollectionSettings and FolderSettings components for better integration with testing frameworks. - Updated Tabs and ResponsiveTabs components to include data-testid attributes for tab triggers, enhancing the ability to select and verify tabs in tests. - Modified script-errors tests to utilize new locators for improved readability and maintainability. --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
bruno-converters
The converters package is responsible for converting collections from one format to a Bruno collection. It can be used as a standalone package or as a part of the Bruno framework.
Installation
npm install @usebruno/converters
Usage
Convert Postman collection to Bruno collection
const { postmanToBruno } = require('@usebruno/converters');
// Convert Postman collection to Bruno collection
const brunoCollection = postmanToBruno(postmanCollection);
Convert Postman Environment to Bruno Environment
const { postmanToBrunoEnvironment } = require('@usebruno/converters');
const brunoEnvironment = postmanToBrunoEnvironment(postmanEnvironment);
Convert Insomnia collection to Bruno collection
const { insomniaToBruno } = require('@usebruno/converters');
const brunoCollection = insomniaToBruno(insomniaCollection);
Convert OpenAPI specification to Bruno collection
const { openApiToBruno } = require('@usebruno/converters');
const brunoCollection = openApiToBruno(openApiSpecification);
Convert WSDL file to Bruno collection
import { wsdlToBruno } from '@usebruno/converters';
const brunoCollection = await wsdlToBruno(wsdlContent);
Example
const { postmanToBruno } = require('@usebruno/converters');
const fs = require('fs/promises');
const path = require('path');
async function convertPostmanToBruno(inputFile, outputFile) {
try {
// Read Postman collection file
const inputData = await fs.readFile(inputFile, 'utf8');
// Convert to Bruno collection
const brunoCollection = await postmanToBruno(JSON.parse(inputData));
// Save Bruno collection
await fs.writeFile(outputFile, JSON.stringify(brunoCollection, null, 2));
console.log('Conversion successful!');
} catch (error) {
console.error('Error during conversion:', error);
}
}
// Usage
const inputFilePath = path.resolve(__dirname, 'demo_collection.postman_collection.json');
const outputFilePath = path.resolve(__dirname, 'bruno-collection.json');
convertPostmanToBruno(inputFilePath, outputFilePath);
WSDL Import Features
The WSDL importer supports the following features:
- Service Discovery: Automatically extracts service endpoints from WSDL definitions
- Operation Mapping: Converts WSDL operations to Bruno HTTP requests
- SOAP Envelope Generation: Creates proper SOAP envelopes for each operation
- Header Configuration: Sets up appropriate Content-Type and SOAPAction headers
- Environment Variables: Creates environment variables for service base URLs
- Folder Organization: Groups operations by port type for better organization
WSDL Import Example
import { wsdlToBruno } from '@usebruno/converters';
import fs from 'fs/promises';
async function importWSDL() {
try {
// Read WSDL file
const wsdlContent = await fs.readFile('service.wsdl', 'utf8');
// Convert to Bruno collection
const brunoCollection = await wsdlToBruno(wsdlContent);
// Save Bruno collection
await fs.writeFile('soap-collection.json', JSON.stringify(brunoCollection, null, 2));
console.log('WSDL import successful!');
} catch (error) {
console.error('Error during WSDL import:', error);
}
}
importWSDL();
CLI Usage
You can also use the Bruno CLI to import WSDL files:
# Import WSDL file to a directory
bruno import wsdl --source service.wsdl --output ~/Desktop/soap-collection --collection-name "SOAP Service"
# Import WSDL from URL
bruno import wsdl --source https://example.com/service.wsdl --output ~/Desktop --collection-name "Remote SOAP Service"
# Import WSDL and save as JSON file
bruno import wsdl --source service.wsdl --output-file ~/Desktop/soap-collection.json --collection-name "SOAP Service"
Supported Formats
- Postman Collections (v2.1)
- Insomnia Collections (v4 and v5)
- OpenAPI Specifications (v3.0)
- WSDL Files (Web Services Description Language)
Dependencies
lodash- Utility functionsnanoid- UUID generationjs-yaml- YAML parsingxml2js- XML parsing for WSDL@usebruno/schema- Schema validation