X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/f84bf8e883e8e5bd9a24b908e2f90a2742d36d19..refs/pull/2023/head:/tests/User/UserProfileTest.php diff --git a/tests/User/UserProfileTest.php b/tests/User/UserProfileTest.php index 979064baa..0a3a1a6b2 100644 --- a/tests/User/UserProfileTest.php +++ b/tests/User/UserProfileTest.php @@ -1,5 +1,8 @@ user = \BookStack\Auth\User::all()->last(); + $this->user = User::all()->last(); } public function test_profile_page_shows_name() @@ -57,8 +60,8 @@ class UserProfileTest extends BrowserKitTest $newUser = $this->getNewBlankUser(); $this->actingAs($newUser); $entities = $this->createEntityChainBelongingToUser($newUser, $newUser); - \Activity::add($entities['book'], 'book_update', $entities['book']->id); - \Activity::add($entities['page'], 'page_create', $entities['book']->id); + Activity::add($entities['book'], 'book_update', $entities['book']->id); + Activity::add($entities['page'], 'page_create', $entities['book']->id); $this->asAdmin()->visit('/user/' . $newUser->id) ->seeInElement('#recent-user-activity', 'updated book') @@ -71,8 +74,8 @@ class UserProfileTest extends BrowserKitTest $newUser = $this->getNewBlankUser(); $this->actingAs($newUser); $entities = $this->createEntityChainBelongingToUser($newUser, $newUser); - \Activity::add($entities['book'], 'book_update', $entities['book']->id); - \Activity::add($entities['page'], 'page_create', $entities['book']->id); + Activity::add($entities['book'], 'book_update', $entities['book']->id); + Activity::add($entities['page'], 'page_create', $entities['book']->id); $this->asAdmin()->visit('/')->clickInElement('#recent-activity', $newUser->name) ->seePageIs('/user/' . $newUser->id) @@ -89,7 +92,7 @@ class UserProfileTest extends BrowserKitTest public function test_guest_profile_cannot_be_deleted() { - $guestUser = \BookStack\Auth\User::getDefault(); + $guestUser = User::getDefault(); $this->asAdmin()->visit('/settings/users/' . $guestUser->id . '/delete') ->see('Delete User')->see('Guest') ->press('Confirm') @@ -118,4 +121,24 @@ class UserProfileTest extends BrowserKitTest ->pageHasElement('.featured-image-container'); } + public function test_shelf_view_type_change() + { + $editor = $this->getEditor(); + $shelf = Bookshelf::query()->first(); + setting()->putUser($editor, 'bookshelf_view_type', 'list'); + + $this->actingAs($editor)->visit($shelf->getUrl()) + ->pageNotHasElement('.featured-image-container') + ->pageHasElement('.content-wrap .entity-list-item') + ->see('Grid View'); + + $req = $this->patch("/settings/users/{$editor->id}/switch-shelf-view", ['view_type' => 'grid']); + $req->assertRedirectedTo($shelf->getUrl()); + + $this->actingAs($editor)->visit($shelf->getUrl()) + ->pageHasElement('.featured-image-container') + ->pageNotHasElement('.content-wrap .entity-list-item') + ->see('List View'); + } + }