Skip to content

Commit 4cbf43d

Browse files
committed
#145 fixed script executor selection after HTTP error
1 parent 7e029c7 commit 4cbf43d

2 files changed

Lines changed: 27 additions & 4 deletions

File tree

web-src/src/main-app/store/scriptExecutionManager.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,10 @@ export default {
193193

194194
selectExecutor({commit, state, dispatch}, executor) {
195195
const currentExecutor = state.currentExecutor;
196-
if ((!isNull(currentExecutor))) {
197-
if (executor && (executor.state.id === currentExecutor.state.id)) {
196+
if (!isNull(currentExecutor)) {
197+
// Don't remove finished executor automatically, if it was cleaned up
198+
// unless id is null, meaning it was an error
199+
if (executor && !isNull(executor.state.id) && (executor.state.id === currentExecutor.state.id)) {
198200
return;
199201
}
200202

web-src/tests/unit/main-app/store/scriptExecutionManager_test.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ function mockActiveExecutions(executions) {
5757
}
5858
}
5959

60-
function mockStartResponse(id) {
61-
axiosMock.onPost('executions/start').reply(200, id);
60+
function mockStartResponse(id, status = 200) {
61+
axiosMock.onPost('executions/start').reply(status, id);
6262
}
6363

6464
describe('Test scriptExecutionManager', function () {
@@ -148,6 +148,27 @@ describe('Test scriptExecutionManager', function () {
148148

149149
assertSelectedExecutor(12);
150150
});
151+
152+
it('Test startExecution twice, when first is error', async function () {
153+
store.state.scripts.selectedScript = 'abc';
154+
155+
mockStartResponse(null, 500);
156+
157+
await store.dispatch('executions/startExecution');
158+
await flushPromises();
159+
160+
const currentExecutor = store.state.executions.currentExecutor;
161+
expect(currentExecutor).not.toBeNil();
162+
expect(currentExecutor.state.id).toBeNil();
163+
expect(currentExecutor.state.scriptName).toEqual('abc');
164+
165+
mockStartResponse(123);
166+
167+
await store.dispatch('executions/startExecution');
168+
await flushPromises();
169+
170+
assertSelectedExecutor(123);
171+
});
151172
});
152173

153174
describe('Test selectExecutor', function () {

0 commit comments

Comments
 (0)