Review of #2682, Also added parent deletion link on restore

On restore, added a link to the parent deletion restore if any exists
on a cascading parent. Added a test to cover this case to ensure its shown.

Also tweaked default empty state message on recycle bin item list to align
with new column count.

Also done a little existing code cleanup including a getUrl helper on
the deletion items.

Related to #2682 & #2594
This commit is contained in:
Dan Brown
2021-06-26 12:12:11 +01:00
parent 8a9505bf8c
commit 3a402f6adc
7 changed files with 63 additions and 9 deletions

View File

@ -247,4 +247,22 @@ class RecycleBinTest extends TestCase
$chapter->refresh();
$this->assertNull($chapter->deleted_at);
}
public function test_restore_page_shows_link_to_parent_restore_if_parent_also_deleted()
{
/** @var Book $book */
$book = Book::query()->whereHas('pages')->whereHas('chapters')->with(['pages', 'chapters'])->firstOrFail();
$chapter = $book->chapters->first();
/** @var Page $page */
$page = $chapter->pages->first();
$this->asEditor()->delete($page->getUrl());
$this->asEditor()->delete($book->getUrl());
$bookDeletion = $book->deletions()->first();
$pageDeletion = $page->deletions()->first();
$pageRestoreView = $this->asAdmin()->get("/settings/recycle-bin/{$pageDeletion->id}/restore");
$pageRestoreView->assertSee('The parent of this item has also been deleted.');
$pageRestoreView->assertElementContains('a[href$="/settings/recycle-bin/' . $bookDeletion->id. '/restore"]', 'Restore Parent');
}
}