mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-09 06:55:03 +00:00
feat: support newer Postman export format with collection envelope (#8038)
- Updated the Postman collection importer to handle collections wrapped in a { collection: { ... } } format.
- Enhanced the parsing logic to extract collection info correctly from both legacy and newer formats.
- Added a new test case for importing a Postman v2.1 collection with the wrapped format to ensure compatibility.
This commit is contained in:
66
tests/import/postman/fixtures/postman-v21-wrapped.json
Normal file
66
tests/import/postman/fixtures/postman-v21-wrapped.json
Normal file
@@ -0,0 +1,66 @@
|
||||
{
|
||||
"collection": {
|
||||
"info": {
|
||||
"name": "Postman v2.1 Wrapped Collection",
|
||||
"description": "Test collection using newer Postman export format with collection envelope",
|
||||
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
|
||||
"_postman_id": "beaf4d12-a72a-47cb-902d-2942a68a59c4"
|
||||
},
|
||||
"item": [
|
||||
{
|
||||
"name": "Get Users",
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"header": [
|
||||
{
|
||||
"key": "Authorization",
|
||||
"value": "Bearer {{token}}",
|
||||
"type": "text"
|
||||
}
|
||||
],
|
||||
"url": {
|
||||
"raw": "{{baseUrl}}/users",
|
||||
"host": ["{{baseUrl}}"],
|
||||
"path": ["users"],
|
||||
"query": [
|
||||
{
|
||||
"key": "page",
|
||||
"value": "1"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "Create User",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"type": "text"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n \"name\": \"John Doe\",\n \"email\": \"john@example.com\"\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{baseUrl}}/users",
|
||||
"host": ["{{baseUrl}}"],
|
||||
"path": ["users"]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
],
|
||||
"variable": [
|
||||
{
|
||||
"key": "baseUrl",
|
||||
"value": "https://api.example.com"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
17
tests/import/postman/import-postman-v21-wrapped.spec.ts
Normal file
17
tests/import/postman/import-postman-v21-wrapped.spec.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { test } from '../../../playwright';
|
||||
import * as path from 'path';
|
||||
import { closeAllCollections, importCollection } from '../../utils/page';
|
||||
|
||||
test.describe('Import Postman Collection v2.1 (wrapped format)', () => {
|
||||
test.afterEach(async ({ page }) => {
|
||||
await closeAllCollections(page);
|
||||
});
|
||||
|
||||
test('Import Postman Collection v2.1 with collection envelope successfully', async ({ page, createTmpDir }) => {
|
||||
const postmanFile = path.resolve(__dirname, 'fixtures', 'postman-v21-wrapped.json');
|
||||
|
||||
await importCollection(page, postmanFile, await createTmpDir('postman-v21-wrapped-test'), {
|
||||
expectedCollectionName: 'Postman v2.1 Wrapped Collection'
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user