@@ -45,33 +45,29 @@ const formatLevels = ({ progress, position, levels, testStatus }: Input): Output
4545 status = 'ACTIVE'
4646 }
4747 if ( step . subtasks && step . subtasks ) {
48- if ( Object . keys ( testStatus ?. summary || { } ) . length !== step . subtasks . length ) {
48+ const testSummaries = Object . keys ( testStatus ?. summary || { } )
49+ if ( testSummaries . length && testSummaries . length !== step . subtasks . length ) {
4950 // test result count and subtask count don't match
5051 // something is wrong with the tutorial
5152 // 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- } )
53+ console . error (
54+ 'ERROR: subtasks and test results have a different number of results. This is likely an error with the tutorial or an edited test file.' ,
55+ )
7456 }
57+ subtasks = step . subtasks . map ( ( subtask : string , subtaskIndex : number ) => {
58+ let subtaskStatus : T . ProgressStatus = 'INCOMPLETE'
59+ // task is complete, subtasks must be complete
60+ if ( status === 'COMPLETE' ) {
61+ subtaskStatus = 'COMPLETE'
62+ // task is active, check which are complete from test results
63+ } else if ( status === 'ACTIVE' ) {
64+ subtaskStatus = ! ! ( testStatus ?. summary && testStatus . summary [ subtaskIndex ] ) ? 'COMPLETE' : 'ACTIVE'
65+ }
66+ return {
67+ name : subtask ,
68+ status : subtaskStatus ,
69+ }
70+ } )
7571 }
7672 return { ...step , status, subtasks }
7773 } ) ,
0 commit comments