fix(admin): eager load workflow stage definitions
This commit is contained in:
2 files changed
+15
-3
No files matched your search
@@ -5,6 +5,7 @@ namespace App\Filament\Resources\WorkflowConfigurations\Pages;
|
||||
use App\Actions\WorkflowConfiguration\PublishWorkflowConfigurationAction;
|
||||
use App\Filament\Resources\WorkflowConfigurations\WorkflowConfigurationResource;
|
||||
use App\Models\User;
|
||||
use App\Models\WorkflowConfiguration;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Notifications\Notification;
|
||||
@@ -21,6 +22,14 @@ class ViewWorkflowConfiguration extends ViewRecord
|
||||
$this->publishWorkflowConfiguration = $publishWorkflowConfiguration;
|
||||
}
|
||||
|
||||
protected function resolveRecord(int|string $key): WorkflowConfiguration
|
||||
{
|
||||
/** @var WorkflowConfiguration $record */
|
||||
$record = parent::resolveRecord($key);
|
||||
|
||||
return $record->loadMissing('steps.stageDefinition');
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
|
||||
@@ -18,12 +18,13 @@ uses(LazilyRefreshDatabase::class);
|
||||
|
||||
test('a workflow with configured rules can be viewed', function () {
|
||||
$user = User::factory()->create();
|
||||
$stage = StageDefinition::factory()->forStage(LoanStage::FraudCheck)->create();
|
||||
$fraudStage = StageDefinition::factory()->forStage(LoanStage::FraudCheck)->create();
|
||||
$guarantorStage = StageDefinition::factory()->forStage(LoanStage::GuarantorCheck)->create();
|
||||
$workflow = WorkflowConfiguration::factory()
|
||||
->withStep($stage, 1, [
|
||||
->withStep($fraudStage, 1, [
|
||||
'fraudPrefix' => 'FRAUD',
|
||||
'guarantorRequired' => true,
|
||||
])
|
||||
->withStep($guarantorStage, 2, ['guarantorRequired' => true])
|
||||
->create();
|
||||
|
||||
Filament::setCurrentPanel(Filament::getPanel('admin'));
|
||||
@@ -31,6 +32,8 @@ test('a workflow with configured rules can be viewed', function () {
|
||||
Livewire::actingAs($user)
|
||||
->test(ViewWorkflowConfiguration::class, ['record' => $workflow->getRouteKey()])
|
||||
->assertOk()
|
||||
->assertSee($fraudStage->name)
|
||||
->assertSee($guarantorStage->name)
|
||||
->assertSee('Fraud Prefix: FRAUD')
|
||||
->assertSee('Guarantor Required: Yes');
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user