()
| 10 | * corresponding end mark was never executed - thus leaving it as a "stale step" |
| 11 | */ |
| 12 | export const getActiveStepsFromNavigationSteps = (): Record< |
| 13 | string, |
| 14 | boolean |
| 15 | > => { |
| 16 | const navigationSteps = getNavigationState(); |
| 17 | const { startMarkToStepsMap } = steps; |
| 18 | const numberOfSteps = Object.keys(navigationSteps).length; |
| 19 | if (numberOfSteps === 0) { |
| 20 | return {}; |
| 21 | } |
| 22 | |
| 23 | const activeSteps: Record<string, boolean> = {}; |
| 24 | const currentNavIndex = numberOfSteps - 1; |
| 25 | |
| 26 | const currentNavStep = getStepsFromNavigation(currentNavIndex); |
| 27 | |
| 28 | Object.keys(currentNavStep).forEach((startMark: string) => { |
| 29 | const ongoingSteps = startMarkToStepsMap[startMark] ?? []; |
| 30 | Object.keys(ongoingSteps).forEach(step => { |
| 31 | activeSteps[step] = true; |
| 32 | }); |
| 33 | }); |
| 34 | |
| 35 | // if nav length is >1, then check the nav step prior as well |
| 36 | if (numberOfSteps > 1) { |
| 37 | const prevNavStep = getStepsFromNavigation(currentNavIndex - 1); |
| 38 | |
| 39 | Object.keys(prevNavStep).forEach((startMark: string) => { |
| 40 | const prevNavSteps = startMarkToStepsMap[startMark] ?? []; |
| 41 | Object.keys(prevNavSteps).forEach(step => { |
| 42 | activeSteps[step] = true; |
| 43 | }); |
| 44 | }); |
| 45 | } |
| 46 | |
| 47 | return activeSteps; |
| 48 | }; |
| 49 | |
| 50 | // start mark for navigationSteps data structure |
| 51 | export const recordStartMark = (startMark: string) => { |
no test coverage detected