X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/f99af807d044b55ef8ec6c43d8ad8c7d61b47146..refs/pull/3245/head:/tests/Entity/PageDraftTest.php diff --git a/tests/Entity/PageDraftTest.php b/tests/Entity/PageDraftTest.php index 21a74768f..cac1babea 100644 --- a/tests/Entity/PageDraftTest.php +++ b/tests/Entity/PageDraftTest.php @@ -20,7 +20,7 @@ class PageDraftTest extends TestCase */ protected $pageRepo; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->page = Page::query()->first(); @@ -138,8 +138,6 @@ class PageDraftTest extends TestCase ]); } - - public function test_draft_pages_show_on_homepage() { /** @var Book $book */ @@ -180,4 +178,30 @@ class PageDraftTest extends TestCase 'html' => $page->html, ]); } + + public function test_updating_page_draft_with_markdown_retains_markdown_content() + { + /** @var Book $book */ + $book = Book::query()->first(); + $this->asEditor()->get($book->getUrl('/create-page')); + /** @var Page $draft */ + $draft = Page::query()->where('draft', '=', true)->where('book_id', '=', $book->id)->firstOrFail(); + + $resp = $this->put('/ajax/page/' . $draft->id . '/save-draft', [ + 'name' => 'My updated draft', + 'markdown' => "# My markdown page\n\n[A link](https://example.com)", + 'html' => '
checking markdown takes priority over this
', + ]); + $resp->assertOk(); + + $this->assertDatabaseHas('pages', [ + 'id' => $draft->id, + 'draft' => true, + 'name' => 'My updated draft', + 'markdown' => "# My markdown page\n\n[A link](https://example.com)", + ]); + + $draft->refresh(); + $this->assertStringContainsString('href="https://example.com"', $draft->html); + } }