+ public function test_read_endpoint_includes_chapter_and_page_contents()
+ {
+ $this->actingAsApiEditor();
+ $book = $this->entities->bookHasChaptersAndPages();
+ $chapter = $book->chapters()->first();
+ $chapterPage = $chapter->pages()->first();
+
+ $resp = $this->getJson($this->baseEndpoint . "/{$book->id}");
+
+ $directChildCount = $book->directPages()->count() + $book->chapters()->count();
+ $resp->assertStatus(200);
+ $resp->assertJsonCount($directChildCount, 'contents');
+ $resp->assertJson([
+ 'contents' => [
+ [
+ 'type' => 'chapter',
+ 'id' => $chapter->id,
+ 'name' => $chapter->name,
+ 'slug' => $chapter->slug,
+ 'pages' => [
+ [
+ 'id' => $chapterPage->id,
+ 'name' => $chapterPage->name,
+ 'slug' => $chapterPage->slug,
+ ]
+ ]
+ ]
+ ]
+ ]);
+ }
+
+ public function test_read_endpoint_contents_nested_pages_has_permissions_applied()
+ {
+ $this->actingAsApiEditor();
+
+ $book = $this->entities->bookHasChaptersAndPages();
+ $chapter = $book->chapters()->first();
+ $chapterPage = $chapter->pages()->first();
+ $customName = 'MyNonVisiblePageWithinAChapter';
+ $chapterPage->name = $customName;
+ $chapterPage->save();
+
+ $this->permissions->disableEntityInheritedPermissions($chapterPage);
+
+ $resp = $this->getJson($this->baseEndpoint . "/{$book->id}");
+ $resp->assertJsonMissing(['name' => $customName]);
+ }
+