+
+ public function test_anchors_referencing_non_bkmrk_ids_rewritten_after_save()
+ {
+ $this->asEditor();
+ $page = Page::first();
+
+ $content = '<h1 id="non-standard-id">test</h1><p><a href="#non-standard-id">link</a></p>';
+ $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 = '<h1 id="testa">Hello</h1><h2 id="testb">There</h2><h3 id="testc">Donkey</h3>';
+ $pageContent = new PageContent(new Page(['html' => $content]));
+ $navMap = $pageContent->getNavigation($content);
+
+ $this->assertCount(3, $navMap);
+ $this->assertArrayMapIncludes([
+ 'nodeName' => 'h1',
+ 'link' => '#testa',
+ 'text' => 'Hello',
+ 'level' => 1,
+ ], $navMap[0]);
+ $this->assertArrayMapIncludes([
+ 'nodeName' => 'h2',
+ 'link' => '#testb',
+ 'text' => 'There',
+ 'level' => 2,
+ ], $navMap[1]);
+ $this->assertArrayMapIncludes([
+ 'nodeName' => 'h3',
+ 'link' => '#testc',
+ 'text' => 'Donkey',
+ 'level' => 3,
+ ], $navMap[2]);
+ }
+
+ public function test_get_page_nav_does_not_show_empty_titles()
+ {
+ $content = '<h1 id="testa">Hello</h1><h2 id="testb"> </h2><h3 id="testc"></h3>';
+ $pageContent = new PageContent(new Page(['html' => $content]));
+ $navMap = $pageContent->getNavigation($content);
+
+ $this->assertCount(1, $navMap);
+ $this->assertArrayMapIncludes([
+ 'nodeName' => 'h1',
+ 'link' => '#testa',
+ 'text' => 'Hello'
+ ], $navMap[0]);
+ }
+
+ public function test_get_page_nav_shifts_headers_if_only_smaller_ones_are_used()
+ {
+ $content = '<h4 id="testa">Hello</h4><h5 id="testb">There</h5><h6 id="testc">Donkey</h6>';
+ $pageContent = new PageContent(new Page(['html' => $content]));
+ $navMap = $pageContent->getNavigation($content);
+
+ $this->assertCount(3, $navMap);
+ $this->assertArrayMapIncludes([
+ 'nodeName' => 'h4',
+ 'level' => 1,
+ ], $navMap[0]);
+ $this->assertArrayMapIncludes([
+ 'nodeName' => 'h5',
+ 'level' => 2,
+ ], $navMap[1]);
+ $this->assertArrayMapIncludes([
+ 'nodeName' => 'h6',
+ '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' => '<p>"Hello & welcome"</p>',
+ ]);
+
+ $page->refresh();
+ $this->assertEquals('"Hello & welcome"', $page->text);
+ }
+
+ public function test_page_markdown_table_rendering()
+ {
+ $this->asEditor();
+ $page = Page::query()->first();
+
+ $content = '| Syntax | Description |
+| ----------- | ----------- |
+| Header | Title |
+| Paragraph | Text |';
+ $this->put($page->getUrl(), [
+ 'name' => $page->name, 'markdown' => $content,
+ 'html' => '', 'summary' => ''
+ ]);
+
+ $page->refresh();
+ $this->assertStringContainsString('</tbody>', $page->html);
+
+ $pageView = $this->get($page->getUrl());
+ $pageView->assertElementExists('.page-content table tbody td');
+ }
+
+ public function test_page_markdown_task_list_rendering()
+ {
+ $this->asEditor();
+ $page = Page::query()->first();
+
+ $content = '- [ ] Item a
+- [x] Item b';
+ $this->put($page->getUrl(), [
+ 'name' => $page->name, 'markdown' => $content,
+ 'html' => '', 'summary' => ''
+ ]);
+
+ $page->refresh();
+ $this->assertStringContainsString('input', $page->html);
+ $this->assertStringContainsString('type="checkbox"', $page->html);
+
+ $pageView = $this->get($page->getUrl());
+ $pageView->assertElementExists('.page-content input[type=checkbox]');
+ }
+
+ public function test_page_markdown_strikethrough_rendering()
+ {
+ $this->asEditor();
+ $page = Page::query()->first();
+
+ $content = '~~some crossed out text~~';
+ $this->put($page->getUrl(), [
+ 'name' => $page->name, 'markdown' => $content,
+ 'html' => '', 'summary' => ''
+ ]);
+
+ $page->refresh();
+ $this->assertStringMatchesFormat('%A<s%A>some crossed out text</s>%A', $page->html);
+
+ $pageView = $this->get($page->getUrl());
+ $pageView->assertElementExists('.page-content p > s');
+ }