diff --git a/magellan-library/src/main/java/com/wealthfront/magellan/navigation/NavigationTraverser.kt b/magellan-library/src/main/java/com/wealthfront/magellan/navigation/NavigationTraverser.kt index 09bac315..511c8d05 100644 --- a/magellan-library/src/main/java/com/wealthfront/magellan/navigation/NavigationTraverser.kt +++ b/magellan-library/src/main/java/com/wealthfront/magellan/navigation/NavigationTraverser.kt @@ -41,7 +41,7 @@ public class NavigationTraverser(private val root: NavigableCompat) { "$VERTICAL_LINE$INDENT_SPACE" } node.getNavigationSnapshotRecursive( - indent + childIndent, + childIndent, index == children.lastIndex ) }.forEach { stringBuilder.append(it) } diff --git a/magellan-library/src/test/java/com/wealthfront/magellan/navigation/NavigationTraverserTest.kt b/magellan-library/src/test/java/com/wealthfront/magellan/navigation/NavigationTraverserTest.kt index 7bcfafdc..9b255980 100644 --- a/magellan-library/src/test/java/com/wealthfront/magellan/navigation/NavigationTraverserTest.kt +++ b/magellan-library/src/test/java/com/wealthfront/magellan/navigation/NavigationTraverserTest.kt @@ -84,20 +84,34 @@ internal class NavigationTraverserTest { @Test fun globalBackStackWithSiblingJourney() { - traverser = NavigationTraverser(siblingRoot) - - siblingRoot.transitionToState(Created(context)) + val rootJourney = + DummyJourney( + DummyJourney( + DummyJourney( + DummyJourney( + siblingRoot + ) + ) + ) + ) + traverser = NavigationTraverser(rootJourney) + + rootJourney.transitionToState(Created(context)) journey3.goToAnotherJourney() assertThat(traverser.getGlobalBackstackDescription()).isEqualTo( """ - SiblingJourney - ├ DummyJourney3 - | ├ DummyStep3 - | └ DummyStep4 - └ DummyJourney2 - ├ DummyStep1 - └ DummyStep2 + DummyJourney + └ DummyJourney + └ DummyJourney + └ DummyJourney + └ SiblingJourney + ├ DummyJourney3 + | ├ DummyStep3 + | └ DummyStep4 + └ DummyJourney2 + ├ DummyStep1 + └ DummyStep2 """.trimIndent() ) @@ -129,6 +143,16 @@ internal class NavigationTraverserTest { } } + private inner class DummyJourney(val otherJourney: Journey<*>) : Journey( + MagellanDummyLayoutBinding::inflate, + MagellanDummyLayoutBinding::container + ) { + + override fun onCreate(context: Context) { + navigator.goTo(otherJourney) + } + } + private inner class MultiStepJourney : Journey( MagellanDummyLayoutBinding::inflate, MagellanDummyLayoutBinding::container