@@ -45,20 +45,33 @@ const formatLevels = ({ progress, position, levels, testStatus }: Input): Output
4545 status = 'ACTIVE'
4646 }
4747 if ( step . subtasks && step . subtasks ) {
48- subtasks = step . subtasks . map ( ( subtask : string , subtaskIndex : number ) => {
49- let subtaskStatus : T . ProgressStatus = 'INCOMPLETE'
50- // task is complete, subtasks must be complete
51- if ( status === 'COMPLETE' ) {
52- subtaskStatus = 'COMPLETE'
53- // task is active, check which are complete from test results
54- } else if ( status === 'ACTIVE' ) {
55- subtaskStatus = ! ! ( testStatus ?. summary && testStatus . summary [ subtaskIndex ] ) ? 'COMPLETE' : 'ACTIVE'
56- }
57- return {
58- name : subtask ,
59- status : subtaskStatus ,
60- }
61- } )
48+ if ( Object . keys ( testStatus ?. summary || { } ) . length !== step . subtasks . length ) {
49+ // test result count and subtask count don't match
50+ // something is wrong with the tutorial
51+ // NOTE: hacky temp solution as should be caught by tutorial creators / build tools
52+ subtasks = [
53+ {
54+ name :
55+ 'ERROR: subtasks and test results have a different number of results. This is likely an error with the tutorial.' ,
56+ status : 'ACTIVE' as 'ACTIVE' ,
57+ } ,
58+ ]
59+ } else {
60+ subtasks = step . subtasks . map ( ( subtask : string , subtaskIndex : number ) => {
61+ let subtaskStatus : T . ProgressStatus = 'INCOMPLETE'
62+ // task is complete, subtasks must be complete
63+ if ( status === 'COMPLETE' ) {
64+ subtaskStatus = 'COMPLETE'
65+ // task is active, check which are complete from test results
66+ } else if ( status === 'ACTIVE' ) {
67+ subtaskStatus = ! ! ( testStatus ?. summary && testStatus . summary [ subtaskIndex ] ) ? 'COMPLETE' : 'ACTIVE'
68+ }
69+ return {
70+ name : subtask ,
71+ status : subtaskStatus ,
72+ }
73+ } )
74+ }
6275 }
6376 return { ...step , status, subtasks }
6477 } ) ,
0 commit comments