]> BookStack Code Mirror - bookstack/commitdiff
Fixed failing home test after changes in last commit
authorDan Brown <redacted>
Fri, 18 Dec 2020 21:42:43 +0000 (21:42 +0000)
committerDan Brown <redacted>
Fri, 18 Dec 2020 21:44:35 +0000 (21:44 +0000)
Also made a restriction test more reliable.
Also renamed restrictionstest to entitypermissionstest to be more
consistent with newer app wording.

tests/HomepageTest.php
tests/Permissions/EntityPermissionsTest.php [moved from tests/Permissions/RestrictionsTest.php with 99% similarity]

index 3bc85b39e7e09fad373282118d1f330492b85235..943a3160a1915af2a803ed88cd82411e67f2336d 100644 (file)
@@ -98,16 +98,16 @@ class HomepageTest extends TestCase
     {
         $editor = $this->getEditor();
         setting()->putUser($editor, 'bookshelves_view_type', 'grid');
+        $shelf = Bookshelf::query()->firstOrFail();
 
         $this->setSettings(['app-homepage-type' => 'bookshelves']);
 
         $this->asEditor();
         $homeVisit = $this->get('/');
         $homeVisit->assertSee('Shelves');
-        $homeVisit->assertSee('bookshelf-grid-item grid-card');
         $homeVisit->assertSee('grid-card-content');
-        $homeVisit->assertSee('grid-card-footer');
         $homeVisit->assertSee('featured-image-container');
+        $homeVisit->assertElementContains('.grid-card', $shelf->name);
 
         $this->setSettings(['app-homepage-type' => false]);
         $this->test_default_homepage_visible();
similarity index 99%
rename from tests/Permissions/RestrictionsTest.php
rename to tests/Permissions/EntityPermissionsTest.php
index c3c6aa44fa6e4631203ec1af7c3417a406365edb..1e6d1cc325e6bff83ff55322dc05e0c99e0c22d1 100644 (file)
@@ -6,9 +6,10 @@ use BookStack\Entities\Models\Chapter;
 use BookStack\Entities\Models\Entity;
 use BookStack\Auth\User;
 use BookStack\Entities\Models\Page;
+use Illuminate\Support\Str;
 use Tests\BrowserKitTest;
 
-class RestrictionsTest extends BrowserKitTest
+class EntityPermissionsTest extends BrowserKitTest
 {
 
     /**
@@ -642,11 +643,15 @@ class RestrictionsTest extends BrowserKitTest
     public function test_page_visible_if_has_permissions_when_book_not_visible()
     {
         $book = Book::first();
-
-        $this->setEntityRestrictions($book, []);
-
         $bookChapter = $book->chapters->first();
         $bookPage = $bookChapter->pages->first();
+
+        foreach ([$book, $bookChapter, $bookPage] as $entity) {
+            $entity->name = Str::random(24);
+            $entity->save();
+        }
+
+        $this->setEntityRestrictions($book, []);
         $this->setEntityRestrictions($bookPage, ['view']);
 
         $this->actingAs($this->viewer);