@@ -7,6 +7,7 @@ const COMMANDS = {
77START :'coderoad.start' ,
88OPEN_WEBVIEW :'coderoad.open_webview' ,
99RUN_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
1819let webview :any
19-
20+ let currentStepId = ''
2021return {
2122// initialize
2223[ COMMANDS . START ] :async ( ) => {
@@ -52,26 +53,32 @@ export const createCommands = ({vscodeExt}: CreateCommandProps) => {
5253
5354webview . 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 }
5764runTest ( {
5865onSuccess :( ) => {
5966console . log ( 'COMMAND TEST_PASS' )
60- webview . send ( { type :'TEST_PASS' , payload : { stepId } } )
67+ webview . send ( { type :'TEST_PASS' , payload} )
6168vscode . window . showInformationMessage ( 'PASS' )
6269} ,
6370onFail :( ) => {
6471console . log ( 'COMMAND TEST_FAIL' )
65- webview . send ( { type :'TEST_FAIL' , payload : { stepId } } )
72+ webview . send ( { type :'TEST_FAIL' , payload} )
6673vscode . window . showWarningMessage ( 'FAIL' )
6774} ,
6875onError :( ) => {
6976console . log ( 'COMMAND TEST_ERROR' )
70- webview . send ( { type :'TEST_ERROR' , payload : [ stepId ] } )
77+ webview . send ( { type :'TEST_ERROR' , payload} )
7178} ,
7279onRun :( ) => {
7380console . log ( 'COMMAND TEST_RUN' )
74- webview . send ( { type :'TEST_RUN' , payload : { stepId } } )
81+ webview . send ( { type :'TEST_RUN' , payload} )
7582}
7683} )
7784} ,