File tree Expand file tree Collapse file tree 7 files changed +35
-8
lines changed Expand file tree Collapse file tree 7 files changed +35
-8
lines changed Original file line number Diff line number Diff line change @@ -309,14 +309,17 @@ class Channel implements Channel {
309309 // run test following solution to update position
310310 vscode . commands . executeCommand ( COMMANDS . RUN_TEST )
311311 return
312-
313312 case 'EDITOR_SYNC_PROGRESS' :
314313 // update progress when a level is deemed complete in the client
315314 await this . context . progress . syncProgress ( action . payload . progress )
316315 return
317316 case 'EDITOR_OPEN_LOGS' :
318317 const channel = action . payload . channel
319318 await showOutput ( channel )
319+ return
320+ case 'EDITOR_RUN_TEST' :
321+ vscode . commands . executeCommand ( COMMANDS . RUN_TEST )
322+ return
320323 default :
321324 logger ( `No match for action type: ${ actionType } ` )
322325 return
Original file line number Diff line number Diff line change @@ -36,6 +36,4 @@ if (!supportedOS.includes(OS_PLATFORM)) {
3636
3737export const TUTORIAL_URL : string | null = process . env . CODEROAD_TUTORIAL_URL || null
3838
39- export const DISABLE_AUTOSAVE = process . env . CODEROAD_DISABLE_AUTOSAVE
40- ? process . env . CODEROAD_DISABLE_AUTOSAVE . toLowerCase ( ) === 'true'
41- : false
39+ export const DISABLE_AUTOSAVE = ( process . env . CODEROAD_DISABLE_AUTOSAVE || '' ) . toLowerCase ( ) === 'true'
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import Markdown from '../../../components/Markdown'
99import ProcessMessages from '../../../components/ProcessMessages'
1010import NuxTutorial from '../../../components/NewUserExperience/NuxTutorial'
1111import Step from './Step'
12+ import { DISPLAY_RUN_TEST_BUTTON } from '../../../environment'
1213
1314const styles = {
1415 page : {
@@ -95,6 +96,7 @@ interface Props {
9596 processes : T . ProcessEvent [ ]
9697 testStatus : T . TestStatus | null
9798 onContinue ( ) : void
99+ onRunTest ( ) : void
98100 onLoadSolution ( ) : void
99101 onOpenLogs ( channel : string ) : void
100102}
@@ -107,6 +109,7 @@ const Level = ({
107109 index,
108110 status,
109111 onContinue,
112+ onRunTest,
110113 onLoadSolution,
111114 onOpenLogs,
112115 processes,
@@ -181,10 +184,16 @@ const Level = ({
181184 </ div >
182185
183186 < div css = { styles . footer } >
184- < span >
185- { typeof index === 'number' ? `${ index + 1 } . ` : '' }
186- { title }
187- </ span >
187+ { DISPLAY_RUN_TEST_BUTTON && status !== 'COMPLETE' ? (
188+ < Button type = "primary" onClick = { onRunTest } >
189+ Run
190+ </ Button >
191+ ) : (
192+ < span >
193+ { typeof index === 'number' ? `${ index + 1 } . ` : '' }
194+ { title }
195+ </ span >
196+ ) }
188197 < span >
189198 { status === 'COMPLETE' || ! steps . length ? (
190199 < Button type = "primary" onClick = { onContinue } >
Original file line number Diff line number Diff line change @@ -32,6 +32,10 @@ const TutorialPage = (props: PageProps) => {
3232 props . send ( { type : 'STEP_SOLUTION_LOAD' } )
3333 }
3434
35+ const onRunTest = ( ) : void => {
36+ props . send ( { type : 'RUN_TEST' } )
37+ }
38+
3539 const onOpenLogs = ( channel : string ) : void => {
3640 props . send ( { type : 'OPEN_LOGS' , payload : { channel } } )
3741 }
@@ -64,6 +68,7 @@ const TutorialPage = (props: PageProps) => {
6468 steps = { steps }
6569 status = { progress . levels [ position . levelId ] ? 'COMPLETE' : 'ACTIVE' }
6670 onContinue = { onContinue }
71+ onRunTest = { onRunTest }
6772 onLoadSolution = { onLoadSolution }
6873 onOpenLogs = { onOpenLogs }
6974 processes = { processes }
Original file line number Diff line number Diff line change @@ -12,3 +12,6 @@ export const NODE_ENV: string = process.env.NODE_ENV || 'development'
1212export const LOG : boolean = ( process . env . REACT_APP_LOG || '' ) . toLowerCase ( ) === 'true'
1313export const TUTORIAL_LIST_URL : string = process . env . REACT_APP_TUTORIAL_LIST_URL || ''
1414export const SENTRY_DSN : string | null = process . env . REACT_APP_SENTRY_DSN || null
15+
16+ // config variables
17+ export const DISPLAY_RUN_TEST_BUTTON = ( process . env . CODEROAD_DISPLAY_RUN_TEST_BUTTON || '' ) . toLowerCase ( ) === 'true'
Original file line number Diff line number Diff line change @@ -101,4 +101,10 @@ export default (editorSend: any) => ({
101101 payload : { channel : event . payload . channel } ,
102102 } )
103103 } ,
104+ runTest ( context : T . MachineContext ) {
105+ editorSend ( {
106+ type : 'EDITOR_RUN_TEST' ,
107+ payload : { position : context . position } ,
108+ } )
109+ } ,
104110} )
Original file line number Diff line number Diff line change @@ -177,6 +177,9 @@ export const createMachine = (options: any) => {
177177 OPEN_LOGS : {
178178 actions : [ 'editorOpenLogs' ] ,
179179 } ,
180+ RUN_TEST : {
181+ actions : [ 'runTest' ] ,
182+ } ,
180183 } ,
181184 } ,
182185 TestRunning : {
You can’t perform that action at this time.
0 commit comments