]> BookStack Code Mirror - bookstack/blobdiff - tests/Entity/PageEditorTest.php
Tests: Updated comment test to account for new editor usage
[bookstack] / tests / Entity / PageEditorTest.php
index 9340249568c0d58718d325d183365cdc3b5905a4..ad753c9664759c9d891d5a7050c07b8bbc97ac13 100644 (file)
@@ -24,6 +24,21 @@ class PageEditorTest extends TestCase
         $this->withHtml($this->followRedirects($resp))->assertElementExists('#html-editor');
     }
 
+    public function test_editor_set_for_new_pages()
+    {
+        $book = $this->page->book;
+
+        $this->asEditor()->get($book->getUrl('/create-page'));
+        $newPage = $book->pages()->orderBy('id', 'desc')->first();
+        $this->assertEquals('wysiwyg', $newPage->editor);
+
+        $this->setSettings(['app-editor' => PageEditorType::Markdown->value]);
+
+        $this->asEditor()->get($book->getUrl('/create-page'));
+        $newPage = $book->pages()->orderBy('id', 'desc')->first();
+        $this->assertEquals('markdown', $newPage->editor);
+    }
+
     public function test_markdown_setting_shows_markdown_editor_for_new_pages()
     {
         $this->setSettings(['app-editor' => PageEditorType::Markdown->value]);
@@ -176,20 +191,20 @@ class PageEditorTest extends TestCase
     {
         $resp = $this->asAdmin()->get($this->page->getUrl('/edit'));
         $editLink = $this->page->getUrl('/edit') . '?editor=';
-        $this->withHtml($resp)->assertElementContains("a[href=\"${editLink}markdown-clean\"]", '(Clean Content)');
-        $this->withHtml($resp)->assertElementContains("a[href=\"${editLink}markdown-stable\"]", '(Stable Content)');
-        $this->withHtml($resp)->assertElementContains("a[href=\"${editLink}wysiwyg2024\"]", '(In Alpha Testing)');
+        $this->withHtml($resp)->assertElementContains("a[href=\"{$editLink}markdown-clean\"]", '(Clean Content)');
+        $this->withHtml($resp)->assertElementContains("a[href=\"{$editLink}markdown-stable\"]", '(Stable Content)');
+        $this->withHtml($resp)->assertElementContains("a[href=\"{$editLink}wysiwyg2024\"]", '(In Beta Testing)');
 
         $resp = $this->asAdmin()->get($this->page->getUrl('/edit?editor=markdown-stable'));
         $editLink = $this->page->getUrl('/edit') . '?editor=';
-        $this->withHtml($resp)->assertElementContains("a[href=\"${editLink}wysiwyg\"]", 'Switch to WYSIWYG Editor');
+        $this->withHtml($resp)->assertElementContains("a[href=\"{$editLink}wysiwyg\"]", 'Switch to WYSIWYG Editor');
     }
 
     public function test_editor_type_switch_options_dont_show_if_without_change_editor_permissions()
     {
         $resp = $this->asEditor()->get($this->page->getUrl('/edit'));
         $editLink = $this->page->getUrl('/edit') . '?editor=';
-        $this->withHtml($resp)->assertElementNotExists("a[href*=\"${editLink}\"]");
+        $this->withHtml($resp)->assertElementNotExists("a[href*=\"{$editLink}\"]");
     }
 
     public function test_page_editor_type_switch_does_not_work_without_change_editor_permissions()