72 lines
2.5 KiB
PHP
72 lines
2.5 KiB
PHP
<?php
|
|
|
|
use App\Filament\Resources\InventoryItemResource;
|
|
use App\Models\InventoryItem;
|
|
use App\Models\InventoryLink;
|
|
use Illuminate\Support\Str;
|
|
|
|
it('shows zero-state when no dependencies and shows missing badge when applicable', function () {
|
|
[$user, $tenant] = createUserWithTenant();
|
|
$this->actingAs($user);
|
|
|
|
/** @var InventoryItem $item */
|
|
$item = InventoryItem::factory()->create([
|
|
'tenant_id' => $tenant->getKey(),
|
|
'external_id' => (string) Str::uuid(),
|
|
]);
|
|
|
|
// Zero state
|
|
$url = InventoryItemResource::getUrl('view', ['record' => $item], tenant: $tenant);
|
|
$this->get($url)->assertOk()->assertSee('No dependencies found');
|
|
|
|
// Create a missing edge and assert badge appears
|
|
InventoryLink::factory()->create([
|
|
'tenant_id' => $tenant->getKey(),
|
|
'source_type' => 'inventory_item',
|
|
'source_id' => $item->external_id,
|
|
'target_type' => 'missing',
|
|
'target_id' => null,
|
|
'relationship_type' => 'assigned_to',
|
|
'metadata' => ['last_known_name' => null],
|
|
]);
|
|
|
|
$this->get($url)->assertOk()->assertSee('Missing');
|
|
});
|
|
|
|
it('direction filter limits to outbound or inbound', function () {
|
|
[$user, $tenant] = createUserWithTenant();
|
|
$this->actingAs($user);
|
|
|
|
/** @var InventoryItem $item */
|
|
$item = InventoryItem::factory()->create([
|
|
'tenant_id' => $tenant->getKey(),
|
|
'external_id' => (string) Str::uuid(),
|
|
]);
|
|
|
|
// Outbound only
|
|
InventoryLink::factory()->create([
|
|
'tenant_id' => $tenant->getKey(),
|
|
'source_type' => 'inventory_item',
|
|
'source_id' => $item->external_id,
|
|
'target_type' => 'foundation_object',
|
|
'target_id' => (string) Str::uuid(),
|
|
'relationship_type' => 'assigned_to',
|
|
]);
|
|
|
|
// Inbound only
|
|
InventoryLink::factory()->create([
|
|
'tenant_id' => $tenant->getKey(),
|
|
'source_type' => 'inventory_item',
|
|
'source_id' => (string) Str::uuid(),
|
|
'target_type' => 'inventory_item',
|
|
'target_id' => $item->external_id,
|
|
'relationship_type' => 'depends_on',
|
|
]);
|
|
|
|
$urlOutbound = InventoryItemResource::getUrl('view', ['record' => $item], tenant: $tenant).'?direction=outbound';
|
|
$this->get($urlOutbound)->assertOk()->assertDontSee('No dependencies found');
|
|
|
|
$urlInbound = InventoryItemResource::getUrl('view', ['record' => $item], tenant: $tenant).'?direction=inbound';
|
|
$this->get($urlInbound)->assertOk()->assertDontSee('No dependencies found');
|
|
});
|