@@ -7,6 +7,7 @@ const COMMANDS = {
77 START : 'coderoad.start' ,
88 OPEN_WEBVIEW : 'coderoad.open_webview' ,
99 RUN_TEST : 'coderoad.run_test' ,
10+ SET_CURRENT_STEP : 'coderoad.set_current_step' ,
1011}
1112
1213interface CreateCommandProps {
@@ -16,7 +17,7 @@ interface CreateCommandProps {
1617export const createCommands = ( { vscodeExt} : CreateCommandProps ) => {
1718 // React panel webview
1819 let webview : any
19-
20+ let currentStepId = ''
2021 return {
2122 // initialize
2223 [ COMMANDS . START ] : async ( ) => {
@@ -52,26 +53,32 @@ export const createCommands = ({vscodeExt}: CreateCommandProps) => {
5253
5354 webview . createOrShow ( column )
5455 } ,
55- [ COMMANDS . RUN_TEST ] : ( { stepId} : { stepId : string } ) => {
56- console . log ( 'run test webview' , Object . keys ( webview ) )
56+ [ COMMANDS . SET_CURRENT_STEP ] : ( { stepId} : { stepId : string } ) => {
57+ // NOTE: as async, may sometimes be inaccurate
58+ // set from last setup stepAction
59+ currentStepId = stepId
60+ } ,
61+ [ COMMANDS . RUN_TEST ] : ( current : { stepId : string } | undefined ) => {
62+ // use stepId from client, or last set stepId
63+ const payload = { stepId : current ? current . stepId : currentStepId }
5764 runTest ( {
5865 onSuccess : ( ) => {
5966 console . log ( 'COMMAND TEST_PASS' )
60- webview . send ( { type : 'TEST_PASS' , payload : { stepId } } )
67+ webview . send ( { type : 'TEST_PASS' , payload} )
6168 vscode . window . showInformationMessage ( 'PASS' )
6269 } ,
6370 onFail : ( ) => {
6471 console . log ( 'COMMAND TEST_FAIL' )
65- webview . send ( { type : 'TEST_FAIL' , payload : { stepId } } )
72+ webview . send ( { type : 'TEST_FAIL' , payload} )
6673 vscode . window . showWarningMessage ( 'FAIL' )
6774 } ,
6875 onError : ( ) => {
6976 console . log ( 'COMMAND TEST_ERROR' )
70- webview . send ( { type : 'TEST_ERROR' , payload : [ stepId ] } )
77+ webview . send ( { type : 'TEST_ERROR' , payload} )
7178 } ,
7279 onRun : ( ) => {
7380 console . log ( 'COMMAND TEST_RUN' )
74- webview . send ( { type : 'TEST_RUN' , payload : { stepId } } )
81+ webview . send ( { type : 'TEST_RUN' , payload} )
7582 }
7683 } )
7784 } ,
0 commit comments