mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-30 04:23:11 +03:00
Added markdown export endpoints to API
- Added tests to cover. - Added slight extra spaces at content joins.
This commit is contained in:
@ -140,4 +140,17 @@ class BooksApiTest extends TestCase
|
||||
$resp->assertStatus(200);
|
||||
$resp->assertHeader('Content-Disposition', 'attachment; filename="' . $book->slug . '.pdf"');
|
||||
}
|
||||
|
||||
public function test_export_markdown_endpoint()
|
||||
{
|
||||
$this->actingAsApiEditor();
|
||||
$book = Book::visible()->has('pages')->has('chapters')->first();
|
||||
|
||||
$resp = $this->get($this->baseEndpoint . "/{$book->id}/export/markdown");
|
||||
$resp->assertStatus(200);
|
||||
$resp->assertHeader('Content-Disposition', 'attachment; filename="' . $book->slug . '.md"');
|
||||
$resp->assertSee('# ' . $book->name);
|
||||
$resp->assertSee('# ' . $book->pages()->first()->name);
|
||||
$resp->assertSee('# ' . $book->chapters()->first()->name);
|
||||
}
|
||||
}
|
@ -186,4 +186,16 @@ class ChaptersApiTest extends TestCase
|
||||
$resp->assertStatus(200);
|
||||
$resp->assertHeader('Content-Disposition', 'attachment; filename="' . $chapter->slug . '.pdf"');
|
||||
}
|
||||
|
||||
public function test_export_markdown_endpoint()
|
||||
{
|
||||
$this->actingAsApiEditor();
|
||||
$chapter = Chapter::visible()->has('pages')->first();
|
||||
|
||||
$resp = $this->get($this->baseEndpoint . "/{$chapter->id}/export/markdown");
|
||||
$resp->assertStatus(200);
|
||||
$resp->assertHeader('Content-Disposition', 'attachment; filename="' . $chapter->slug . '.md"');
|
||||
$resp->assertSee('# ' . $chapter->name);
|
||||
$resp->assertSee('# ' . $chapter->pages()->first()->name);
|
||||
}
|
||||
}
|
@ -258,4 +258,15 @@ class PagesApiTest extends TestCase
|
||||
$resp->assertStatus(200);
|
||||
$resp->assertHeader('Content-Disposition', 'attachment; filename="' . $page->slug . '.pdf"');
|
||||
}
|
||||
|
||||
public function test_export_markdown_endpoint()
|
||||
{
|
||||
$this->actingAsApiEditor();
|
||||
$page = Page::visible()->first();
|
||||
|
||||
$resp = $this->get($this->baseEndpoint . "/{$page->id}/export/markdown");
|
||||
$resp->assertStatus(200);
|
||||
$resp->assertSee('# ' . $page->name);
|
||||
$resp->assertHeader('Content-Disposition', 'attachment; filename="' . $page->slug . '.md"');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user