+ public function test_add_and_remove_redirect_to_entity_without_history()
+ {
+ $page = $this->entities->page();
+
+ $resp = $this->asEditor()->post('/favourites/add', [
+ 'type' => $page->getMorphClass(),
+ 'id' => $page->id,
+ ]);
+ $resp->assertRedirect($page->getUrl());
+
+ $resp = $this->asEditor()->post('/favourites/remove', [
+ 'type' => $page->getMorphClass(),
+ 'id' => $page->id,
+ ]);
+ $resp->assertRedirect($page->getUrl());
+ }
+
+ public function test_favourite_flow_with_own_permissions()
+ {
+ $book = $this->entities->book();
+ $user = User::factory()->create();
+ $book->owned_by = $user->id;
+ $book->save();
+
+ $this->permissions->grantUserRolePermissions($user, ['book-view-own']);
+
+ $this->actingAs($user)->get($book->getUrl());
+ $resp = $this->post('/favourites/add', [
+ 'type' => $book->getMorphClass(),
+ 'id' => $book->id,
+ ]);
+ $resp->assertRedirect($book->getUrl());
+
+ $this->assertDatabaseHas('favourites', [
+ 'user_id' => $user->id,
+ 'favouritable_type' => $book->getMorphClass(),
+ 'favouritable_id' => $book->id,
+ ]);
+ }
+
+ public function test_each_entity_type_shows_favourite_button()