1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-30 04:23:11 +03:00

Added ability to use templates

- Added replace, append and prepend actions for template content into
both the WYSIWYG editor and markdown editor.
- Added further testing to cover.
This commit is contained in:
Dan Brown
2019-08-11 20:04:43 +01:00
parent 2ebbc6b658
commit de3e9ab094
17 changed files with 368 additions and 16 deletions

View File

@ -47,4 +47,44 @@ class PageTemplateTest extends TestCase
]);
}
public function test_templates_content_should_be_fetchable_only_if_page_marked_as_template()
{
$content = '<div>my_custom_template_content</div>';
$page = Page::first();
$editor = $this->getEditor();
$this->actingAs($editor);
$templateFetch = $this->get('/templates/' . $page->id);
$templateFetch->assertStatus(404);
$page->html = $content;
$page->template = true;
$page->save();
$templateFetch = $this->get('/templates/' . $page->id);
$templateFetch->assertStatus(200);
$templateFetch->assertJson([
'html' => $content,
'markdown' => '',
]);
}
public function test_template_endpoint_returns_paginated_list_of_templates()
{
$editor = $this->getEditor();
$this->actingAs($editor);
$toBeTemplates = Page::query()->take(12)->get();
$page = $toBeTemplates->first();
$emptyTemplatesFetch = $this->get('/templates');
$emptyTemplatesFetch->assertDontSee($page->name);
Page::query()->whereIn('id', $toBeTemplates->pluck('id')->toArray())->update(['template' => true]);
$templatesFetch = $this->get('/templates');
$templatesFetch->assertSee($page->name);
$templatesFetch->assertSee('pagination');
}
}