]> BookStack Code Mirror - bookstack/blobdiff - tests/Entity/EntityTest.php
Adds test cases and fixes an issue with the permission checking.
[bookstack] / tests / Entity / EntityTest.php
index a43f65b5efd568c58d1ce6a8e9c9343276d1be07..5492534177b9795eb36532c038aaa81e2ca2cb2f 100644 (file)
@@ -82,6 +82,27 @@ class EntityTest extends BrowserKitTest
             ->see($firstChapter->name);
     }
 
+    public function test_toggle_book_view()
+    {
+        $editor = $this->getEditor();
+        setting()->putUser($editor, 'books_view_type', 'grid');
+
+        $this->actingAs($editor)
+            ->visit('/books')
+            ->pageHasElement('.featured-image-container')
+            ->submitForm('Toggle Book View')
+            // Check redirection.
+            ->seePageIs('/books')
+            ->pageNotHasElement('.featured-image-container');
+
+        $this->actingAs($editor)
+            ->visit('/books')
+            ->submitForm('Toggle Book View')
+            ->seePageIs('/books')
+            ->pageHasElement('.featured-image-container');
+
+    }
+
     public function pageCreation($chapter)
     {
         $page = factory(Page::class)->make([
@@ -155,7 +176,7 @@ class EntityTest extends BrowserKitTest
             ->type($book->name, '#name')
             ->type($book->description, '#description')
             ->press('Save Book');
-        
+
         $expectedPattern = '/\/books\/my-first-book-[0-9a-zA-Z]{3}/';
         $this->assertRegExp($expectedPattern, $this->currentUri, "Did not land on expected page [$expectedPattern].\n");