- Added new automation-related routes and controllers for managing automations. - Introduced automation nodes in the UI with distinct styles and interactions. - Updated sidebar to include navigation for automations. - Enhanced post creation logic to support automation metadata. - Refactored content type and platform enums into types for better type safety. - Added localization for automation-related terms in English, Spanish, and Portuguese. - Improved error handling in various components to accommodate new features.
39 lines
1.2 KiB
PHP
39 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Actions\Automation\Run\RetryRunFromNode;
|
|
use App\Enums\Automation\Run\Status;
|
|
use App\Jobs\Automation\ProcessAutomationNode;
|
|
use App\Models\Automation;
|
|
use App\Models\AutomationRun;
|
|
use Illuminate\Support\Facades\Queue;
|
|
|
|
it('resets a failed run to pending and dispatches the next node', function () {
|
|
Queue::fake();
|
|
|
|
$automation = Automation::factory()->create();
|
|
$run = AutomationRun::factory()->for($automation)->create([
|
|
'status' => Status::Failed,
|
|
'error' => ['message' => 'previous failure'],
|
|
'finished_at' => now(),
|
|
'current_node_id' => 'g',
|
|
]);
|
|
|
|
app(RetryRunFromNode::class)($run, 'g');
|
|
|
|
$fresh = $run->fresh();
|
|
expect($fresh->status)->toBe(Status::Pending);
|
|
expect($fresh->error)->toBeNull();
|
|
expect($fresh->finished_at)->toBeNull();
|
|
|
|
Queue::assertPushed(ProcessAutomationNode::class);
|
|
});
|
|
|
|
it('rejects retry for runs that are not failed', function () {
|
|
$automation = Automation::factory()->create();
|
|
$run = AutomationRun::factory()->for($automation)->create(['status' => Status::Completed]);
|
|
|
|
expect(fn () => app(RetryRunFromNode::class)($run, 'g'))
|
|
->toThrow(DomainException::class);
|
|
});
|