+ public function test_book_chapter_shelf_pages_contain_favourite_button()
+ {
+ $entities = [
+ Bookshelf::query()->first(),
+ Book::query()->first(),
+ Chapter::query()->first(),
+ ];
+ $this->actingAs($this->getEditor());
+
+ foreach ($entities as $entity) {
+ $resp = $this->get($entity->getUrl());
+ $resp->assertElementExists('form[method="POST"][action$="/favourites/add"]');
+ }
+ }
+
+ public function test_header_contains_link_to_favourites_page_when_logged_in()
+ {
+ $this->setSettings(['app-public' => 'true']);
+ $this->get('/')->assertElementNotContains('header', 'My Favourites');
+ $this->actingAs($this->getViewer())->get('/')->assertElementContains('header a', 'My Favourites');
+ }
+
+ public function test_favourites_shown_on_homepage()
+ {
+ $editor = $this->getEditor();
+
+ $resp = $this->actingAs($editor)->get('/');
+ $resp->assertElementNotExists('#top-favourites');
+
+ /** @var Page $page */
+ $page = Page::query()->first();
+ $page->favourites()->save((new Favourite)->forceFill(['user_id' => $editor->id]));
+
+ $resp = $this->get('/');
+ $resp->assertElementExists('#top-favourites');
+ $resp->assertElementContains('#top-favourites', $page->name);
+ }
+
+ public function test_favourites_list_page_shows_favourites_and_has_working_pagination()
+ {
+ /** @var Page $page */
+ $page = Page::query()->first();
+ $editor = $this->getEditor();
+
+ $resp = $this->actingAs($editor)->get('/favourites');
+ $resp->assertDontSee($page->name);
+
+ $page->favourites()->save((new Favourite)->forceFill(['user_id' => $editor->id]));
+
+ $resp = $this->get('/favourites');
+ $resp->assertSee($page->name);
+
+ $resp = $this->get('/favourites?page=2');
+ $resp->assertDontSee($page->name);
+ }
+