Exercise 2: Confirming the Cascade — Possible Solution ==================================================================== SETUP ------------------------------ Three real pages: id: 1, slug: 'java', fullPath: 'programming/java', parentId: id: 2, slug: 'fundamentals', fullPath: 'programming/java/fundamentals', parentId: 1 id: 3, slug: 'chapter-1', fullPath: 'programming/java/fundamentals/chapter-1', parentId: 2 MOVING java UNDER A NEW PARENT ------------------------------ await movePage(1, <'reference' page's own id>); WHAT HAPPENS ------------------------------ movePage() first updates page 1's own fullPath to 'reference/java' (or whatever the new parent's own path is, plus 'java'), then calls updateDescendantPaths(1). updateDescendantPaths(1) finds page 2 as a child of page 1, rebuilds its fullPath as 'reference/java/fundamentals' using page 1's own now-updated fullPath, saves it, then recurses into updateDescendantPaths(2) - which finds page 3, rebuilds its fullPath as 'reference/java/fundamentals/chapter-1', and saves it too. CONFIRMATION ------------------------------ All three pages now have fullPath values reflecting the new 'reference/java/...' branch, not just the directly-moved page 1 - the cascade reached every descendant, not only the immediate child. WHY THIS WORKS AS AN ANSWER ------------------------------ It correctly traces movePage()'s own two-step process (updating the moved page, then recursing through updateDescendantPaths()), and correctly shows the cascade reaching all the way down to a grandchild page, not stopping at the first level.