mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-25 17:33:28 +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,29 +216,40 @@ const registerNetworkIpc = (mainWindow, watcher, lastOpenedCollections) => {
|
|||||||
|
|
||||||
// run assertions
|
// run assertions
|
||||||
const assertions = get(request, 'assertions');
|
const assertions = get(request, 'assertions');
|
||||||
const assertRuntime = new AssertRuntime();
|
if(assertions && assertions.length) {
|
||||||
const results = assertRuntime.runAssertions(assertions, request, response, envVars, collectionVariables, collectionPath);
|
const assertRuntime = new AssertRuntime();
|
||||||
|
const results = assertRuntime.runAssertions(assertions, request, response, envVars, collectionVariables, collectionPath);
|
||||||
|
|
||||||
mainWindow.webContents.send('main:run-request-event', {
|
mainWindow.webContents.send('main:run-request-event', {
|
||||||
type: 'assertion-results',
|
type: 'assertion-results',
|
||||||
results: results,
|
results: results,
|
||||||
itemUid: item.uid,
|
itemUid: item.uid,
|
||||||
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');
|
||||||
const testRuntime = new TestRuntime();
|
if(testFile && testFile.length) {
|
||||||
const testResults = testRuntime.runTests(testFile, request, response, envVars, collectionVariables, collectionPath);
|
const testRuntime = new TestRuntime();
|
||||||
|
const testResults = testRuntime.runTests(testFile, request, response, envVars, collectionVariables, collectionPath);
|
||||||
|
|
||||||
mainWindow.webContents.send('main:run-request-event', {
|
mainWindow.webContents.send('main:run-request-event', {
|
||||||
type: 'test-results',
|
type: 'test-results',
|
||||||
results: testResults.results,
|
results: testResults.results,
|
||||||
itemUid: item.uid,
|
itemUid: item.uid,
|
||||||
requestUid,
|
requestUid,
|
||||||
collectionUid
|
collectionUid
|
||||||
});
|
});
|
||||||
|
|
||||||
|
mainWindow.webContents.send('main:script-environment-update', {
|
||||||
|
envVariables: testResults.envVariables,
|
||||||
|
collectionVariables: testResults.collectionVariables,
|
||||||
|
requestUid,
|
||||||
|
collectionUid
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
deleteCancelToken(cancelTokenUid);
|
deleteCancelToken(cancelTokenUid);
|
||||||
|
|
||||||
@ -263,29 +274,40 @@ 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');
|
||||||
const assertRuntime = new AssertRuntime();
|
if(assertions && assertions.length) {
|
||||||
const results = assertRuntime.runAssertions(assertions, request, error.response, envVars, collectionVariables, collectionPath);
|
const assertRuntime = new AssertRuntime();
|
||||||
|
const results = assertRuntime.runAssertions(assertions, request, error.response, envVars, collectionVariables, collectionPath);
|
||||||
|
|
||||||
mainWindow.webContents.send('main:run-request-event', {
|
mainWindow.webContents.send('main:run-request-event', {
|
||||||
type: 'assertion-results',
|
type: 'assertion-results',
|
||||||
results: results,
|
results: results,
|
||||||
itemUid: item.uid,
|
itemUid: item.uid,
|
||||||
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');
|
||||||
const testRuntime = new TestRuntime();
|
if(testFile && testFile.length) {
|
||||||
const testResults = testRuntime.runTests(testFile, request, error.response, envVars, collectionVariables, collectionPath);
|
const testRuntime = new TestRuntime();
|
||||||
|
const testResults = testRuntime.runTests(testFile, request, error.response, envVars, collectionVariables, collectionPath);
|
||||||
|
|
||||||
mainWindow.webContents.send('main:run-request-event', {
|
mainWindow.webContents.send('main:run-request-event', {
|
||||||
type: 'test-results',
|
type: 'test-results',
|
||||||
results: testResults.results,
|
results: testResults.results,
|
||||||
itemUid: item.uid,
|
itemUid: item.uid,
|
||||||
requestUid,
|
requestUid,
|
||||||
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,
|
||||||
@ -507,14 +529,22 @@ 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');
|
||||||
const testRuntime = new TestRuntime();
|
if(testFile && testFile.length) {
|
||||||
const testResults = testRuntime.runTests(testFile, request, response, envVars, collectionVariables, collectionPath);
|
const testRuntime = new TestRuntime();
|
||||||
|
const testResults = testRuntime.runTests(testFile, request, response, envVars, collectionVariables, collectionPath);
|
||||||
|
|
||||||
mainWindow.webContents.send('main:run-folder-event', {
|
mainWindow.webContents.send('main:run-folder-event', {
|
||||||
type: 'test-results',
|
type: 'test-results',
|
||||||
testResults: testResults.results,
|
testResults: testResults.results,
|
||||||
...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',
|
||||||
@ -562,14 +592,22 @@ 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');
|
||||||
const testRuntime = new TestRuntime();
|
if(testFile && testFile.length) {
|
||||||
const testResults = testRuntime.runTests(testFile, request, error.response, envVars, collectionVariables, collectionPath);
|
const testRuntime = new TestRuntime();
|
||||||
|
const testResults = testRuntime.runTests(testFile, request, error.response, envVars, collectionVariables, collectionPath);
|
||||||
|
|
||||||
mainWindow.webContents.send('main:run-folder-event', {
|
mainWindow.webContents.send('main:run-folder-event', {
|
||||||
type: 'test-results',
|
type: 'test-results',
|
||||||
testResults: testResults.results,
|
testResults: testResults.results,
|
||||||
...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', {
|
||||||
|
Loading…
Reference in New Issue
Block a user