From ed6ec341dfc1dff765911b5b283884c56ef747fe Mon Sep 17 00:00:00 2001 From: Dan Brown <ssddanbrown@googlemail.com> Date: Sat, 29 May 2021 12:49:10 +0100 Subject: [PATCH] Added testing to cover next/previous navigation For #2511 --- app/Http/Controllers/BookController.php | 1 - app/Http/Controllers/ChapterController.php | 1 - app/Http/Controllers/PageController.php | 1 - .../partials/entity-sibling-navigation.blade.php | 2 +- tests/Entity/BookTest.php | 15 +++++++++++++++ 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/BookController.php b/app/Http/Controllers/BookController.php index d111f9f0a..64ae982d5 100644 --- a/app/Http/Controllers/BookController.php +++ b/app/Http/Controllers/BookController.php @@ -12,7 +12,6 @@ use BookStack\Exceptions\ImageUploadException; use Illuminate\Http\Request; use Illuminate\Validation\ValidationException; use Throwable; -use Views; class BookController extends Controller { diff --git a/app/Http/Controllers/ChapterController.php b/app/Http/Controllers/ChapterController.php index 1c968a82c..d65b43cc1 100644 --- a/app/Http/Controllers/ChapterController.php +++ b/app/Http/Controllers/ChapterController.php @@ -11,7 +11,6 @@ use BookStack\Exceptions\NotFoundException; use Illuminate\Http\Request; use Illuminate\Validation\ValidationException; use Throwable; -use Views; class ChapterController extends Controller { diff --git a/app/Http/Controllers/PageController.php b/app/Http/Controllers/PageController.php index f76f00810..31ee4e970 100644 --- a/app/Http/Controllers/PageController.php +++ b/app/Http/Controllers/PageController.php @@ -14,7 +14,6 @@ use Exception; use Illuminate\Http\Request; use Illuminate\Validation\ValidationException; use Throwable; -use Views; class PageController extends Controller { diff --git a/resources/views/partials/entity-sibling-navigation.blade.php b/resources/views/partials/entity-sibling-navigation.blade.php index 7743081be..1f64bac3e 100644 --- a/resources/views/partials/entity-sibling-navigation.blade.php +++ b/resources/views/partials/entity-sibling-navigation.blade.php @@ -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"> diff --git a/tests/Entity/BookTest.php b/tests/Entity/BookTest.php index 6c2cf30d4..74b0b0e0b 100644 --- a/tests/Entity/BookTest.php +++ b/tests/Entity/BookTest.php @@ -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