mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-28 17:02:04 +03:00
Added conversion of iframes to anchors on PDF export
- Replaced iframe elements with anchor elements wrapped in a paragraph. - Extracted PDF generation action to seperate class for easier mocking within testing. - Added test to cover. For #3077
This commit is contained in:
@ -6,6 +6,7 @@ use BookStack\Auth\Role;
|
||||
use BookStack\Entities\Models\Book;
|
||||
use BookStack\Entities\Models\Chapter;
|
||||
use BookStack\Entities\Models\Page;
|
||||
use BookStack\Entities\Tools\PdfGenerator;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Tests\TestCase;
|
||||
@ -289,6 +290,24 @@ class ExportTest extends TestCase
|
||||
$resp->assertDontSee('ExportWizardTheFifth');
|
||||
}
|
||||
|
||||
public function test_page_pdf_export_converts_iframes_to_links()
|
||||
{
|
||||
$page = Page::query()->first()->forceFill([
|
||||
'html' => '<iframe width="560" height="315" src="//www.youtube.com/embed/ShqUjt33uOs"></iframe>',
|
||||
]);
|
||||
$page->save();
|
||||
|
||||
$pdfHtml = '';
|
||||
$mockPdfGenerator = $this->mock(PdfGenerator::class);
|
||||
$mockPdfGenerator->shouldReceive('fromHtml')
|
||||
->with(\Mockery::capture($pdfHtml))
|
||||
->andReturn('');
|
||||
|
||||
$this->asEditor()->get($page->getUrl('/export/pdf'));
|
||||
$this->assertStringNotContainsString('iframe>', $pdfHtml);
|
||||
$this->assertStringContainsString('<p><a href="https://www.youtube.com/embed/ShqUjt33uOs">https://www.youtube.com/embed/ShqUjt33uOs</a></p>', $pdfHtml);
|
||||
}
|
||||
|
||||
public function test_page_markdown_export()
|
||||
{
|
||||
$page = Page::query()->first();
|
||||
|
Reference in New Issue
Block a user