Added bookshelves to breadcrumbs

- Updated breadcrumb dropdown switchers and back-end sibling code to handle new breadcrumbs.
- Added breadcrumb view composer and EntityContext system to mangage
tracking if in the context of a bookshelf.
This commit is contained in:
Dan Brown
2019-04-07 18:28:11 +01:00
parent 221a483b40
commit b12ae6d11b
10 changed files with 202 additions and 29 deletions

View File

@ -185,4 +185,30 @@ class BookShelfTest extends TestCase
$this->assertDatabaseHas('entity_permissions', ['restrictable_id' => $child->id, 'action' => 'update', 'role_id' => $editorRole->id]);
}
public function test_bookshelves_show_in_breadcrumbs_if_in_context()
{
$shelf = Bookshelf::first();
$shelfBook = $shelf->books()->first();
$shelfPage = $shelfBook->pages()->first();
$this->asAdmin();
$bookVisit = $this->get($shelfBook->getUrl());
$bookVisit->assertElementNotContains('.breadcrumbs', 'Shelves');
$bookVisit->assertElementNotContains('.breadcrumbs', $shelf->getShortName());
$this->get($shelf->getUrl());
$bookVisit = $this->get($shelfBook->getUrl());
$bookVisit->assertElementContains('.breadcrumbs', 'Shelves');
$bookVisit->assertElementContains('.breadcrumbs', $shelf->getShortName());
$pageVisit = $this->get($shelfPage->getUrl());
$pageVisit->assertElementContains('.breadcrumbs', 'Shelves');
$pageVisit->assertElementContains('.breadcrumbs', $shelf->getShortName());
$this->get('/books');
$pageVisit = $this->get($shelfPage->getUrl());
$pageVisit->assertElementNotContains('.breadcrumbs', 'Shelves');
$pageVisit->assertElementNotContains('.breadcrumbs', $shelf->getShortName());
}
}