zapier improvements (#532)
* zapier improvements * Fix test case --------- Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
parent
7ac8503201
commit
943e906c86
|
|
@ -18,15 +18,13 @@ class PollSubmissionRequest extends FormRequest
|
|||
return [
|
||||
'form_id' => [
|
||||
'required',
|
||||
Rule::exists(Form::getModel()->getTable(), 'slug'),
|
||||
Rule::exists(Form::getModel()->getTable(), 'id'),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function form(): Form
|
||||
{
|
||||
return Form::query()
|
||||
->where('slug', $this->input('form_id'))
|
||||
->firstOrFail();
|
||||
return Form::findOrFail($this->input('form_id'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class CreateIntegrationRequest extends FormRequest
|
|||
return [
|
||||
'form_id' => [
|
||||
'required',
|
||||
Rule::exists(Form::getModel()->getTable(), 'slug'),
|
||||
Rule::exists(Form::getModel()->getTable(), 'id'),
|
||||
],
|
||||
'hookUrl' => [
|
||||
'required',
|
||||
|
|
@ -24,8 +24,6 @@ class CreateIntegrationRequest extends FormRequest
|
|||
|
||||
public function form(): Form
|
||||
{
|
||||
return Form::query()
|
||||
->where('slug', $this->input('form_id'))
|
||||
->firstOrFail();
|
||||
return Form::findOrFail($this->input('form_id'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class DeleteIntegrationRequest extends FormRequest
|
|||
return [
|
||||
'form_id' => [
|
||||
'required',
|
||||
Rule::exists(Form::getModel()->getTable(), 'slug'),
|
||||
Rule::exists(Form::getModel()->getTable(), 'id'),
|
||||
],
|
||||
'hookUrl' => [
|
||||
'required',
|
||||
|
|
@ -24,8 +24,6 @@ class DeleteIntegrationRequest extends FormRequest
|
|||
|
||||
public function form(): Form
|
||||
{
|
||||
return Form::query()
|
||||
->where('slug', $this->input('form_id'))
|
||||
->firstOrFail();
|
||||
return Form::findOrFail($this->input('form_id'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,8 +12,9 @@ class FormResource extends JsonResource
|
|||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->resource->slug,
|
||||
'id' => $this->resource->id,
|
||||
'name' => $this->resource->title,
|
||||
'label' => $this->resource->title . ' (' . $this->resource->slug . ')'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ module.exports = {
|
|||
key: 'form_id',
|
||||
type: 'string',
|
||||
label: 'Form',
|
||||
dynamic: 'list_forms.id.name',
|
||||
dynamic: 'list_forms.id.label',
|
||||
required: true,
|
||||
list: false,
|
||||
altersDynamicFields: false,
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ test('create an integration', function () {
|
|||
|
||||
$this->withoutExceptionHandling();
|
||||
post(route('zapier.webhooks.store'), [
|
||||
'form_id' => $form->slug,
|
||||
'form_id' => $form->id,
|
||||
'hookUrl' => $hookUrl = 'https://zapier.com/hook/test'
|
||||
])
|
||||
->assertOk();
|
||||
|
|
@ -45,7 +45,7 @@ test('cannot create an integration without a corresponding ability', function ()
|
|||
Sanctum::actingAs($user);
|
||||
|
||||
post(route('zapier.webhooks.store'), [
|
||||
'form_id' => $form->slug,
|
||||
'form_id' => $form->id,
|
||||
'hookUrl' => 'https://zapier.com/hook/test'
|
||||
])
|
||||
->assertForbidden();
|
||||
|
|
@ -64,7 +64,7 @@ test('cannot create an integration for other users form', function () {
|
|||
Sanctum::actingAs($user);
|
||||
|
||||
post(route('zapier.webhooks.store'), [
|
||||
'form_id' => $form->slug,
|
||||
'form_id' => $form->id,
|
||||
'hookUrl' => 'https://zapier.com/hook/test'
|
||||
])
|
||||
->assertForbidden();
|
||||
|
|
@ -94,7 +94,7 @@ test('delete an integration', function () {
|
|||
assertDatabaseCount('form_integrations', 1);
|
||||
|
||||
delete(route('zapier.webhooks.destroy', $integration), [
|
||||
'form_id' => $form->slug,
|
||||
'form_id' => $form->id,
|
||||
'hookUrl' => $hookUrl,
|
||||
])
|
||||
->assertOk();
|
||||
|
|
@ -122,7 +122,7 @@ test('cannot delete an integration with an incorrect hook url', function () {
|
|||
]);
|
||||
|
||||
delete(route('zapier.webhooks.destroy', $integration), [
|
||||
'form_id' => $form->slug,
|
||||
'form_id' => $form->id,
|
||||
'hookUrl' => 'https://google.com',
|
||||
])
|
||||
->assertOk();
|
||||
|
|
@ -178,7 +178,7 @@ test('poll for the latest submission', function () {
|
|||
Sanctum::actingAs($user, ['view', 'manage-integrations']);
|
||||
|
||||
// Call the poll endpoint
|
||||
$response = $this->getJson(route('zapier.webhooks.poll', ['form_id' => $form->slug]));
|
||||
$response = $this->getJson(route('zapier.webhooks.poll', ['form_id' => $form->id]));
|
||||
|
||||
// Assert the response status is OK
|
||||
$response->assertOk();
|
||||
|
|
@ -229,7 +229,7 @@ test('make up a submission when polling without any submission', function () {
|
|||
|
||||
// Call the poll endpoint
|
||||
$this->withoutExceptionHandling();
|
||||
$response = $this->getJson(route('zapier.webhooks.poll', ['form_id' => $form->slug]));
|
||||
$response = $this->getJson(route('zapier.webhooks.poll', ['form_id' => $form->id]));
|
||||
// Assert the response status is OK
|
||||
$response->assertOk();
|
||||
|
||||
|
|
|
|||
|
|
@ -22,11 +22,11 @@ test('list all forms of a given workspace', function () {
|
|||
->assertJsonCount(2)
|
||||
->assertJson([
|
||||
[
|
||||
'id' => $form1->slug,
|
||||
'id' => $form1->id,
|
||||
'name' => $form1->title,
|
||||
],
|
||||
[
|
||||
'id' => $form2->slug,
|
||||
'id' => $form2->id,
|
||||
'name' => $form2->title,
|
||||
],
|
||||
]);
|
||||
|
|
|
|||
Loading…
Reference in New Issue