X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/31495758a9459d13d6dd4718262c23f7f763bc92..refs/pull/5676/head:/tests/Entity/PageContentTest.php diff --git a/tests/Entity/PageContentTest.php b/tests/Entity/PageContentTest.php index 6d6224abf..23a38b573 100644 --- a/tests/Entity/PageContentTest.php +++ b/tests/Entity/PageContentTest.php @@ -8,7 +8,7 @@ use Tests\TestCase; class PageContentTest extends TestCase { - protected $base64Jpeg = '/9j/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/yQALCAABAAEBAREA/8wABgAQEAX/2gAIAQEAAD8A0s8g/9k='; + protected string $base64Jpeg = '/9j/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/yQALCAABAAEBAREA/8wABgAQEAX/2gAIAQEAAD8A0s8g/9k='; public function test_page_includes() { @@ -57,55 +57,48 @@ class PageContentTest extends TestCase $this->assertEquals('', $page->text); } - public function test_page_includes_do_not_break_tables() + public function test_page_includes_rendered_on_book_export() { $page = $this->entities->page(); - $secondPage = $this->entities->page(); + $secondPage = Page::query() + ->where('book_id', '!=', $page->book_id) + ->first(); - $content = '
test |
my cat is awesome and scratchy
'; $secondPage->html = $content; $secondPage->save(); - $page->html = "{{@{$secondPage->id}#table}}"; + $page->html = "{{@{$secondPage->id}#bkmrk-meow}}"; $page->save(); - $pageResp = $this->asEditor()->get($page->getUrl()); - $pageResp->assertSee($content, false); + $this->asEditor(); + $htmlContent = $this->get($page->book->getUrl('/export/html')); + $htmlContent->assertSee('my cat is awesome and scratchy'); } - public function test_page_includes_do_not_break_code() + public function test_page_includes_can_be_nested_up_to_three_times() { $page = $this->entities->page(); - $secondPage = $this->entities->page(); - - $content = 'var cat = null;
';
- $secondPage->html = $content;
- $secondPage->save();
-
- $page->html = "{{@{$secondPage->id}#bkmrk-code}}";
+ $tag = "{{@{$page->id}#bkmrk-test}}";
+ $page->html = 'Hello Barry ' . $tag . '
'; $page->save(); $pageResp = $this->asEditor()->get($page->getUrl()); - $pageResp->assertSee($content, false); + $this->withHtml($pageResp)->assertElementContains('#bkmrk-test', 'Hello Barry Hello Barry Hello Barry Hello Barry ' . $tag); + $this->withHtml($pageResp)->assertElementNotContains('#bkmrk-test', 'Hello Barry Hello Barry Hello Barry Hello Barry Hello Barry ' . $tag); } - public function test_page_includes_rendered_on_book_export() + public function test_page_includes_to_nonexisting_pages_does_not_error() { $page = $this->entities->page(); - $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}}"; + $missingId = Page::query()->max('id') + 1; + $tag = "{{@{$missingId}}}"; + $page->html = 'Hello Barry ' . $tag . '
'; $page->save(); - $this->asEditor(); - $htmlContent = $this->get($page->book->getUrl('/export/html')); - $htmlContent->assertSee('my cat is awesome and scratchy'); + $pageResp = $this->asEditor()->get($page->getUrl()); + $pageResp->assertOk(); + $pageResp->assertSee('Hello Barry'); } public function test_page_content_scripts_removed_by_default() @@ -476,6 +469,20 @@ class PageContentTest extends TestCase ], $navMap[2]); } + public function test_get_page_nav_respects_non_breaking_spaces() + { + $content = 'test
test%A
test
test%A