feat: enhance script execution with environment variable support - #4209
Open
ajaaypranav-bt wants to merge 1 commit into
Open
feat: enhance script execution with environment variable support#4209ajaaypranav-bt wants to merge 1 commit into
ajaaypranav-bt wants to merge 1 commit into
Conversation
|
Hi Team, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
sp.global.set/sp.environment.setwere only available in pre-request scripts. This PR adds the full variable API —sp.global.set/getandsp.environment.set/get— to post-response (post-processing) scripts, in both the desktop and web apps, for REST requests as well as Testflows.Changes:
test-script-worker.ts(desktop + web): the post-script sandbox now receives the active environment variables and exposessp.environment(typeE) andsp.global(typeG) with the sameset/getimplementation as the pre-script worker, returning the mutated env to the caller.RestExplorerPage.ViewModel.ts+TestflowExplorerPage.ViewModel.ts, desktop + web): unlike pre-request scripts (wheresetonly affects the in-flight request's variable substitution), asetin post-processing would be a no-op without persistence. A newpersistScriptEnvironmentChangeshelper diffs the env returned by the script against the snapshot sent to it, then upserts changed keys into the workspace's global environment (G) or the currently selected environment (E) — RxDB only for guest users,environmentService.updateEnvironment+ repository/tab sync for logged-in users, mirroring the existingupdateEnvironmentflow (without toast notifications).{{token}}in node 2 within the same run.@sparrow-libraryeditor.ts): the post-script editor now completessp.environment./sp.global.→set/get.Example (post-response script):
Add Issue Number
Fixes #<your_issue_number>
Add Screenshots/GIFs
N/A
Add Known Issue
sp.environment.setchanges have nowhere to persist and are dropped silently.setcalls still only affect the outgoing request's variable substitution and are not persisted.Contribution Checklist: