From bc4978479715f11f8413103f870ee9745109c6be Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Sun, 12 Jun 2016 12:48:06 +0100 Subject: [PATCH] Added tests to cover page_move features --- resources/views/pages/move.blade.php | 2 +- tests/Entity/EntitySearchTest.php | 10 ++++++++++ tests/Entity/SortTest.php | 18 ++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/resources/views/pages/move.blade.php b/resources/views/pages/move.blade.php index 2c9437e77..5b02c827e 100644 --- a/resources/views/pages/move.blade.php +++ b/resources/views/pages/move.blade.php @@ -32,7 +32,7 @@
- +
@include('partials/loading-icon')
diff --git a/tests/Entity/EntitySearchTest.php b/tests/Entity/EntitySearchTest.php index 6b313e7b8..a9d9bc047 100644 --- a/tests/Entity/EntitySearchTest.php +++ b/tests/Entity/EntitySearchTest.php @@ -82,4 +82,14 @@ class EntitySearchTest extends TestCase $this->asAdmin()->visit('/search/books?term=' . $book->name) ->see('Book Search Results')->see('.entity-list', $book->name); } + + public function test_ajax_entity_search() + { + $page = \BookStack\Page::all()->last(); + $notVisitedPage = \BookStack\Page::first(); + $this->visit($page->getUrl()); + $this->asAdmin()->visit('/ajax/search/entities?term=' . $page->name)->see('.entity-list', $page->name); + $this->asAdmin()->visit('/ajax/search/entities?types=book&term=' . $page->name)->dontSee('.entity-list', $page->name); + $this->asAdmin()->visit('/ajax/search/entities')->see('.entity-list', $page->name)->dontSee($notVisitedPage->name); + } } diff --git a/tests/Entity/SortTest.php b/tests/Entity/SortTest.php index 8792a0a06..2f2f9109d 100644 --- a/tests/Entity/SortTest.php +++ b/tests/Entity/SortTest.php @@ -22,4 +22,22 @@ class SortTest extends TestCase ->dontSee($draft->name); } + public function test_page_move() + { + $page = \BookStack\Page::first(); + $currentBook = $page->book; + $newBook = \BookStack\Book::where('id', '!=', $currentBook->id)->first(); + $this->asAdmin()->visit($page->getUrl() . '/move') + ->see('Move Page')->see($page->name) + ->type('book:' . $newBook->id, 'entity_selection')->press('Move Page'); + + $page = \BookStack\Page::find($page->id); + $this->seePageIs($page->getUrl()); + $this->assertTrue($page->book->id == $newBook->id, 'Page book is now the new book'); + + $this->visit($newBook->getUrl()) + ->seeInNthElement('.activity-list-item', 0, 'moved page') + ->seeInNthElement('.activity-list-item', 0, $page->name); + } + } \ No newline at end of file