mirror of
https://github.com/usebruno/bruno.git
synced 2025-02-16 17:51:48 +01:00
This commit is contained in:
parent
e6c3a5af4c
commit
d3a56fdc82
@ -72,7 +72,7 @@ const getSize = (data) => {
|
|||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
const registerNetworkIpc = (mainWindow, watcher, lastOpenedCollections) => {
|
const registerNetworkIpc = (mainWindow) => {
|
||||||
// handler for sending http request
|
// handler for sending http request
|
||||||
ipcMain.handle('send-http-request', async (event, item, collectionUid, collectionPath, environment, collectionVariables) => {
|
ipcMain.handle('send-http-request', async (event, item, collectionUid, collectionPath, environment, collectionVariables) => {
|
||||||
const cancelTokenUid = uuid();
|
const cancelTokenUid = uuid();
|
||||||
@ -216,6 +216,7 @@ const registerNetworkIpc = (mainWindow, watcher, lastOpenedCollections) => {
|
|||||||
|
|
||||||
// run assertions
|
// run assertions
|
||||||
const assertions = get(request, 'assertions');
|
const assertions = get(request, 'assertions');
|
||||||
|
if(assertions && assertions.length) {
|
||||||
const assertRuntime = new AssertRuntime();
|
const assertRuntime = new AssertRuntime();
|
||||||
const results = assertRuntime.runAssertions(assertions, request, response, envVars, collectionVariables, collectionPath);
|
const results = assertRuntime.runAssertions(assertions, request, response, envVars, collectionVariables, collectionPath);
|
||||||
|
|
||||||
@ -226,9 +227,11 @@ const registerNetworkIpc = (mainWindow, watcher, lastOpenedCollections) => {
|
|||||||
requestUid,
|
requestUid,
|
||||||
collectionUid
|
collectionUid
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// run tests
|
// run tests
|
||||||
const testFile = item.draft ? get(item.draft, 'request.tests') : get(item, 'request.tests');
|
const testFile = item.draft ? get(item.draft, 'request.tests') : get(item, 'request.tests');
|
||||||
|
if(testFile && testFile.length) {
|
||||||
const testRuntime = new TestRuntime();
|
const testRuntime = new TestRuntime();
|
||||||
const testResults = testRuntime.runTests(testFile, request, response, envVars, collectionVariables, collectionPath);
|
const testResults = testRuntime.runTests(testFile, request, response, envVars, collectionVariables, collectionPath);
|
||||||
|
|
||||||
@ -240,6 +243,14 @@ const registerNetworkIpc = (mainWindow, watcher, lastOpenedCollections) => {
|
|||||||
collectionUid
|
collectionUid
|
||||||
});
|
});
|
||||||
|
|
||||||
|
mainWindow.webContents.send('main:script-environment-update', {
|
||||||
|
envVariables: testResults.envVariables,
|
||||||
|
collectionVariables: testResults.collectionVariables,
|
||||||
|
requestUid,
|
||||||
|
collectionUid
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
deleteCancelToken(cancelTokenUid);
|
deleteCancelToken(cancelTokenUid);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -263,6 +274,7 @@ const registerNetworkIpc = (mainWindow, watcher, lastOpenedCollections) => {
|
|||||||
if(error && error.response) {
|
if(error && error.response) {
|
||||||
// run assertions
|
// run assertions
|
||||||
const assertions = get(request, 'assertions');
|
const assertions = get(request, 'assertions');
|
||||||
|
if(assertions && assertions.length) {
|
||||||
const assertRuntime = new AssertRuntime();
|
const assertRuntime = new AssertRuntime();
|
||||||
const results = assertRuntime.runAssertions(assertions, request, error.response, envVars, collectionVariables, collectionPath);
|
const results = assertRuntime.runAssertions(assertions, request, error.response, envVars, collectionVariables, collectionPath);
|
||||||
|
|
||||||
@ -273,9 +285,11 @@ const registerNetworkIpc = (mainWindow, watcher, lastOpenedCollections) => {
|
|||||||
requestUid,
|
requestUid,
|
||||||
collectionUid
|
collectionUid
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// run tests
|
// run tests
|
||||||
const testFile = item.draft ? get(item.draft, 'request.tests') : get(item, 'request.tests');
|
const testFile = item.draft ? get(item.draft, 'request.tests') : get(item, 'request.tests');
|
||||||
|
if(testFile && testFile.length) {
|
||||||
const testRuntime = new TestRuntime();
|
const testRuntime = new TestRuntime();
|
||||||
const testResults = testRuntime.runTests(testFile, request, error.response, envVars, collectionVariables, collectionPath);
|
const testResults = testRuntime.runTests(testFile, request, error.response, envVars, collectionVariables, collectionPath);
|
||||||
|
|
||||||
@ -287,6 +301,14 @@ const registerNetworkIpc = (mainWindow, watcher, lastOpenedCollections) => {
|
|||||||
collectionUid
|
collectionUid
|
||||||
});
|
});
|
||||||
|
|
||||||
|
mainWindow.webContents.send('main:script-environment-update', {
|
||||||
|
envVariables: testResults.envVariables,
|
||||||
|
collectionVariables: testResults.collectionVariables,
|
||||||
|
requestUid,
|
||||||
|
collectionUid
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
status: error.response.status,
|
status: error.response.status,
|
||||||
statusText: error.response.statusText,
|
statusText: error.response.statusText,
|
||||||
@ -507,6 +529,7 @@ const registerNetworkIpc = (mainWindow, watcher, lastOpenedCollections) => {
|
|||||||
|
|
||||||
// run tests
|
// run tests
|
||||||
const testFile = item.draft ? get(item.draft, 'request.tests') : get(item, 'request.tests');
|
const testFile = item.draft ? get(item.draft, 'request.tests') : get(item, 'request.tests');
|
||||||
|
if(testFile && testFile.length) {
|
||||||
const testRuntime = new TestRuntime();
|
const testRuntime = new TestRuntime();
|
||||||
const testResults = testRuntime.runTests(testFile, request, response, envVars, collectionVariables, collectionPath);
|
const testResults = testRuntime.runTests(testFile, request, response, envVars, collectionVariables, collectionPath);
|
||||||
|
|
||||||
@ -516,6 +539,13 @@ const registerNetworkIpc = (mainWindow, watcher, lastOpenedCollections) => {
|
|||||||
...eventData
|
...eventData
|
||||||
});
|
});
|
||||||
|
|
||||||
|
mainWindow.webContents.send('main:script-environment-update', {
|
||||||
|
envVariables: testResults.envVariables,
|
||||||
|
collectionVariables: testResults.collectionVariables,
|
||||||
|
collectionUid
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
mainWindow.webContents.send('main:run-folder-event', {
|
mainWindow.webContents.send('main:run-folder-event', {
|
||||||
type: 'response-received',
|
type: 'response-received',
|
||||||
...eventData,
|
...eventData,
|
||||||
@ -562,6 +592,7 @@ const registerNetworkIpc = (mainWindow, watcher, lastOpenedCollections) => {
|
|||||||
|
|
||||||
// run tests
|
// run tests
|
||||||
const testFile = item.draft ? get(item.draft, 'request.tests') : get(item, 'request.tests');
|
const testFile = item.draft ? get(item.draft, 'request.tests') : get(item, 'request.tests');
|
||||||
|
if(testFile && testFile.length) {
|
||||||
const testRuntime = new TestRuntime();
|
const testRuntime = new TestRuntime();
|
||||||
const testResults = testRuntime.runTests(testFile, request, error.response, envVars, collectionVariables, collectionPath);
|
const testResults = testRuntime.runTests(testFile, request, error.response, envVars, collectionVariables, collectionPath);
|
||||||
|
|
||||||
@ -571,6 +602,13 @@ const registerNetworkIpc = (mainWindow, watcher, lastOpenedCollections) => {
|
|||||||
...eventData
|
...eventData
|
||||||
});
|
});
|
||||||
|
|
||||||
|
mainWindow.webContents.send('main:script-environment-update', {
|
||||||
|
envVariables: testResults.envVariables,
|
||||||
|
collectionVariables: testResults.collectionVariables,
|
||||||
|
collectionUid
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// if we get a response from the server, we consider it as a success
|
// if we get a response from the server, we consider it as a success
|
||||||
mainWindow.webContents.send('main:run-folder-event', {
|
mainWindow.webContents.send('main:run-folder-event', {
|
||||||
type: 'response-received',
|
type: 'response-received',
|
||||||
|
Loading…
Reference in New Issue
Block a user