From c99da3a581160c06c85c089b9eb03ffa8c5be964 Mon Sep 17 00:00:00 2001 From: BruAlcaraz Date: Thu, 25 Jul 2024 08:27:55 -0300 Subject: [PATCH] Allow bru.setNextRequest() on Test Scripts (#2155) (#2552) Co-authored-by: Alcaraz, Bruno --- packages/bruno-cli/src/runner/run-single-request.js | 4 ++++ packages/bruno-electron/src/ipc/network/index.js | 4 ++++ packages/bruno-js/src/runtime/test-runtime.js | 6 ++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/bruno-cli/src/runner/run-single-request.js b/packages/bruno-cli/src/runner/run-single-request.js index 088f3dde7..f4e36e03a 100644 --- a/packages/bruno-cli/src/runner/run-single-request.js +++ b/packages/bruno-cli/src/runner/run-single-request.js @@ -352,6 +352,10 @@ const runSingleRequest = async function ( scriptingConfig ); testResults = get(result, 'results', []); + + if (result?.nextRequestName !== undefined) { + nextRequestName = result.nextRequestName; + } } if (testResults?.length) { diff --git a/packages/bruno-electron/src/ipc/network/index.js b/packages/bruno-electron/src/ipc/network/index.js index 825614a0f..49144d479 100644 --- a/packages/bruno-electron/src/ipc/network/index.js +++ b/packages/bruno-electron/src/ipc/network/index.js @@ -1047,6 +1047,10 @@ const registerNetworkIpc = (mainWindow) => { scriptingConfig ); + if (testResults?.nextRequestName !== undefined) { + nextRequestName = testResults.nextRequestName; + } + mainWindow.webContents.send('main:run-folder-event', { type: 'test-results', testResults: testResults.results, diff --git a/packages/bruno-js/src/runtime/test-runtime.js b/packages/bruno-js/src/runtime/test-runtime.js index ddafd513a..cd6f378f0 100644 --- a/packages/bruno-js/src/runtime/test-runtime.js +++ b/packages/bruno-js/src/runtime/test-runtime.js @@ -76,7 +76,8 @@ class TestRuntime { request, envVariables, runtimeVariables, - results: __brunoTestResults.getResults() + results: __brunoTestResults.getResults(), + nextRequestName: bru.nextRequest }; } @@ -147,7 +148,8 @@ class TestRuntime { request, envVariables: cleanJson(envVariables), runtimeVariables: cleanJson(runtimeVariables), - results: cleanJson(__brunoTestResults.getResults()) + results: cleanJson(__brunoTestResults.getResults()), + nextRequestName: bru.nextRequest }; } }