]> BookStack Code Mirror - bookstack/blobdiff - tests/User/UserProfileTest.php
Update settings.php
[bookstack] / tests / User / UserProfileTest.php
index 979064baa64d5aec99c4737cfd14b9607ecfa258..0a3a1a6b202fcf776457f9478ddba01e39cbd76b 100644 (file)
@@ -1,5 +1,8 @@
 <?php namespace Test\User;
 
+use Activity;
+use BookStack\Auth\User;
+use BookStack\Entities\Bookshelf;
 use Tests\BrowserKitTest;
 
 class UserProfileTest extends BrowserKitTest
@@ -9,7 +12,7 @@ class UserProfileTest extends BrowserKitTest
     public function setUp(): void
     {
         parent::setUp();
-        $this->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');
+    }
+
 }