## Summary Fixes a tenant dashboard Internal Server Error caused by `App\\Models\\BaselineCompareRun` being referenced but not existing. ## What changed - Dashboard widget now uses `OperationRun` (`type=baseline_compare`, context baseline_profile_id, ordered by completed_at) instead of the missing model. - Added regression test ensuring tenant dashboard renders when a baseline assignment exists. ## Tests - `vendor/bin/sail artisan test --compact tests/Feature/Filament/BaselineCompareNowWidgetTest.php` - `vendor/bin/sail artisan test --compact tests/Feature/Filament/TenantDashboardDbOnlyTest.php tests/Feature/Filament/TenantDashboardTenantScopeTest.php` ## Notes No UX changes; this is a runtime stability fix only. Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #125
47 lines
1.5 KiB
PHP
47 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Filament\Pages\TenantDashboard;
|
|
use App\Models\BaselineProfile;
|
|
use App\Models\BaselineTenantAssignment;
|
|
use App\Models\OperationRun;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
it('renders the tenant dashboard when a baseline assignment exists (regression: missing BaselineCompareRun model)', function (): void {
|
|
[$user, $tenant] = createUserWithTenant(role: 'owner');
|
|
|
|
$profile = BaselineProfile::factory()->create([
|
|
'workspace_id' => (int) $tenant->workspace_id,
|
|
'name' => 'Baseline A',
|
|
]);
|
|
|
|
BaselineTenantAssignment::factory()->create([
|
|
'workspace_id' => (int) $tenant->workspace_id,
|
|
'tenant_id' => (int) $tenant->getKey(),
|
|
'baseline_profile_id' => (int) $profile->getKey(),
|
|
]);
|
|
|
|
OperationRun::factory()->create([
|
|
'tenant_id' => (int) $tenant->getKey(),
|
|
'workspace_id' => (int) $tenant->workspace_id,
|
|
'type' => 'baseline_compare',
|
|
'status' => 'completed',
|
|
'outcome' => 'succeeded',
|
|
'initiator_name' => 'System',
|
|
'context' => [
|
|
'baseline_profile_id' => (int) $profile->getKey(),
|
|
],
|
|
'completed_at' => now()->subDay(),
|
|
]);
|
|
|
|
$this->actingAs($user)
|
|
->get(TenantDashboard::getUrl(tenant: $tenant))
|
|
->assertOk()
|
|
->assertSee('Baseline Governance')
|
|
->assertSee('Baseline A')
|
|
->assertSee('No open drift — baseline compliant');
|
|
});
|