]> BookStack Code Mirror - bookstack/blobdiff - tests/Entity/EntityTest.php
Merge branch 'master' into translations
[bookstack] / tests / Entity / EntityTest.php
index 3bf6a3f2ac76ed88b56739a3459210c367c818ed..79e574cbd48d444670ccbd1dda90f84e71e44ee6 100644 (file)
@@ -136,7 +136,7 @@ class EntityTest extends TestCase
         $this->asAdmin()
             ->visit('/books')
             // Choose to create a book
-            ->click('Add new book')
+            ->click('Create New Book')
             ->seePageIs('/books/create')
             // Fill out form & save
             ->type($book->name, '#name')
@@ -151,8 +151,10 @@ class EntityTest extends TestCase
             ->visit('/books/create')
             ->type($book->name, '#name')
             ->type($book->description, '#description')
-            ->press('Save Book')
-            ->seePageIs('/books/my-first-book-2');
+            ->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");
 
         $book = \BookStack\Book::where('slug', '=', 'my-first-book')->first();
         return $book;
@@ -216,15 +218,27 @@ class EntityTest extends TestCase
 
     public function test_old_page_slugs_redirect_to_new_pages()
     {
-        $page = \BookStack\Page::all()->first();
+        $page = \BookStack\Page::first();
         $pageUrl = $page->getUrl();
         $newPageUrl = '/books/' . $page->book->slug . '/page/super-test-page';
+        // Need to save twice since revisions are not generated in seeder.
         $this->asAdmin()->visit($pageUrl)
+            ->clickInElement('#content', 'Edit')
+            ->type('super test', '#name')
+            ->press('Save Page');
+
+        $page = \BookStack\Page::first();
+        $pageUrl = $page->getUrl();
+
+        // Second Save
+        $this->visit($pageUrl)
             ->clickInElement('#content', 'Edit')
             ->type('super test page', '#name')
             ->press('Save Page')
-            ->seePageIs($newPageUrl)
-            ->visit($pageUrl)
+            // Check redirect
+            ->seePageIs($newPageUrl);
+
+        $this->visit($pageUrl)
             ->seePageIs($newPageUrl);
     }