fix(admin): render workflow rule summaries correctly
This commit is contained in:
2 files changed
+24
-1
No files matched your search
+2
-1
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Filament\Resources\WorkflowConfigurations\Schemas;
|
namespace App\Filament\Resources\WorkflowConfigurations\Schemas;
|
||||||
|
|
||||||
use App\Domain\Loan\Enums\WorkflowConfigurationStatus;
|
use App\Domain\Loan\Enums\WorkflowConfigurationStatus;
|
||||||
|
use App\Models\WorkflowConfigurationStep;
|
||||||
use Filament\Infolists\Components\IconEntry;
|
use Filament\Infolists\Components\IconEntry;
|
||||||
use Filament\Infolists\Components\RepeatableEntry;
|
use Filament\Infolists\Components\RepeatableEntry;
|
||||||
use Filament\Infolists\Components\TextEntry;
|
use Filament\Infolists\Components\TextEntry;
|
||||||
@@ -56,7 +57,7 @@ class WorkflowConfigurationInfolist
|
|||||||
IconEntry::make('is_enabled')->label('Enabled')->boolean(),
|
IconEntry::make('is_enabled')->label('Enabled')->boolean(),
|
||||||
TextEntry::make('rules')
|
TextEntry::make('rules')
|
||||||
->label('Rules')
|
->label('Rules')
|
||||||
->formatStateUsing(fn (array $state): string => collect($state)
|
->state(fn (WorkflowConfigurationStep $record): string => collect($record->rules)
|
||||||
->map(fn (mixed $value, string $key): string => str($key)->headline().': '.(is_bool($value) ? ($value ? 'Yes' : 'No') : $value))
|
->map(fn (mixed $value, string $key): string => str($key)->headline().': '.(is_bool($value) ? ($value ? 'Yes' : 'No') : $value))
|
||||||
->implode(' · '))
|
->implode(' · '))
|
||||||
->placeholder('No configurable rules')
|
->placeholder('No configurable rules')
|
||||||
|
|||||||
@@ -4,15 +4,37 @@ use App\Actions\WorkflowConfiguration\CreateWorkflowConfigurationAction;
|
|||||||
use App\Actions\WorkflowConfiguration\PublishWorkflowConfigurationAction;
|
use App\Actions\WorkflowConfiguration\PublishWorkflowConfigurationAction;
|
||||||
use App\Domain\Loan\Enums\LoanStage;
|
use App\Domain\Loan\Enums\LoanStage;
|
||||||
use App\Domain\Loan\Enums\WorkflowConfigurationStatus;
|
use App\Domain\Loan\Enums\WorkflowConfigurationStatus;
|
||||||
|
use App\Filament\Resources\WorkflowConfigurations\Pages\ViewWorkflowConfiguration;
|
||||||
use App\Models\LoanType;
|
use App\Models\LoanType;
|
||||||
use App\Models\StageDefinition;
|
use App\Models\StageDefinition;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Models\WorkflowConfiguration;
|
use App\Models\WorkflowConfiguration;
|
||||||
|
use Filament\Facades\Filament;
|
||||||
use Illuminate\Foundation\Testing\LazilyRefreshDatabase;
|
use Illuminate\Foundation\Testing\LazilyRefreshDatabase;
|
||||||
use Illuminate\Validation\ValidationException;
|
use Illuminate\Validation\ValidationException;
|
||||||
|
use Livewire\Livewire;
|
||||||
|
|
||||||
uses(LazilyRefreshDatabase::class);
|
uses(LazilyRefreshDatabase::class);
|
||||||
|
|
||||||
|
test('a workflow with configured rules can be viewed', function () {
|
||||||
|
$user = User::factory()->create();
|
||||||
|
$stage = StageDefinition::factory()->forStage(LoanStage::FraudCheck)->create();
|
||||||
|
$workflow = WorkflowConfiguration::factory()
|
||||||
|
->withStep($stage, 1, [
|
||||||
|
'fraudPrefix' => 'FRAUD',
|
||||||
|
'guarantorRequired' => true,
|
||||||
|
])
|
||||||
|
->create();
|
||||||
|
|
||||||
|
Filament::setCurrentPanel(Filament::getPanel('admin'));
|
||||||
|
|
||||||
|
Livewire::actingAs($user)
|
||||||
|
->test(ViewWorkflowConfiguration::class, ['record' => $workflow->getRouteKey()])
|
||||||
|
->assertOk()
|
||||||
|
->assertSee('Fraud Prefix: FRAUD')
|
||||||
|
->assertSee('Guarantor Required: Yes');
|
||||||
|
});
|
||||||
|
|
||||||
test('copying a workflow creates an isolated next draft version', function () {
|
test('copying a workflow creates an isolated next draft version', function () {
|
||||||
$user = User::factory()->create();
|
$user = User::factory()->create();
|
||||||
$loanType = LoanType::factory()->create(['code' => 'PERSONAL']);
|
$loanType = LoanType::factory()->create(['code' => 'PERSONAL']);
|
||||||
|
|||||||
Reference in new issue
Block a user