+ 'data' => $expectedData->values()->all(),
+ 'total' => 2,
+ ]);
+ }
+
+ public function test_index_endpoint_returns_children_count()
+ {
+ $admin = $this->users->admin();
+
+ $book = Book::query()->whereHas('pages')->whereHas('chapters')->withCount(['pages', 'chapters'])->first();
+ $this->actingAs($admin)->delete($book->getUrl());
+
+ $deletion = Deletion::query()->orderBy('id')->first();
+
+ $resp = $this->getJson($this->baseEndpoint);
+
+ $expectedData = [
+ [
+ 'id' => $deletion->id,
+ 'deletable' => [
+ 'pages_count' => $book->pages_count,
+ 'chapters_count' => $book->chapters_count,
+ ],
+ ],
+ ];
+
+ $resp->assertJson([
+ 'data' => $expectedData,
+ 'total' => 1,
+ ]);
+ }
+
+ public function test_index_endpoint_returns_parent()
+ {
+ $admin = $this->users->admin();
+ $page = $this->entities->pageWithinChapter();
+
+ $this->actingAs($admin)->delete($page->getUrl());
+ $deletion = Deletion::query()->orderBy('id')->first();
+
+ $resp = $this->getJson($this->baseEndpoint);
+
+ $expectedData = [
+ [
+ 'id' => $deletion->id,
+ 'deletable' => [
+ 'parent' => [
+ 'id' => $page->chapter->id,
+ 'name' => $page->chapter->name,
+ 'type' => 'chapter',
+ ],
+ ],
+ ],
+ ];
+
+ $resp->assertJson([
+ 'data' => $expectedData,
+ 'total' => 1,