]> BookStack Code Mirror - bookstack/blobdiff - tests/Entity/ExportTest.php
MD Exports: Added HTML description conversion
[bookstack] / tests / Entity / ExportTest.php
index 040f69013a5f1bee44b48759f10a13f644410c36..97b1ff1bcfde86883c5bfc99b7dc75cac6d5bf23 100644 (file)
@@ -417,23 +417,35 @@ class ExportTest extends TestCase
     public function test_chapter_markdown_export()
     {
         $chapter = $this->entities->chapter();
+        $chapter->description_html = '<p>My <strong>chapter</strong> description</p>';
+        $chapter->save();
         $page = $chapter->pages()->first();
+
         $resp = $this->asEditor()->get($chapter->getUrl('/export/markdown'));
 
         $resp->assertSee('# ' . $chapter->name);
         $resp->assertSee('# ' . $page->name);
+        $resp->assertSee('My **chapter** description');
     }
 
     public function test_book_markdown_export()
     {
         $book = Book::query()->whereHas('pages')->whereHas('chapters')->first();
+        $book->description_html = '<p>My <strong>book</strong> description</p>';
+        $book->save();
+
         $chapter = $book->chapters()->first();
+        $chapter->description_html = '<p>My <strong>chapter</strong> description</p>';
+        $chapter->save();
+
         $page = $chapter->pages()->first();
         $resp = $this->asEditor()->get($book->getUrl('/export/markdown'));
 
         $resp->assertSee('# ' . $book->name);
         $resp->assertSee('# ' . $chapter->name);
         $resp->assertSee('# ' . $page->name);
+        $resp->assertSee('My **book** description');
+        $resp->assertSee('My **chapter** description');
     }
 
     public function test_book_markdown_export_concats_immediate_pages_with_newlines()
@@ -529,6 +541,22 @@ class ExportTest extends TestCase
         }, PdfExportException::class);
     }
 
+    public function test_pdf_command_timout_option_limits_export_time()
+    {
+        $page = $this->entities->page();
+        $command = 'php -r \'sleep(4);\'';
+        config()->set('exports.pdf_command', $command);
+        config()->set('exports.pdf_command_timeout', 1);
+
+        $this->assertThrows(function () use ($page) {
+            $start = time();
+            $this->withoutExceptionHandling()->asEditor()->get($page->getUrl('/export/pdf'));
+
+            $this->assertTrue(time() < ($start + 3));
+        }, PdfExportException::class,
+            "PDF Export via command failed due to timeout at 1 second(s)");
+    }
+
     public function test_html_exports_contain_csp_meta_tag()
     {
         $entities = [