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'); }); it('relationship filter limits edges by type', function () { [$user, $tenant] = createUserWithTenant(); $this->actingAs($user); /** @var InventoryItem $item */ $item = InventoryItem::factory()->create([ 'tenant_id' => $tenant->getKey(), 'external_id' => (string) Str::uuid(), ]); // Two outbound edges with different relationship types. 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' => 'Assigned Target'], ]); InventoryLink::factory()->create([ 'tenant_id' => $tenant->getKey(), 'source_type' => 'inventory_item', 'source_id' => $item->external_id, 'target_type' => 'missing', 'target_id' => null, 'relationship_type' => 'scoped_by', 'metadata' => ['last_known_name' => 'Scoped Target'], ]); $url = InventoryItemResource::getUrl('view', ['record' => $item], tenant: $tenant) .'?direction=outbound&relationship_type=scoped_by'; $this->get($url) ->assertOk() ->assertSee('Scoped Target') ->assertDontSee('Assigned Target'); });