feat: enable importing folder-level scripts (#7504)

* feat: enable importing folder-level scripts

* fix snapshot

---------

Co-authored-by: jackkav <jackkav@gmail.com>
This commit is contained in:
Hexxa
2024-06-06 19:54:06 +08:00
committed by GitHub
parent 6b22f1d34f
commit 482eb7911e
2 changed files with 16 additions and 1 deletions

View File

@@ -4304,11 +4304,13 @@ exports[`Fixtures Import postman complex-v2_0_fromHeaders-input.json 1`] = `
{
"_id": "__GRP_2__",
"_type": "request_group",
"afterResponseScript": "",
"description": "",
"environment": {},
"metaSortKey": -1622117983999,
"name": "Projects",
"parentId": "__GRP_1__",
"preRequestScript": "",
},
{
"_id": "__REQ_1__",
@@ -4564,11 +4566,13 @@ exports[`Fixtures Import postman complex-v2_0-input.json 1`] = `
{
"_id": "__GRP_2__",
"_type": "request_group",
"afterResponseScript": "",
"description": "The first folder",
"environment": {},
"metaSortKey": -1622117983999,
"name": "First Folder",
"parentId": "__GRP_1__",
"preRequestScript": "",
},
{
"_id": "__REQ_1__",
@@ -4730,11 +4734,13 @@ exports[`Fixtures Import postman complex-v2_1-input.json 1`] = `
{
"_id": "__GRP_2__",
"_type": "request_group",
"afterResponseScript": "",
"description": "The first folder",
"environment": {},
"metaSortKey": -1622117983999,
"name": "First Folder",
"parentId": "__GRP_1__",
"preRequestScript": "",
},
{
"_id": "__REQ_1__",
@@ -8142,11 +8148,13 @@ exports[`Fixtures Import wsdl addition-input.wsdl 1`] = `
{
"_id": "__GRP_2__",
"_type": "request_group",
"afterResponseScript": "",
"description": "",
"environment": {},
"metaSortKey": -1622117983999,
"name": "Calculator",
"parentId": "__GRP_1__",
"preRequestScript": "",
},
{
"_id": "__REQ_1__",
@@ -8226,11 +8234,13 @@ exports[`Fixtures Import wsdl calculator-input.wsdl 1`] = `
{
"_id": "__GRP_2__",
"_type": "request_group",
"afterResponseScript": "",
"description": "",
"environment": {},
"metaSortKey": -1622117983999,
"name": "Calculator",
"parentId": "__GRP_1__",
"preRequestScript": "",
},
{
"_id": "__REQ_1__",

View File

@@ -243,13 +243,18 @@ export class ImportPostman {
}) as Parameter);
};
importFolderItem = ({ name, description }: Folder, parentId: string) => {
importFolderItem = ({ name, description, event }: Folder, parentId: string) => {
const preRequestScript = this.importPreRequestScript(event);
const afterResponseScript = this.importAfterResponseScript(event);
return {
parentId,
_id: `__GRP_${requestGroupCount++}__`,
_type: 'request_group',
name,
description: description || '',
preRequestScript,
afterResponseScript,
};
};