public function test_page_text_export()
{
- $page = Page::first();
+ $page = Page::query()->first();
$this->asEditor();
$resp = $this->get($page->getUrl('/export/plaintext'));
public function test_page_pdf_export()
{
- $page = Page::first();
+ $page = Page::query()->first();
$this->asEditor();
$resp = $this->get($page->getUrl('/export/pdf'));
public function test_page_html_export()
{
- $page = Page::first();
+ $page = Page::query()->first();
$this->asEditor();
$resp = $this->get($page->getUrl('/export/html'));
public function test_book_text_export()
{
- $page = Page::first();
+ $page = Page::query()->first();
$book = $page->book;
$this->asEditor();
public function test_book_pdf_export()
{
- $page = Page::first();
+ $page = Page::query()->first();
$book = $page->book;
$this->asEditor();
public function test_book_html_export()
{
- $page = Page::first();
+ $page = Page::query()->first();
$book = $page->book;
$this->asEditor();
public function test_chapter_text_export()
{
- $chapter = Chapter::first();
+ $chapter = Chapter::query()->first();
$page = $chapter->pages[0];
$this->asEditor();
public function test_chapter_pdf_export()
{
- $chapter = Chapter::first();
+ $chapter = Chapter::query()->first();
$this->asEditor();
$resp = $this->get($chapter->getUrl('/export/pdf'));
public function test_chapter_html_export()
{
- $chapter = Chapter::first();
+ $chapter = Chapter::query()->first();
$page = $chapter->pages[0];
$this->asEditor();
public function test_page_html_export_contains_custom_head_if_set()
{
- $page = Page::first();
+ $page = Page::query()->first();
$customHeadContent = "<style>p{color: red;}</style>";
$this->setSettings(['app-custom-head' => $customHeadContent]);
$resp->assertSee($customHeadContent);
}
+ public function test_page_html_export_does_not_break_with_only_comments_in_custom_head()
+ {
+ $page = Page::query()->first();
+
+ $customHeadContent = "<!-- A comment -->";
+ $this->setSettings(['app-custom-head' => $customHeadContent]);
+
+ $resp = $this->asEditor()->get($page->getUrl('/export/html'));
+ $resp->assertStatus(200);
+ $resp->assertSee($customHeadContent);
+ }
+
public function test_page_html_export_use_absolute_dates()
{
- $page = Page::first();
+ $page = Page::query()->first();
$resp = $this->asEditor()->get($page->getUrl('/export/html'));
$resp->assertSee($page->created_at->formatLocalized('%e %B %Y %H:%M:%S'));
public function test_page_export_does_not_include_user_or_revision_links()
{
- $page = Page::first();
+ $page = Page::query()->first();
$resp = $this->asEditor()->get($page->getUrl('/export/html'));
$resp->assertDontSee($page->getUrl('/revisions'));
public function test_page_export_sets_right_data_type_for_svg_embeds()
{
- $page = Page::first();
+ $page = Page::query()->first();
Storage::disk('local')->makeDirectory('uploads/images/gallery');
Storage::disk('local')->put('uploads/images/gallery/svg_test.svg', '<svg></svg>');
$page->html = '<img src="http://localhost/uploads/images/gallery/svg_test.svg">';
public function test_page_image_containment_works_on_multiple_images_within_a_single_line()
{
- $page = Page::first();
+ $page = Page::query()->first();
Storage::disk('local')->makeDirectory('uploads/images/gallery');
Storage::disk('local')->put('uploads/images/gallery/svg_test.svg', '<svg></svg>');
Storage::disk('local')->put('uploads/images/gallery/svg_test2.svg', '<svg></svg>');
public function test_page_export_contained_html_image_fetches_only_run_when_url_points_to_image_upload_folder()
{
- $page = Page::first();
+ $page = Page::query()->first();
$page->html = '<img src="http://localhost/uploads/images/gallery/svg_test.svg"/>'
.'<img src="http://localhost/uploads/svg_test.svg"/>'
.'<img src="/uploads/svg_test.svg"/>';
public function test_page_export_with_deleted_creator_and_updater()
{
$user = $this->getViewer(['name' => 'ExportWizardTheFifth']);
- $page = Page::first();
+ $page = Page::query()->first();
$page->created_by = $user->id;
$page->updated_by = $user->id;
$page->save();
public function test_page_includes()
{
- $page = Page::first();
- $secondPage = Page::where('id', '!=', $page->id)->first();
+ $page = Page::query()->first();
+ $secondPage = Page::query()->where('id', '!=', $page->id)->first();
$secondPage->html = "<p id='section1'>Hello, This is a test</p><p id='section2'>This is a second block of content</p>";
$secondPage->save();
public function test_saving_page_with_includes()
{
- $page = Page::first();
- $secondPage = Page::where('id', '!=', $page->id)->first();
+ $page = Page::query()->first();
+ $secondPage = Page::query()->where('id', '!=', $page->id)->first();
$this->asEditor();
$includeTag = '{{@' . $secondPage->id . '}}';
public function test_page_includes_do_not_break_tables()
{
- $page = Page::first();
- $secondPage = Page::where('id', '!=', $page->id)->first();
+ $page = Page::query()->first();
+ $secondPage = Page::query()->where('id', '!=', $page->id)->first();
$content = '<table id="table"><tbody><tr><td>test</td></tr></tbody></table>';
$secondPage->html = $content;
public function test_page_content_scripts_removed_by_default()
{
$this->asEditor();
- $page = Page::first();
+ $page = Page::query()->first();
$script = 'abc123<script>console.log("hello-test")</script>abc123';
$page->html = "escape {$script}";
$page->save();
];
$this->asEditor();
- $page = Page::first();
+ $page = Page::query()->first();
foreach ($checks as $check) {
$page->html = $check;
];
$this->asEditor();
- $page = Page::first();
+ $page = Page::query()->first();
foreach ($checks as $check) {
$page->html = $check;
];
$this->asEditor();
- $page = Page::first();
+ $page = Page::query()->first();
foreach ($checks as $check) {
$page->html = $check;
];
$this->asEditor();
- $page = Page::first();
+ $page = Page::query()->first();
foreach ($checks as $check) {
$page->html = $check;
];
$this->asEditor();
- $page = Page::first();
+ $page = Page::query()->first();
foreach ($checks as $check) {
$page->html = $check;
public function test_page_inline_on_attributes_removed_by_default()
{
$this->asEditor();
- $page = Page::first();
+ $page = Page::query()->first();
$script = '<p onmouseenter="console.log(\'test\')">Hello</p>';
$page->html = "escape {$script}";
$page->save();
];
$this->asEditor();
- $page = Page::first();
+ $page = Page::query()->first();
foreach ($checks as $check) {
$page->html = $check;
public function test_page_content_scripts_show_when_configured()
{
$this->asEditor();
- $page = Page::first();
+ $page = Page::query()->first();
config()->push('app.allow_content_scripts', 'true');
$script = 'abc123<script>console.log("hello-test")</script>abc123';
public function test_page_inline_on_attributes_show_if_configured()
{
$this->asEditor();
- $page = Page::first();
+ $page = Page::query()->first();
config()->push('app.allow_content_scripts', 'true');
$script = '<p onmouseenter="console.log(\'test\')">Hello</p>';
public function test_duplicate_ids_does_not_break_page_render()
{
$this->asEditor();
- $pageA = Page::first();
+ $pageA = Page::query()->first();
$pageB = Page::query()->where('id', '!=', $pageA->id)->first();
$content = '<ul id="bkmrk-xxx-%28"></ul> <ul id="bkmrk-xxx-%28"></ul>';
public function test_duplicate_ids_fixed_on_page_save()
{
$this->asEditor();
- $page = Page::first();
+ $page = Page::query()->first();
$content = '<ul id="bkmrk-test"><li>test a</li><li><ul id="bkmrk-test"><li>test b</li></ul></li></ul>';
$pageSave = $this->put($page->getUrl(), [
]);
$pageSave->assertRedirect();
- $updatedPage = Page::where('id', '=', $page->id)->first();
+ $updatedPage = Page::query()->where('id', '=', $page->id)->first();
$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();
+ $page = Page::query()->first();
$content = '<h1 id="non-standard-id">test</h1><p><a href="#non-standard-id">link</a></p>';
$this->put($page->getUrl(), [
'summary' => ''
]);
- $updatedPage = Page::where('id', '=', $page->id)->first();
+ $updatedPage = Page::query()->where('id', '=', $page->id)->first();
$this->assertStringContainsString('id="bkmrk-test"', $updatedPage->html);
$this->assertStringContainsString('href="#bkmrk-test"', $updatedPage->html);
}
$pageView->assertElementExists('.page-content p > s');
}
+ public function test_page_markdown_single_html_comment_saving()
+ {
+ $this->asEditor();
+ $page = Page::query()->first();
+
+ $content = '<!-- Test Comment -->';
+ $this->put($page->getUrl(), [
+ 'name' => $page->name, 'markdown' => $content,
+ 'html' => '', 'summary' => ''
+ ]);
+
+ $page->refresh();
+ $this->assertStringMatchesFormat($content, $page->html);
+
+ $pageView = $this->get($page->getUrl());
+ $pageView->assertStatus(200);
+ $pageView->assertSee($content);
+ }
+
public function test_base64_images_get_extracted_from_page_content()
{
$this->asEditor();