actingAs($user); $tenant->makeCurrent(); Filament::setTenant($tenant, true); /** @var OperationRunService $operationRuns */ $operationRuns = app(OperationRunService::class); $run = $operationRuns->ensureRun( tenant: $tenant, type: 'policy.export', inputs: ['scope' => 'subset', 'policy_ids' => [999_999_991]], initiator: $user, ); $job = new BulkPolicyExportJob( tenantId: (int) $tenant->getKey(), userId: (int) $user->getKey(), policyIds: [999_999_991], backupName: 'OpsUx Circuit Breaker Regression', operationRun: $run, ); $job->handle($operationRuns); $run->refresh(); expect($run->status)->toBe('completed'); expect($run->outcome)->toBe('failed'); expect((int) ($run->summary_counts['failed'] ?? 0))->toBeGreaterThan(0); expect($user->notifications()->count())->toBe(1); $this->assertDatabaseHas('notifications', [ 'notifiable_id' => $user->getKey(), 'notifiable_type' => $user->getMorphClass(), 'type' => OperationRunCompleted::class, ]); $this->assertDatabaseMissing('notifications', [ 'notifiable_id' => $user->getKey(), 'notifiable_type' => $user->getMorphClass(), 'type' => DatabaseNotification::class, ]); })->group('ops-ux');