1
+ import * as T from 'typings'
1
2
import * as TT from 'typings/tutorial'
2
3
import * as vscode from 'vscode'
3
- import createTestRunner , { Payload } from '../services/testRunner'
4
+ import createTestRunner from '../services/testRunner'
4
5
import { setupActions } from '../actions/setupActions'
5
6
import createWebView from '../webview'
7
+ import logger from '../services/logger'
6
8
7
9
export const COMMANDS = {
8
10
START : 'coderoad.start' ,
9
11
OPEN_WEBVIEW : 'coderoad.open_webview' ,
10
12
CONFIG_TEST_RUNNER : 'coderoad.config_test_runner' ,
11
13
RUN_TEST : 'coderoad.run_test' ,
12
- SET_CURRENT_STEP : 'coderoad.set_current_step ' ,
14
+ SET_CURRENT_POSITION : 'coderoad.set_current_position ' ,
13
15
}
14
16
15
17
interface CreateCommandProps {
@@ -20,7 +22,7 @@ interface CreateCommandProps {
20
22
export const createCommands = ( { extensionPath, workspaceState } : CreateCommandProps ) => {
21
23
// React panel webview
22
24
let webview : any
23
- let currentStepId : string | null = ''
25
+ let currentPosition : T . Position
24
26
let testRunner : any
25
27
26
28
return {
@@ -55,32 +57,38 @@ export const createCommands = ({ extensionPath, workspaceState }: CreateCommandP
55
57
await setupActions ( { actions : config . actions , send : webview . send , path : config . path } )
56
58
}
57
59
testRunner = createTestRunner ( config , {
58
- onSuccess : ( payload : Payload ) => {
60
+ onSuccess : ( position : T . Position ) => {
61
+ logger ( 'test pass position' , position )
59
62
// send test pass message back to client
60
- webview . send ( { type : 'TEST_PASS' , payload } )
63
+ webview . send ( { type : 'TEST_PASS' , payload : { position } } )
61
64
} ,
62
- onFail : ( payload : Payload , message : string ) => {
65
+ onFail : ( position : T . Position , message : string ) => {
63
66
// send test fail message back to client with failure message
64
- webview . send ( { type : 'TEST_FAIL' , payload : { ... payload , message } } )
67
+ webview . send ( { type : 'TEST_FAIL' , payload : { position , message } } )
65
68
} ,
66
- onError : ( payload : Payload ) => {
67
- // send test error message back to client
68
- webview . send ( { type : 'TEST_ERROR' , payload } )
69
+ onError : ( position : T . Position ) => {
70
+ // TODO: send test error message back to client
71
+ const message = 'Error with test runner'
72
+ webview . send ( { type : 'TEST_ERROR' , payload : { position, message } } )
69
73
} ,
70
- onRun : ( payload : Payload ) => {
74
+ onRun : ( position : T . Position ) => {
71
75
// send test run message back to client
72
- webview . send ( { type : 'TEST_RUNNING' , payload } )
76
+ webview . send ( { type : 'TEST_RUNNING' , payload : { position } } )
73
77
} ,
74
78
} )
75
79
} ,
76
- [ COMMANDS . SET_CURRENT_STEP ] : ( { stepId } : Payload ) => {
80
+ [ COMMANDS . SET_CURRENT_POSITION ] : ( position : T . Position ) => {
77
81
// set from last setup stepAction
78
- currentStepId = stepId
82
+ currentPosition = position
79
83
} ,
80
- [ COMMANDS . RUN_TEST ] : ( current : Payload | undefined , onSuccess : ( ) => void ) => {
84
+ [ COMMANDS . RUN_TEST ] : ( callback ?: { onSuccess : ( ) => void } ) => {
85
+ logger ( 'run test current' , currentPosition )
81
86
// use stepId from client, or last set stepId
82
- const payload : Payload = { stepId : current && current . stepId ?. length ? current . stepId : currentStepId }
83
- testRunner ( payload , onSuccess )
87
+ // const position: T.Position = {
88
+ // ...current,
89
+ // stepId: current && current.position.stepId?.length ? current.position.stepId : currentPosition.stepId,
90
+ // }
91
+ testRunner ( currentPosition , callback ?. onSuccess )
84
92
} ,
85
93
}
86
94
}
0 commit comments