X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/d29b177c8422075742ae22b200b84daa8c61c4b2..refs/pull/904/head:/tests/Entity/EntityTest.php diff --git a/tests/Entity/EntityTest.php b/tests/Entity/EntityTest.php index a43f65b5e..f8ca8ea12 100644 --- a/tests/Entity/EntityTest.php +++ b/tests/Entity/EntityTest.php @@ -5,6 +5,7 @@ use BookStack\Chapter; use BookStack\Page; use BookStack\Repos\EntityRepo; use BookStack\Repos\UserRepo; +use Carbon\Carbon; class EntityTest extends BrowserKitTest { @@ -82,6 +83,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('List View') + // Check redirection. + ->seePageIs('/books') + ->pageNotHasElement('.featured-image-container'); + + $this->actingAs($editor) + ->visit('/books') + ->submitForm('Grid View') + ->seePageIs('/books') + ->pageHasElement('.featured-image-container'); + + } + public function pageCreation($chapter) { $page = factory(Page::class)->make([ @@ -118,7 +140,7 @@ class EntityTest extends BrowserKitTest // Navigate to chapter create page ->visit($book->getUrl()) ->click('New Chapter') - ->seePageIs($book->getUrl() . '/chapter/create') + ->seePageIs($book->getUrl() . '/create-chapter') // Fill out form ->type($chapter->name, '#name') ->type($chapter->description, '#description') @@ -140,7 +162,7 @@ class EntityTest extends BrowserKitTest ->visit('/books') // Choose to create a book ->click('Create New Book') - ->seePageIs('/books/create') + ->seePageIs('/create-book') // Fill out form & save ->type($book->name, '#name') ->type($book->description, '#description') @@ -151,11 +173,11 @@ class EntityTest extends BrowserKitTest // Ensure duplicate names are given different slugs $this->asAdmin() - ->visit('/books/create') + ->visit('/create-book') ->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"); @@ -248,6 +270,9 @@ class EntityTest extends BrowserKitTest public function test_recently_updated_pages_on_home() { $page = Page::orderBy('updated_at', 'asc')->first(); + Page::where('id', '!=', $page->id)->update([ + 'updated_at' => Carbon::now()->subSecond(1) + ]); $this->asAdmin()->visit('/') ->dontSeeInElement('#recently-updated-pages', $page->name); $this->visit($page->getUrl() . '/edit')