1
0
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:
Dan Brown
2021-06-22 21:32:55 +01:00
parent 57ea2e92ec
commit 992f03a3c0
9 changed files with 85 additions and 3 deletions

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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"');
}
}