From: Dan Brown Date: Sat, 18 Jan 2020 10:04:13 +0000 (+0000) Subject: Added a few test to cover api docs pages X-Git-Tag: v0.28.0~1^2~14^2~3 X-Git-Url: http://source.bookstackapp.com/bookstack/commitdiff_plain/64455307b13d7eae3d40ab91a75a34ddec3ea686 Added a few test to cover api docs pages --- diff --git a/tests/Api/ApiDocsTest.php b/tests/Api/ApiDocsTest.php new file mode 100644 index 000000000..b240c1672 --- /dev/null +++ b/tests/Api/ApiDocsTest.php @@ -0,0 +1,42 @@ +getViewer(); + $resp = $this->actingAs($viewer)->get($this->endpoint); + $resp->assertStatus(403); + + $resp = $this->actingAsApiEditor()->get($this->endpoint); + $resp->assertStatus(200); + } + + public function test_docs_page_returns_view_with_docs_content() + { + $resp = $this->actingAsApiEditor()->get($this->endpoint); + $resp->assertStatus(200); + $resp->assertSee(url('/api/docs.json')); + $resp->assertSee('Show a JSON view of the API docs data.'); + $resp->assertHeader('Content-Type', 'text/html; charset=UTF-8'); + } + + public function test_docs_json_endpoint_returns_json() + { + $resp = $this->actingAsApiEditor()->get($this->endpoint . '.json'); + $resp->assertStatus(200); + $resp->assertHeader('Content-Type', 'application/json'); + $resp->assertJson([ + 'docs' => [ [ + 'name' => 'docs-display', + 'uri' => 'api/docs' + ] ] + ]); + } +} \ No newline at end of file diff --git a/tests/Api/ApiListingTest.php b/tests/Api/ApiListingTest.php index fa28dfb36..741b9664b 100644 --- a/tests/Api/ApiListingTest.php +++ b/tests/Api/ApiListingTest.php @@ -2,9 +2,7 @@ namespace Tests; -use BookStack\Auth\Permissions\RolePermission; use BookStack\Entities\Book; -use Carbon\Carbon; class ApiListingTest extends TestCase {