X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/badaf08e554e172051db0b8e210b734d8355ba58..refs/pull/3039/head:/tests/Entity/PageEditorTest.php diff --git a/tests/Entity/PageEditorTest.php b/tests/Entity/PageEditorTest.php index 8d1c56e16..652bc1336 100644 --- a/tests/Entity/PageEditorTest.php +++ b/tests/Entity/PageEditorTest.php @@ -2,15 +2,16 @@ namespace Tests\Entity; +use BookStack\Entities\Models\Book; use BookStack\Entities\Models\Page; use Tests\TestCase; class PageEditorTest extends TestCase { - /** @var Page */ + /** @var Page */ protected $page; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->page = Page::query()->first(); @@ -49,4 +50,28 @@ class PageEditorTest extends TestCase $this->asAdmin()->get($this->page->getUrl() . '/edit') ->assertElementContains('[name="markdown"]', $this->page->html); } -} \ No newline at end of file + + public function test_empty_markdown_still_saves_without_error() + { + $this->setSettings(['app-editor' => 'markdown']); + /** @var Book $book */ + $book = Book::query()->first(); + + $this->asEditor()->get($book->getUrl('/create-page')); + $draft = Page::query()->where('book_id', '=', $book->id) + ->where('draft', '=', true)->first(); + + $details = [ + 'name' => 'my page', + 'markdown' => '', + ]; + $resp = $this->post($book->getUrl("/draft/{$draft->id}"), $details); + $resp->assertRedirect(); + + $this->assertDatabaseHas('pages', [ + 'markdown' => $details['markdown'], + 'id' => $draft->id, + 'draft' => false, + ]); + } +}