+
+ public function test_set_bookshelves_homepage()
+ {
+ $editor = $this->getEditor();
+ setting()->putUser($editor, 'bookshelves_view_type', 'grid');
+ $shelf = Bookshelf::query()->firstOrFail();
+
+ $this->setSettings(['app-homepage-type' => 'bookshelves']);
+
+ $this->asEditor();
+ $homeVisit = $this->get('/');
+ $homeVisit->assertSee('Shelves');
+ $homeVisit->assertSee('grid-card-content');
+ $homeVisit->assertSee('featured-image-container');
+ $this->withHtml($homeVisit)->assertElementContains('.grid-card', $shelf->name);
+
+ $this->setSettings(['app-homepage-type' => false]);
+ $this->test_default_homepage_visible();
+ }
+
+ public function test_shelves_list_homepage_adheres_to_book_visibility_permissions()
+ {
+ $editor = $this->getEditor();
+ setting()->putUser($editor, 'bookshelves_view_type', 'list');
+ $this->setSettings(['app-homepage-type' => 'bookshelves']);
+ $this->asEditor();
+
+ $shelf = Bookshelf::query()->first();
+ $book = $shelf->books()->first();
+
+ // Ensure initially visible
+ $homeVisit = $this->get('/');
+ $this->withHtml($homeVisit)->assertElementContains('.content-wrap', $shelf->name);
+ $this->withHtml($homeVisit)->assertElementContains('.content-wrap', $book->name);
+
+ // Ensure book no longer visible without view permission
+ $editor->roles()->detach();
+ $this->giveUserPermissions($editor, ['bookshelf-view-all']);
+ $homeVisit = $this->get('/');
+ $this->withHtml($homeVisit)->assertElementContains('.content-wrap', $shelf->name);
+ $this->withHtml($homeVisit)->assertElementNotContains('.content-wrap', $book->name);
+
+ // Ensure is visible again with entity-level view permission
+ $this->setEntityRestrictions($book, ['view'], [$editor->roles()->first()]);
+ $homeVisit = $this->get('/');
+ $this->withHtml($homeVisit)->assertElementContains('.content-wrap', $shelf->name);
+ $this->withHtml($homeVisit)->assertElementContains('.content-wrap', $book->name);
+ }
+
+ public function test_new_users_dont_have_any_recently_viewed()
+ {
+ $user = User::factory()->create();
+ $viewRole = Role::getRole('Viewer');
+ $user->attachRole($viewRole);
+
+ $homeVisit = $this->actingAs($user)->get('/');
+ $this->withHtml($homeVisit)->assertElementContains('#recently-viewed', 'You have not viewed any pages');
+ }