Generation
- Generate node now produces the full post (text + AI image + carousel)
via a shared PostImagePipeline extracted from StreamPostCreation
- Generate config UI mirrors the /posts/create wizard (carousel slide
count, include-image toggle); drop the decorative format/unsplash keys
Flow correctness
- RSS/HTTP nodes expose named has-items (default) and no-items output
handles, labeled and colored like the Condition node
- AdvanceAutomationRun records a no_matching_edge terminal instead of
completing silently; "0 new items" feedback in the test panel
- Manual/test runs no longer persist the production dedup watermark
Run reliability
- Pause truly halts in-flight runs (production only; manual test runs
always run regardless of automation status)
- ProcessAutomationNode::failed() marks the run failed
- automation:recover-stuck-runs and automation:prune-dry-runs commands
Webhook / HTTP
- Branded User-Agent (config-driven) on outbound webhook + http_request
- Webhook fails on invalid JSON instead of silently sending {}
- HTTP custom headers editor; CodeMirror-based CodeEditor for JSON
Editor UX
- Header Test button only opens the panel; the panel has a Run button
(saves first) and owns the with-real-data toggle
- Clicking a node closes the test panel and opens its config
- Node cards: max-width + truncate so long URLs don't grow the node
90 lines
2.9 KiB
PHP
90 lines
2.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Actions\Automation\Node\RunWebhookNode;
|
|
use App\Enums\Automation\NodeRun\Status;
|
|
use App\Models\AutomationRun;
|
|
use Illuminate\Support\Facades\Http;
|
|
|
|
it('posts interpolated payload to the configured url', function () {
|
|
Http::fake([
|
|
'hooks.example.com/*' => Http::response(['ok' => true], 200),
|
|
]);
|
|
|
|
$run = AutomationRun::factory()->create([
|
|
'context' => ['trigger' => ['title' => 'Hello'], 'generated' => ['post_url' => 'https://t.it/p/1']],
|
|
]);
|
|
|
|
$result = app(RunWebhookNode::class)($run, [
|
|
'url' => 'https://hooks.example.com/test',
|
|
'method' => 'POST',
|
|
'headers' => ['X-Source' => 'TryPost'],
|
|
'payload_template' => '{"title":"{{ trigger.title }}","post_url":"{{ generated.post_url }}"}',
|
|
]);
|
|
|
|
expect($result->status)->toBe(Status::Completed);
|
|
Http::assertSent(fn ($request) => $request['title'] === 'Hello' && $request['post_url'] === 'https://t.it/p/1');
|
|
});
|
|
|
|
it('sends the branded user-agent header', function () {
|
|
Http::fake([
|
|
'hooks.example.com/*' => Http::response(['ok' => true], 200),
|
|
]);
|
|
|
|
$run = AutomationRun::factory()->create();
|
|
|
|
app(RunWebhookNode::class)($run, [
|
|
'url' => 'https://hooks.example.com/test',
|
|
'method' => 'POST',
|
|
'headers' => ['User-Agent' => 'user-supplied-agent'],
|
|
'payload_template' => '{}',
|
|
]);
|
|
|
|
Http::assertSent(fn ($request) => $request->hasHeader('User-Agent', config('trypost.user_agent')));
|
|
});
|
|
|
|
it('fails on 5xx response', function () {
|
|
Http::fake(['hooks.example.com/*' => Http::response('err', 500)]);
|
|
|
|
$run = AutomationRun::factory()->create();
|
|
|
|
$result = app(RunWebhookNode::class)($run, [
|
|
'url' => 'https://hooks.example.com/test',
|
|
'method' => 'POST',
|
|
'payload_template' => '{}',
|
|
]);
|
|
|
|
expect($result->status)->toBe(Status::Failed);
|
|
});
|
|
|
|
it('fails on malformed payload json instead of silently sending an empty body', function () {
|
|
Http::fake(['hooks.example.com/*' => Http::response(['ok' => true], 200)]);
|
|
|
|
$run = AutomationRun::factory()->create();
|
|
|
|
$result = app(RunWebhookNode::class)($run, [
|
|
'url' => 'https://hooks.example.com/test',
|
|
'method' => 'POST',
|
|
'payload_template' => '{ "a": }',
|
|
]);
|
|
|
|
expect($result->status)->toBe(Status::Failed);
|
|
expect($result->error['reason'])->toBe('invalid_payload_json');
|
|
Http::assertNothingSent();
|
|
});
|
|
|
|
it('treats 4xx responses as completed (only 5xx fails)', function () {
|
|
Http::fake(['hooks.example.com/*' => Http::response('not found', 404)]);
|
|
|
|
$run = AutomationRun::factory()->create();
|
|
|
|
$result = app(RunWebhookNode::class)($run, [
|
|
'url' => 'https://hooks.example.com/test',
|
|
'method' => 'POST',
|
|
'payload_template' => '{}',
|
|
]);
|
|
|
|
expect($result->status->value)->toBe('completed');
|
|
expect($result->output['webhook']['status'])->toBe(404);
|
|
});
|