X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/c429cf78187e80deb63982a282a1c6889f30291a..refs/pull/3365/head:/tests/User/UserPreferencesTest.php diff --git a/tests/User/UserPreferencesTest.php b/tests/User/UserPreferencesTest.php index 1d5d3e729..b39c2c47c 100644 --- a/tests/User/UserPreferencesTest.php +++ b/tests/User/UserPreferencesTest.php @@ -2,6 +2,7 @@ namespace Tests\User; +use BookStack\Entities\Models\Bookshelf; use Tests\TestCase; class UserPreferencesTest extends TestCase @@ -106,4 +107,44 @@ class UserPreferencesTest extends TestCase $home = $this->get('/login'); $home->assertElementExists('.dark-mode'); } + + public function test_books_view_type_preferences_when_list() + { + $editor = $this->getEditor(); + setting()->putUser($editor, 'books_view_type', 'list'); + + $this->actingAs($editor)->get('/books') + ->assertElementNotExists('.featured-image-container') + ->assertElementExists('.content-wrap .entity-list-item'); + } + + public function test_books_view_type_preferences_when_grid() + { + $editor = $this->getEditor(); + setting()->putUser($editor, 'books_view_type', 'grid'); + + $this->actingAs($editor)->get('/books') + ->assertElementExists('.featured-image-container'); + } + + public function test_shelf_view_type_change() + { + $editor = $this->getEditor(); + /** @var Bookshelf $shelf */ + $shelf = Bookshelf::query()->first(); + setting()->putUser($editor, 'bookshelf_view_type', 'list'); + + $this->actingAs($editor)->get($shelf->getUrl()) + ->assertElementNotExists('.featured-image-container') + ->assertElementExists('.content-wrap .entity-list-item') + ->assertSee('Grid View'); + + $req = $this->patch("/settings/users/{$editor->id}/switch-shelf-view", ['view_type' => 'grid']); + $req->assertRedirect($shelf->getUrl()); + + $this->actingAs($editor)->get($shelf->getUrl()) + ->assertElementExists('.featured-image-container') + ->assertElementNotExists('.content-wrap .entity-list-item') + ->assertSee('List View'); + } }