]> BookStack Code Mirror - bookstack/commitdiff
Added testing to cover next/previous navigation
authorDan Brown <redacted>
Sat, 29 May 2021 11:49:10 +0000 (12:49 +0100)
committerDan Brown <redacted>
Sat, 29 May 2021 11:49:10 +0000 (12:49 +0100)
For #2511

app/Http/Controllers/BookController.php
app/Http/Controllers/ChapterController.php
app/Http/Controllers/PageController.php
resources/views/partials/entity-sibling-navigation.blade.php
tests/Entity/BookTest.php

index d111f9f0add92615563e8799500d73b6ac04950e..64ae982d565a35707cbdef1d0e417366cc7df2f5 100644 (file)
@@ -12,7 +12,6 @@ use BookStack\Exceptions\ImageUploadException;
 use Illuminate\Http\Request;
 use Illuminate\Validation\ValidationException;
 use Throwable;
-use Views;
 
 class BookController extends Controller
 {
index 1c968a82c251d7d864e02ad8cd572ff5e160bbca..d65b43cc12e701782628e838353f44dfc0fb6cb2 100644 (file)
@@ -11,7 +11,6 @@ use BookStack\Exceptions\NotFoundException;
 use Illuminate\Http\Request;
 use Illuminate\Validation\ValidationException;
 use Throwable;
-use Views;
 
 class ChapterController extends Controller
 {
index f76f0081070ae482dd5be4ac857ffa221784fc10..31ee4e970bd4952c9a9613863a723d33f7972560 100644 (file)
@@ -14,7 +14,6 @@ use Exception;
 use Illuminate\Http\Request;
 use Illuminate\Validation\ValidationException;
 use Throwable;
-use Views;
 
 class PageController extends Controller
 {
index 7743081beed77dcd5e72ab45074d7b0bcc393377..1f64bac3e5d56aa13f7733b0c0d24b98a67d15b9 100644 (file)
@@ -1,4 +1,4 @@
-<div class="grid half collapse-xs items-center mb-m px-m no-row-gap fade-in-when-active print-hidden">
+<div id="sibling-navigation" class="grid half collapse-xs items-center mb-m px-m no-row-gap fade-in-when-active print-hidden">
     <div>
         @if($previous)
             <a href="{{  $previous->getUrl()  }}" class="outline-hover no-link-style block rounded">
index 6c2cf30d416f9126880a3611b2d6dcd039f3cab5..74b0b0e0b4060f0b26ca808c88b60864cf2088cf 100644 (file)
@@ -31,4 +31,19 @@ class BookTest extends TestCase
         $redirectReq = $this->get($deleteReq->baseResponse->headers->get('location'));
         $redirectReq->assertNotificationContains('Book Successfully Deleted');
     }
+
+    public function test_next_previous_navigation_controls_show_within_book_content()
+    {
+        $book = Book::query()->first();
+        $chapter = $book->chapters->first();
+
+        $resp = $this->asEditor()->get($chapter->getUrl());
+        $resp->assertElementContains('#sibling-navigation', 'Next');
+        $resp->assertElementContains('#sibling-navigation', $chapter->pages[0]->name);
+
+        $resp = $this->get($chapter->pages[0]->getUrl());
+        $resp->assertElementContains('#sibling-navigation', $chapter->pages[1]->name);
+        $resp->assertElementContains('#sibling-navigation', 'Previous');
+        $resp->assertElementContains('#sibling-navigation', $chapter->name);
+    }
 }
\ No newline at end of file