Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): enable folder-level env manipulation for CLI #8495

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/insomnia-inso/src/cli.test.ts
Original file line number Diff line number Diff line change
@@ -160,6 +160,12 @@ describe('inso dev bundle', () => {

expect(secondReqLogPosition).toBeGreaterThan(firstReqLogPosition);
});

it('read and write folder environments', async () => {
const input = '$PWD/packages/insomnia-inso/bin/inso run collection wrk_cfacae2b022e49c8851c2376674cc890 -w packages/insomnia-inso/src/examples/script-folder-environments.yml --requestNamePattern "updateFolderValue" --verbose "FolderEnv"';
const result = await runCliFromRoot(input);
expect(result.stdout).toContain('updated value from folder: 666');
});
});
});

73 changes: 73 additions & 0 deletions packages/insomnia-inso/src/examples/script-folder-environments.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
_type: export
__export_format: 4
__export_date: 2024-08-05T10:12:24.557Z
__export_source: insomnia.desktop.app:v9.3.3
resources:
- _id: fld_01de564274824ecaad272330339ea6b3
parentId: wrk_cfacae2b022e49c8851c2376674cc890
modified: 1668533312225
created: 1668533312225
name: folder1
description: ""
environment:
val: "1"
environmentPropertyOrder: null
metaSortKey: -1668533312225
_type: request_group
afterResponseScript: ""
preRequestScript: ""
- _id: req_51dfc16d0f324a799e46aad52ffd0cd2
parentId: fld_01de564274824ecaad272330339ea6b3
modified: 1722852690008
created: 1722852503814
url: localhost:4010/echo
name: updateFolderValue
description: ""
method: GET
body: {}
parameters: []
headers:
- name: User-Agent
value: insomnia/9.3.3
authentication: {}
preRequestScript: |-
const folder1 = insomnia.parentFolders.get('folder1');
folder1.environment.set('val', '666');
const folder1ValFromFolder1 = folder1.environment.get('val');
console.log("updated value from folder: " + folder1ValFromFolder1)
metaSortKey: -1722852503814
isPrivate: false
pathParameters: []
settingStoreCookies: true
settingSendCookies: true
settingDisableRenderRequestBody: false
settingEncodeUrl: true
settingRebuildPath: true
settingFollowRedirects: global
_type: request
- _id: wrk_cfacae2b022e49c8851c2376674cc890
parentId: null
modified: 1722852498102
created: 1722852498102
name: FolderEnv
description: ""
scope: collection
_type: workspace
- _id: env_fa53fdd70393dd67a77da3c45c26f2b75ecbc1f2
parentId: wrk_cfacae2b022e49c8851c2376674cc890
modified: 1722852666754
created: 1722852498103
name: Base Environment
data: {}
dataPropertyOrder: {}
color: null
isPrivate: false
metaSortKey: 1722852498103
_type: environment
- _id: jar_fa53fdd70393dd67a77da3c45c26f2b75ecbc1f2
parentId: wrk_cfacae2b022e49c8851c2376674cc890
modified: 1722852666753
created: 1722852498104
name: Default Jar
cookies: []
_type: cookie_jar
1 change: 1 addition & 0 deletions packages/insomnia/src/scriptExecutor.ts
Original file line number Diff line number Diff line change
@@ -87,6 +87,7 @@ export const runScript = async (
globals: mutatedContextObject.globals,
requestTestResults: mutatedContextObject.requestTestResults,
execution: mutatedContextObject.execution,
parentFolders: mutatedContextObject.parentFolders,
};
};

Loading