mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-13 15:07:49 +00:00
feat(#46): added support for request body in recipes
This commit is contained in:
parent
3673654df6
commit
e326ded933
7 changed files with 130 additions and 19 deletions
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
use App\Models\Plugin;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
uses(Illuminate\Foundation\Testing\RefreshDatabase::class);
|
||||
|
||||
|
|
@ -40,3 +41,33 @@ test('plugin data_payload is cast to array', function () {
|
|||
->toBeArray()
|
||||
->toBe($data);
|
||||
});
|
||||
|
||||
test('plugin can have polling body for POST requests', function () {
|
||||
$plugin = Plugin::factory()->create([
|
||||
'polling_verb' => 'post',
|
||||
'polling_body' => '{"query": "query { user { id name } }"}',
|
||||
]);
|
||||
|
||||
expect($plugin->polling_body)->toBe('{"query": "query { user { id name } }"}');
|
||||
});
|
||||
|
||||
test('updateDataPayload sends POST request with body when polling_verb is post', function () {
|
||||
Http::fake([
|
||||
'https://example.com/api' => Http::response(['success' => true], 200),
|
||||
]);
|
||||
|
||||
$plugin = Plugin::factory()->create([
|
||||
'data_strategy' => 'polling',
|
||||
'polling_url' => 'https://example.com/api',
|
||||
'polling_verb' => 'post',
|
||||
'polling_body' => '{"query": "query { user { id name } }"}',
|
||||
]);
|
||||
|
||||
$plugin->updateDataPayload();
|
||||
|
||||
Http::assertSent(function ($request) {
|
||||
return $request->url() === 'https://example.com/api' &&
|
||||
$request->method() === 'POST' &&
|
||||
$request->body() === '{"query": "query { user { id name } }"}';
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue