feat(catalog): add scope to filter available variants and update related queries; enhance seeder and tests for stock validation

This commit is contained in:
2026-08-11 09:10:26 -03:00
parent 6f63a87af5
commit 19b506a465
8 changed files with 70 additions and 8 deletions

View File

@@ -76,6 +76,16 @@ class FiestaFutbolInfantilProductSeederTest extends TestCase
$this->assertCount($count, $item->variants);
}
$variantStocks = CatalogItem::query()
->where('tenant_code', $tenant->codigo)
->with('variants.inventory')
->get()
->flatMap(fn (CatalogItem $item) => $item->variants)
->map(fn ($variant): int => $variant->inventory->real_stock);
$this->assertGreaterThan($variantStocks->count() / 2, $variantStocks->filter(fn (int $stock): bool => $stock > 5)->count());
$this->assertNotEmpty($variantStocks->filter(fn (int $stock): bool => $stock === 0));
$this->assertNotEmpty($variantStocks->filter(fn (int $stock): bool => $stock >= 1 && $stock <= 5));
$this->assertSame(
[
'abono' => 'Entradas',