X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/2ebbc6b658e80c1a291de9d699627c82ed07577f..refs/pull/2238/head:/tests/Entity/PageTemplateTest.php diff --git a/tests/Entity/PageTemplateTest.php b/tests/Entity/PageTemplateTest.php index 17450f494..8eba13557 100644 --- a/tests/Entity/PageTemplateTest.php +++ b/tests/Entity/PageTemplateTest.php @@ -1,4 +1,4 @@ -my_custom_template_content'; + $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()->orderBy('name', 'asc')->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'); + } + } \ No newline at end of file