trypost/tests/Feature/Automation/Command/ProcessAutomationDelaysTest.php
Paulo Castellano b23ab0166e feat(automations): implement automation features and UI enhancements
- 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.
2026-05-24 09:17:19 -03:00

50 lines
1.6 KiB
PHP

<?php
declare(strict_types=1);
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('wakes runs whose next_action_at is in the past', function () {
Queue::fake();
$automation = Automation::factory()->create([
'nodes' => [
['id' => 't', 'type' => 'trigger', 'position' => ['x' => 0, 'y' => 0], 'data' => []],
['id' => 'g', 'type' => 'generate', 'position' => ['x' => 1, 'y' => 0], 'data' => []],
],
'connections' => [['id' => 'e1', 'source' => 't', 'target' => 'g']],
]);
$run = AutomationRun::factory()->for($automation)->create([
'status' => Status::Waiting,
'current_node_id' => 't',
'next_action_at' => now()->subMinutes(5),
]);
$this->artisan('automation:process-delays')->assertSuccessful();
$fresh = $run->fresh();
expect($fresh->status)->toBe(Status::Running);
expect($fresh->next_action_at)->toBeNull();
Queue::assertPushed(ProcessAutomationNode::class);
});
it('does not wake runs whose next_action_at is in the future', function () {
Queue::fake();
$automation = Automation::factory()->create();
$run = AutomationRun::factory()->for($automation)->create([
'status' => Status::Waiting,
'next_action_at' => now()->addMinutes(5),
]);
$this->artisan('automation:process-delays')->assertSuccessful();
expect($run->fresh()->status)->toBe(Status::Waiting);
Queue::assertNotPushed(ProcessAutomationNode::class);
});