X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/f413fc528a8136c2ad8d33a57b3615fa22e55e93..refs/pull/2296/head:/tests/Entity/PageContentTest.php diff --git a/tests/Entity/PageContentTest.php b/tests/Entity/PageContentTest.php index 8a78c8ac0..99547fd17 100644 --- a/tests/Entity/PageContentTest.php +++ b/tests/Entity/PageContentTest.php @@ -1,7 +1,8 @@ -assertSee($content); } + public function test_page_includes_rendered_on_book_export() + { + $page = Page::query()->first(); + $secondPage = Page::query() + ->where('book_id', '!=', $page->book_id) + ->first(); + + $content = '

my cat is awesome and scratchy

'; + $secondPage->html = $content; + $secondPage->save(); + + $page->html = "{{@{$secondPage->id}#bkmrk-meow}}"; + $page->save(); + + $this->asEditor(); + $htmlContent = $this->get($page->book->getUrl('/export/html')); + $htmlContent->assertSee('my cat is awesome and scratchy'); + } + public function test_page_content_scripts_removed_by_default() { $this->asEditor(); @@ -242,6 +262,23 @@ class PageContentTest extends TestCase $this->assertEquals(substr_count($updatedPage->html, "bkmrk-test\""), 1); } + public function test_anchors_referencing_non_bkmrk_ids_rewritten_after_save() + { + $this->asEditor(); + $page = Page::first(); + + $content = '

test

link

'; + $this->put($page->getUrl(), [ + 'name' => $page->name, + 'html' => $content, + 'summary' => '' + ]); + + $updatedPage = Page::where('id', '=', $page->id)->first(); + $this->assertStringContainsString('id="bkmrk-test"', $updatedPage->html); + $this->assertStringContainsString('href="#bkmrk-test"', $updatedPage->html); + } + public function test_get_page_nav_sets_correct_properties() { $content = '

Hello

There

Donkey

'; @@ -303,4 +340,18 @@ class PageContentTest extends TestCase 'level' => 3, ], $navMap[2]); } + + public function test_page_text_decodes_html_entities() + { + $page = Page::query()->first(); + + $this->actingAs($this->getAdmin()) + ->put($page->getUrl(''), [ + 'name' => 'Testing', + 'html' => '

"Hello & welcome"

', + ]); + + $page->refresh(); + $this->assertEquals('"Hello & welcome"', $page->text); + } }