X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/d0de4fd8f9076119e5c06b5ba3887f16ff4b6b64..refs/pull/4985/head:/tests/Actions/WebhookManagementTest.php diff --git a/tests/Actions/WebhookManagementTest.php b/tests/Actions/WebhookManagementTest.php index 6eb328714..05475b699 100644 --- a/tests/Actions/WebhookManagementTest.php +++ b/tests/Actions/WebhookManagementTest.php @@ -2,8 +2,8 @@ namespace Tests\Actions; -use BookStack\Actions\ActivityType; -use BookStack\Actions\Webhook; +use BookStack\Activity\ActivityType; +use BookStack\Activity\Models\Webhook; use Tests\TestCase; class WebhookManagementTest extends TestCase @@ -17,8 +17,8 @@ class WebhookManagementTest extends TestCase $resp = $this->asAdmin()->get('/settings/webhooks'); $resp->assertOk(); - $resp->assertElementContains('a[href$="/settings/webhooks/create"]', 'Create New Webhook'); - $resp->assertElementExists('a[href="' . $webhook->getUrl() . '"]', $webhook->name); + $this->withHtml($resp)->assertElementContains('a[href$="/settings/webhooks/create"]', 'Create New Webhook'); + $this->withHtml($resp)->assertElementContains('a[href="' . $webhook->getUrl() . '"]', $webhook->name); $resp->assertSee($webhook->endpoint); $resp->assertSee('All system events'); $resp->assertSee('Active'); @@ -29,7 +29,7 @@ class WebhookManagementTest extends TestCase $resp = $this->asAdmin()->get('/settings/webhooks/create'); $resp->assertOk(); $resp->assertSee('Create New Webhook'); - $resp->assertElementContains('form[action$="/settings/webhooks/create"] button', 'Save Webhook'); + $this->withHtml($resp)->assertElementContains('form[action$="/settings/webhooks/create"] button', 'Save Webhook'); } public function test_store() @@ -70,9 +70,9 @@ class WebhookManagementTest extends TestCase $resp = $this->asAdmin()->get('/settings/webhooks/' . $webhook->id); $resp->assertOk(); $resp->assertSee('Edit Webhook'); - $resp->assertElementContains('form[action="' . $webhook->getUrl() . '"] button', 'Save Webhook'); - $resp->assertElementContains('a[href="' . $webhook->getUrl('/delete') . '"]', 'Delete Webhook'); - $resp->assertElementExists('input[type="checkbox"][value="all"][name="events[]"]'); + $this->withHtml($resp)->assertElementContains('form[action="' . $webhook->getUrl() . '"] button', 'Save Webhook'); + $this->withHtml($resp)->assertElementContains('a[href="' . $webhook->getUrl('/delete') . '"]', 'Delete Webhook'); + $this->withHtml($resp)->assertElementExists('input[type="checkbox"][value="all"][name="events[]"]'); } public function test_update() @@ -84,7 +84,7 @@ class WebhookManagementTest extends TestCase 'endpoint' => 'https://example.com/updated-webhook', 'events' => [ActivityType::PAGE_CREATE, ActivityType::PAGE_UPDATE], 'active' => 'true', - 'timeout' => 5 + 'timeout' => 5, ]); $resp->assertRedirect('/settings/webhooks'); @@ -114,7 +114,7 @@ class WebhookManagementTest extends TestCase $resp->assertOk(); $resp->assertSee('Delete Webhook'); $resp->assertSee('This will fully delete this webhook, with the name \'Webhook to delete\', from the system.'); - $resp->assertElementContains('form[action$="/settings/webhooks/' . $webhook->id . '"]', 'Delete'); + $this->withHtml($resp)->assertElementContains('form[action$="/settings/webhooks/' . $webhook->id . '"]', 'Delete'); } public function test_destroy() @@ -135,7 +135,7 @@ class WebhookManagementTest extends TestCase public function test_settings_manage_permission_required_for_webhook_routes() { - $editor = $this->getEditor(); + $editor = $this->users->editor(); $this->actingAs($editor); $routes = [ @@ -153,7 +153,7 @@ class WebhookManagementTest extends TestCase $this->assertPermissionError($resp); } - $this->giveUserPermissions($editor, ['settings-manage']); + $this->permissions->grantUserRolePermissions($editor, ['settings-manage']); foreach ($routes as [$method, $endpoint]) { $resp = $this->call($method, $endpoint);